use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method deleteFeedbackResponsesForQuestionAndCascade.
public void deleteFeedbackResponsesForQuestionAndCascade(String feedbackQuestionId, boolean hasResponseRateUpdate) {
List<FeedbackResponseAttributes> responsesForQuestion = getFeedbackResponsesForQuestion(feedbackQuestionId);
Set<String> emails = new HashSet<>();
for (FeedbackResponseAttributes response : responsesForQuestion) {
this.deleteFeedbackResponseAndCascade(response);
emails.add(response.giver);
}
if (!hasResponseRateUpdate) {
return;
}
try {
FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(feedbackQuestionId);
boolean isInstructor = question.giverType == FeedbackParticipantType.SELF || question.giverType == FeedbackParticipantType.INSTRUCTORS;
for (String email : emails) {
boolean hasResponses = hasGiverRespondedForSession(email, question.feedbackSessionName, question.courseId);
if (!hasResponses) {
if (isInstructor) {
fsLogic.deleteInstructorRespondent(email, question.feedbackSessionName, question.courseId);
} else {
fsLogic.deleteStudentFromRespondentList(email, question.feedbackSessionName, question.courseId);
}
}
}
} catch (InvalidParametersException | EntityDoesNotExistException e) {
Assumption.fail("Fail to delete respondent");
}
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method clearStudentRespondents.
public void clearStudentRespondents(String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.clearStudentRespondents(sessionToUpdate);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method addStudentRespondents.
public void addStudentRespondents(List<String> emails, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, emails);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.addStudentRespondents(emails, sessionToUpdate);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method deleteStudentFromRespondentList.
public void deleteStudentFromRespondentList(String email, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, email);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.deleteStudentRespondent(email, sessionToUpdate);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionQuestionsForStudent.
/**
* Gets {@code FeedbackQuestions} and previously filled
* {@code FeedbackResponses} that a student can view/submit as a
* {@link FeedbackSessionQuestionsBundle}.
*/
public FeedbackSessionQuestionsBundle getFeedbackSessionQuestionsForStudent(String feedbackSessionName, String courseId, String userEmail) throws EntityDoesNotExistException {
FeedbackSessionAttributes fsa = fsDb.getFeedbackSession(courseId, feedbackSessionName);
if (fsa == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_GET + courseId + "/" + feedbackSessionName);
}
StudentAttributes student = studentsLogic.getStudentForEmail(courseId, userEmail);
if (student == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_STUDENT);
}
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> bundle = new HashMap<>();
Map<String, Map<String, String>> recipientList = new HashMap<>();
List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForStudents(feedbackSessionName, courseId);
Set<String> hiddenInstructorEmails = null;
for (FeedbackQuestionAttributes question : questions) {
if (question.getRecipientType() == FeedbackParticipantType.INSTRUCTORS) {
hiddenInstructorEmails = getHiddenInstructorEmails(courseId);
break;
}
}
for (FeedbackQuestionAttributes question : questions) {
updateBundleAndRecipientListWithResponsesForStudent(userEmail, student, bundle, recipientList, question, hiddenInstructorEmails);
}
return new FeedbackSessionQuestionsBundle(fsa, bundle, recipientList);
}
Aggregations