use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorEditStudentFeedbackPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String moderatedEntityIdentifier = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON);
StudentAttributes studentUnderModeration = logic.getStudentForEmail(courseId, moderatedEntityIdentifier);
if (studentUnderModeration == null) {
List<TeamDetailsBundle> teams = logic.getTeamsForCourse(courseId);
boolean isTeam = false;
for (TeamDetailsBundle team : teams) {
if (team.name.equals(moderatedEntityIdentifier)) {
isTeam = true;
studentUnderModeration = team.students.get(0);
break;
}
}
if (!isTeam) {
throw new EntityDoesNotExistException("An entity with the identifier " + moderatedEntityIdentifier + " does not exist in " + courseId + ".");
}
}
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, studentUnderModeration.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS);
String moderatedQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_QUESTION_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedEntityIdentifier);
FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
data.bundle = logic.getFeedbackSessionQuestionsBundleForStudent(feedbackSessionName, courseId, studentUnderModeration.email);
Assumption.assertNotNull(data.bundle);
data.setSessionOpenForSubmission(true);
data.setModeration(true);
data.setHeaderHidden(true);
data.setStudentToViewPageAs(studentUnderModeration);
data.setSubmitAction(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_SAVE);
if (moderatedQuestionId != null) {
data.setModeratedQuestionId(moderatedQuestionId);
}
statusToAdmin = "Moderating feedback session for student (" + studentUnderModeration.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
data.bundle.hideUnmoderatableQuestions();
data.init(courseId);
return createShowPageResult(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, data);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorFeedbackEditPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
String shouldLoadInEditModeParam = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENABLE_EDIT);
boolean shouldLoadInEditMode = "true".equals(shouldLoadInEditModeParam);
FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), feedbackSession, false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
List<FeedbackQuestionAttributes> questions = logic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
Map<String, Boolean> questionHasResponses = new HashMap<>();
for (FeedbackQuestionAttributes question : questions) {
boolean hasResponse = logic.areThereResponsesForQuestion(question.getId());
questionHasResponses.put(question.getId(), hasResponse);
}
List<StudentAttributes> studentList = logic.getStudentsForCourse(courseId);
studentList.sort(Comparator.comparing((StudentAttributes student) -> student.team.toLowerCase()).thenComparing(student -> student.name.toLowerCase()));
List<InstructorAttributes> instructorList = logic.getInstructorsForCourse(courseId);
List<InstructorAttributes> instructorsWhoCanSubmit = new ArrayList<>();
for (InstructorAttributes instructor : instructorList) {
if (instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS)) {
instructorsWhoCanSubmit.add(instructor);
}
}
instructorList.sort(Comparator.comparing(instructor -> instructor.name.toLowerCase()));
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
int numOfInstructors = instructorList.size();
statusToAdmin = "instructorFeedbackEdit Page Load<br>" + "Editing information for Feedback Session " + "<span class=\"bold\">[" + feedbackSessionName + "]</span>" + "in Course: <span class=\"bold\">[" + courseId + "]</span>";
InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(account, sessionToken);
data.init(feedbackSession, questions, questionHasResponses, studentList, instructorsWhoCanSubmit, instructor, shouldLoadInEditMode, numOfInstructors, logic.getCourseDetails(courseId));
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_EDIT, data);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorFeedbackPreviewAsStudentAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String previewStudentEmail = getRequestParamValue(Const.ParamsNames.PREVIEWAS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
Assumption.assertPostParamNotNull(Const.ParamsNames.PREVIEWAS, previewStudentEmail);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
StudentAttributes previewStudent = logic.getStudentForEmail(courseId, previewStudentEmail);
if (previewStudent == null) {
throw new EntityDoesNotExistException("Student Email " + previewStudentEmail + " does not exist in " + courseId + ".");
}
FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, previewStudent, sessionToken);
data.bundle = logic.getFeedbackSessionQuestionsBundleForStudent(feedbackSessionName, courseId, previewStudent.email);
data.setSessionOpenForSubmission(true);
data.setPreview(true);
data.setHeaderHidden(true);
data.setStudentToViewPageAs(previewStudent);
data.setSubmitAction(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_SAVE);
data.bundle.resetAllResponses();
statusToAdmin = "Preview feedback session as student (" + previewStudent.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
data.init("", "", courseId);
return createShowPageResult(Const.ViewURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT, data);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class AdminExceptionTestAction method execute.
@Override
// deliberately done for testing
@SuppressWarnings("PMD.AvoidThrowingNullPointerException")
protected ActionResult execute() throws EntityDoesNotExistException {
gateKeeper.verifyAdminPrivileges(account);
String error = getRequestParamValue(Const.ParamsNames.ERROR);
if (error.equals(AssertionError.class.getSimpleName())) {
throw new AssertionError("AssertionError Testing");
} else if (error.equals(EntityDoesNotExistException.class.getSimpleName())) {
throw new EntityDoesNotExistException("EntityDoesNotExistException Testing");
} else if (error.equals(UnauthorizedAccessException.class.getSimpleName())) {
throw new UnauthorizedAccessException();
} else if (error.equals(NullPointerException.class.getSimpleName())) {
throw new NullPointerException();
} else if (error.equals(DeadlineExceededException.class.getSimpleName())) {
throw new DeadlineExceededException();
} else if (error.equals(NullPostParameterException.class.getSimpleName())) {
throw new NullPostParameterException("test null post param exception");
}
statusToAdmin = "adminExceptionTest";
return createRedirectResult(Const.ActionURIs.ADMIN_HOME_PAGE);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditSaveAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
if (student == null) {
return redirectWithError(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, "Student <span class=\"bold\">" + studentEmail + "</span> in " + "Course <span class=\"bold\">[" + courseId + "]</span> not found.", courseId);
}
student.name = getRequestParamValue(Const.ParamsNames.STUDENT_NAME);
student.email = getRequestParamValue(Const.ParamsNames.NEW_STUDENT_EMAIL);
student.team = getRequestParamValue(Const.ParamsNames.TEAM_NAME);
student.section = getRequestParamValue(Const.ParamsNames.SECTION_NAME);
student.comments = getRequestParamValue(Const.ParamsNames.COMMENTS);
boolean hasSection = logic.hasIndicatedSections(courseId);
student.name = SanitizationHelper.sanitizeName(student.name);
student.email = SanitizationHelper.sanitizeEmail(student.email);
student.team = SanitizationHelper.sanitizeName(student.team);
student.section = SanitizationHelper.sanitizeName(student.section);
student.comments = SanitizationHelper.sanitizeTextField(student.comments);
try {
StudentAttributes originalStudentAttribute = logic.getStudentForEmail(courseId, studentEmail);
student.updateWithExistingRecord(originalStudentAttribute);
boolean isSectionChanged = student.isSectionChanged(originalStudentAttribute);
boolean isTeamChanged = student.isTeamChanged(originalStudentAttribute);
boolean isEmailChanged = student.isEmailChanged(originalStudentAttribute);
if (isSectionChanged) {
logic.validateSectionsAndTeams(Arrays.asList(student), courseId);
} else if (isTeamChanged) {
logic.validateTeams(Arrays.asList(student), courseId);
}
logic.updateStudent(studentEmail, student);
boolean isSessionSummarySendEmail = getRequestParamAsBoolean(Const.ParamsNames.SESSION_SUMMARY_EMAIL_SEND_CHECK);
if (isEmailChanged) {
logic.resetStudentGoogleId(student.email, courseId);
if (isSessionSummarySendEmail) {
try {
EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(courseId, student);
emailSender.sendEmail(email);
} catch (Exception e) {
log.severe("Error while sending session summary email" + TeammatesException.toStringWithStackTrace(e));
}
}
}
statusToUser.add(new StatusMessage(isSessionSummarySendEmail && isEmailChanged ? Const.StatusMessages.STUDENT_EDITED_AND_EMAIL_SENT : Const.StatusMessages.STUDENT_EDITED, StatusMessageColor.SUCCESS));
statusToAdmin = "Student <span class=\"bold\">" + studentEmail + "'s</span> details in " + "Course <span class=\"bold\">[" + courseId + "]</span> edited.<br>" + "New Email: " + student.email + "<br>New Team: " + student.team + "<br>" + "Comments: " + student.comments;
RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return result;
} catch (InvalidParametersException | EnrollException e) {
setStatusForException(e);
String newEmail = student.email;
student.email = studentEmail;
boolean isOpenOrPublishedEmailSentForTheCourse = logic.isOpenOrPublishedEmailSentForTheCourse(courseId);
InstructorCourseStudentDetailsEditPageData data = new InstructorCourseStudentDetailsEditPageData(account, sessionToken, student, newEmail, hasSection, isOpenOrPublishedEmailSentForTheCourse);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, data);
}
}
Aggregations