Commit e13e5810 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

checking if not already subbmited flag - fixed

parent 2b5924d5
......@@ -13,12 +13,14 @@ public class Solution
private Task task;
private Team team;
private Flag flag;
private String hashValue;
public Solution(Team team, Task task, Flag flag)
public Solution(Team team, Task task, Flag flag, String hashValue)
{
this.team = team;
this.task = task;
this.flag = flag;
this.hashValue = hashValue;
}
public Solution()
......@@ -54,4 +56,14 @@ public class Solution
{
this.flag = flag;
}
public String getHashValue()
{
return hashValue;
}
public void setHashValue(String hashValue)
{
this.hashValue = hashValue;
}
}
......@@ -77,6 +77,7 @@ public class SolutionsRepository implements Repository
@Override
public boolean test(Solution solution)
{
//todo: compare flags, not flag values
return solution.getFlag().getValue().equals(value);
}
})
......
......@@ -166,10 +166,11 @@ public class TasksRepository implements Repository
Pair<Task, Flag> taskFlagPair = taskFlagPairOptional.get();
Task task = taskFlagPair.getKey();
Flag flag = taskFlagPair.getValue();
Optional<Team> team = teamsRepository.getTeamByUser(user);
if (team.isPresent()) {
//todo: combine ifs
Solution solution = new Solution(team.get(), task, hashValue); //todo: conflict, solution stores task flag, should store hashValue!!
Solution solution = new Solution(team.get(), task, flag, hashValue);
if (!isAlreadySubmittedSolution(solution)) {
solutionsRepository.add(solution);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment