Example #1
0
  private static void writeMarks(
      final List<AttendsMark> marks,
      final ExecutionCourse executionCourse,
      final Evaluation evaluation)
      throws FenixServiceMultipleException {

    final List<DomainException> exceptionList = new ArrayList<DomainException>();

    for (final AttendsMark entry : marks) {

      final Attends attend = findAttend(executionCourse, entry.attendId);
      final String markValue = entry.mark;

      if (attend.hasEnrolment() && attend.getEnrolment().isImpossible()) {
        exceptionList.add(
            new DomainException(
                "errors.student.with.impossible.enrolment",
                attend.getRegistration().getStudent().getNumber().toString()));
      } else {
        final Mark mark = attend.getMarkByEvaluation(evaluation);

        if (isToDeleteMark(markValue)) {
          if (mark != null) {
            mark.delete();
          }
        } else {
          try {
            if (mark == null) {
              evaluation.addNewMark(attend, markValue);
            } else {
              mark.setMark(markValue);
            }
          } catch (InvalidMarkDomainException e) {
            exceptionList.add(e);
          }
        }
      }
    }

    if (!exceptionList.isEmpty()) {
      throw new FenixServiceMultipleException(exceptionList);
    }

    EvaluationManagementLog.createLog(
        executionCourse,
        "resources.MessagingResources",
        "log.executionCourse.evaluation.generic.edited.marks",
        evaluation.getPresentationName(),
        executionCourse.getName(),
        executionCourse.getDegreePresentationString());
  }