Ejemplo n.º 1
0
  public void mergeChallengeWithModel(ChallengeModel challengeModel, Challenge challenge) {
    challenge.setChallengeType(challengeModel.getChallengeType());

    challenge.getTitles().clear();
    for (ChallengeModel.MultiLingoText title : challengeModel.getTitles()) {
      challenge.getTitles().put(title.getLingo(), title.getText());
    }

    challenge.getDescriptions().clear();
    for (ChallengeModel.MultiLingoText description : challengeModel.getDescriptions()) {
      challenge.getDescriptions().put(description.getLingo(), description.getText());
    }

    challenge.getSignatures().clear();
    for (ChallengeModel.MultiLingoText signature : challengeModel.getSignatures()) {
      challenge.getSignatures().put(signature.getLingo(), signature.getText());
    }

    challenge.getInputTypes().clear();
    challenge.setInputTypes(ChallengeInputType.createFrom(challengeModel.getInputTypes()));

    challenge.setOutputType(challengeModel.getOutputType());

    challenge.getTestCases().clear();
    for (ChallengeModel.TestCase testCase : challengeModel.getTestCases()) {
      challenge.addTestCase(testCase.getInputValues(), testCase.getOutputValue());
    }
    TestCase.prioritize(challenge.getTestCases());

    if (challengeModel.getApproved() != null) {
      challenge.setApproved(challengeModel.getApproved());
    }

    Long levelId = challengeModel.getLevel();
    if (levelId != null) {
      challenge.setLevel(levelService.findById(levelId));
    } else if (authenticationService.isCurrentUserAdmin()) {
      challenge.setLevel(null);
    }
  }
Ejemplo n.º 2
0
 private List<Solution> getSolutionsOfUser(Challenge challenge) {
   User currentUser = authenticationService.getCurrentUser();
   return solutionDao.findSolutionsBy(challenge, currentUser);
 }
Ejemplo n.º 3
0
 public Set<Challenge> getSolvedChallengesOfCurrentUser() {
   return getSolvedChallengesOf(authenticationService.getCurrentUser());
 }