protected void run(String executionCourseID, String evaluationID, List<String> roomIDs, Boolean sendSMS,
Boolean distributeOnlyEnroledStudents) throws FenixServiceException {
final WrittenEvaluation writtenEvaluation = (WrittenEvaluation) FenixFramework.getDomainObject(evaluationID);
if (writtenEvaluation == null) {
throw new FenixServiceException("error.noWrittenEvaluation");
}
List<Registration> studentsToDistribute;
if (distributeOnlyEnroledStudents) {
studentsToDistribute = readEnroledStudentsInWrittenEvaluation(writtenEvaluation);
} else {
studentsToDistribute = readAllStudentsAttendingExecutionCourses(writtenEvaluation);
}
final List<Space> selectedRooms = readRooms(writtenEvaluation, roomIDs);
if (!selectedRooms.containsAll(writtenEvaluation.getAssociatedRooms())) {
// if the selected rooms are different of the evaluation rooms
// then the user probably selected repeated rooms
throw new FenixServiceException("error.repeated.rooms");
}
writtenEvaluation.distributeStudentsByRooms(studentsToDistribute, selectedRooms);
if (sendSMS) {
sendSMSToStudents(writtenEvaluation);
}