use of teammates.common.exception.EntityAlreadyExistsException in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveAction method enrollAndProcessResultForDisplay.
private List<StudentAttributes>[] enrollAndProcessResultForDisplay(String studentsInfo, String courseId) throws EnrollException, EntityDoesNotExistException, InvalidParametersException, EntityAlreadyExistsException {
CourseEnrollmentResult enrollResult = logic.enrollStudents(studentsInfo, courseId);
List<StudentAttributes> students = enrollResult.studentList;
// Adjust submissions for all feedback responses within the course
List<FeedbackSessionAttributes> feedbackSessions = logic.getFeedbackSessionsForCourse(courseId);
for (FeedbackSessionAttributes session : feedbackSessions) {
// Schedule adjustment of submissions for feedback session in course
taskQueuer.scheduleFeedbackResponseAdjustmentForCourse(courseId, session.getFeedbackSessionName(), enrollResult.enrollmentList);
}
students.sort(Comparator.comparing(obj -> obj.updateStatus.numericRepresentation));
return separateStudents(students);
}
use of teammates.common.exception.EntityAlreadyExistsException in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method updateFeedbackResponsesForChangingEmail.
/**
* Updates responses for a student when his email changes.
*/
// TODO: cascade the update to response comments
public void updateFeedbackResponsesForChangingEmail(String courseId, String oldEmail, String newEmail) throws InvalidParametersException, EntityDoesNotExistException {
List<FeedbackResponseAttributes> responsesFromUser = getFeedbackResponsesFromGiverForCourse(courseId, oldEmail);
for (FeedbackResponseAttributes response : responsesFromUser) {
response.giver = newEmail;
try {
updateFeedbackResponse(response);
} catch (EntityAlreadyExistsException e) {
Assumption.fail("Feedback response failed to update successfully" + "as email was already in use.");
}
}
List<FeedbackResponseAttributes> responsesToUser = getFeedbackResponsesForReceiverForCourse(courseId, oldEmail);
for (FeedbackResponseAttributes response : responsesToUser) {
response.recipient = newEmail;
try {
updateFeedbackResponse(response);
} catch (EntityAlreadyExistsException e) {
Assumption.fail("Feedback response failed to update successfully" + "as email was already in use.");
}
}
}
use of teammates.common.exception.EntityAlreadyExistsException in project teammates by TEAMMATES.
the class StudentsDb method recreateStudentWithNewEmail.
@SuppressWarnings("PMD.PreserveStackTrace")
private void recreateStudentWithNewEmail(CourseStudent newCourseStudent, String lastName, CourseStudent courseStudent, boolean hasDocument, boolean keepUpdateTimestamp, String courseId, String email) throws InvalidParametersException {
newCourseStudent.setLastName(lastName);
newCourseStudent.setCreatedAt(courseStudent.getCreatedAt());
if (keepUpdateTimestamp) {
newCourseStudent.setLastUpdate(courseStudent.getUpdatedAt());
}
StudentAttributes newCourseStudentAttributes = makeAttributes(newCourseStudent);
try {
createStudent(newCourseStudentAttributes, hasDocument);
} catch (EntityAlreadyExistsException e) {
CourseStudent existingStudent = getEntity(newCourseStudentAttributes);
String error = ERROR_UPDATE_EMAIL_ALREADY_USED + existingStudent.getName() + "/" + existingStudent.getEmail();
throw new InvalidParametersException(error);
}
deleteStudent(courseId, email);
}
Aggregations