use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class SystemErrorEmailReportTest method testEntityDoesNotExistException.
private void testEntityDoesNotExistException() {
______TS("EntityDoesNotExistException testing");
AppUrl url = createUrl(Const.ActionURIs.ADMIN_EXCEPTION_TEST).withParam(Const.ParamsNames.ERROR, EntityDoesNotExistException.class.getSimpleName());
page.navigateTo(url);
print("This exception is handled by system, make sure you don't receive any emails. ");
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorEditInstructorFeedbackPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String instructorUnderModerationEmail = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
InstructorAttributes instructorUnderModeration = logic.getInstructorForEmail(courseId, instructorUnderModerationEmail);
// If the instructor doesn't exist
if (instructorUnderModeration == null) {
throw new EntityDoesNotExistException("Instructor Email " + instructorUnderModerationEmail + " does not exist in " + courseId + ".");
}
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, instructorUnderModerationEmail);
FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
data.bundle = logic.getFeedbackSessionQuestionsBundleForInstructor(feedbackSessionName, courseId, instructorUnderModeration.email);
Assumption.assertNotNull(data.bundle);
data.setSessionOpenForSubmission(true);
data.setModeration(true);
data.setHeaderHidden(true);
data.setPreviewInstructor(instructorUnderModeration);
data.setSubmitAction(Const.ActionURIs.INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_SAVE);
if (moderatedQuestionId != null) {
data.setModeratedQuestionId(moderatedQuestionId);
}
statusToAdmin = "Moderating feedback session for instructor (" + instructorUnderModeration.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
data.bundle.hideUnmoderatableQuestions();
data.init(courseId);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, data);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String showStats = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SHOWSTATS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
statusToAdmin = "Show instructor feedback result page<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
boolean isCreatorOnly = true;
gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly);
InstructorFeedbackResultsPageData data = new InstructorFeedbackResultsPageData(account, sessionToken);
String selectedSection = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION);
if (selectedSection == null) {
selectedSection = ALL_SECTION_OPTION;
}
boolean isMissingResponsesShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES);
// this is for ajax loading of the html table in the modal
// "(Non-English characters not displayed properly in the downloaded file? click here)"
// TODO move into another action and another page data class
boolean isLoadingCsvResultsAsHtml = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
if (isLoadingCsvResultsAsHtml) {
return createAjaxResultForCsvTableLoadedInHtml(courseId, feedbackSessionName, instructor, data, selectedSection, isMissingResponsesShown, Boolean.valueOf(showStats));
}
data.setSessionResultsHtmlTableAsString("");
data.setAjaxStatus("");
String groupByTeam = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYTEAM);
String sortType = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE);
String startIndex = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_MAIN_INDEX);
if (startIndex != null) {
data.setStartIndex(Integer.parseInt(startIndex));
}
if (sortType == null) {
// default view: sort by question, statistics shown, grouped by team.
showStats = "on";
groupByTeam = "on";
sortType = Const.FeedbackSessionResults.QUESTION_SORT_TYPE;
isMissingResponsesShown = true;
}
String questionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
String isTestingAjax = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_NEED_AJAX);
if (ALL_SECTION_OPTION.equals(selectedSection) && questionId == null && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
// bundle for all questions and all sections
data.setBundle(logic.getFeedbackSessionResultsForInstructorWithinRangeFromView(feedbackSessionName, courseId, instructor.email, DEFAULT_SECTION_QUERY_RANGE, sortType));
} else if (Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
data.setBundle(getBundleForQuestionView(isTestingAjax, courseId, feedbackSessionName, instructor, data, selectedSection, sortType, questionId));
} else if (Const.FeedbackSessionResults.GQR_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.GRQ_SORT_TYPE.equals(sortType)) {
data.setBundle(logic.getFeedbackSessionResultsForInstructorFromSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
} else if (Const.FeedbackSessionResults.RQG_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.RGQ_SORT_TYPE.equals(sortType)) {
data.setBundle(logic.getFeedbackSessionResultsForInstructorToSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
}
if (data.getBundle() == null) {
throw new EntityDoesNotExistException("Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".");
}
// Warning for section wise viewing in case of many responses.
boolean isShowSectionWarningForQuestionView = data.isLargeNumberOfRespondents() && Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
boolean isShowSectionWarningForParticipantView = !data.getBundle().isComplete && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
// Warning for section wise does not make sense if there are no multiple sections.
boolean isMultipleSectionAvailable = data.getBundle().getRosterSectionTeamNameTable().size() > 1;
if (selectedSection.equals(ALL_SECTION_OPTION) && (isShowSectionWarningForParticipantView || isShowSectionWarningForQuestionView)) {
if (isMultipleSectionAvailable) {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_SECTIONVIEWWARNING, StatusMessageColor.WARNING));
} else {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_QUESTIONVIEWWARNING, StatusMessageColor.WARNING));
}
isError = true;
}
switch(sortType) {
case Const.FeedbackSessionResults.QUESTION_SORT_TYPE:
data.initForViewByQuestion(instructor, selectedSection, showStats, groupByTeam, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, data);
case Const.FeedbackSessionResults.RGQ_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
case Const.FeedbackSessionResults.GRQ_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_RECIPIENT_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, data);
case Const.FeedbackSessionResults.RQG_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_QUESTION_GIVER, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_QUESTION_GIVER, data);
case Const.FeedbackSessionResults.GQR_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_QUESTION_RECIPIENT, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_QUESTION_RECIPIENT, data);
default:
sortType = Const.FeedbackSessionResults.RGQ_SORT_TYPE;
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
}
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorFeedbackPreviewAsInstructorAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String previewInstructorEmail = getRequestParamValue(Const.ParamsNames.PREVIEWAS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
Assumption.assertPostParamNotNull(Const.ParamsNames.PREVIEWAS, previewInstructorEmail);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
InstructorAttributes previewInstructor = logic.getInstructorForEmail(courseId, previewInstructorEmail);
if (previewInstructor == null) {
throw new EntityDoesNotExistException("Instructor Email " + previewInstructorEmail + " does not exist in " + courseId + ".");
}
FeedbackSubmissionEditPageData data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
data.bundle = logic.getFeedbackSessionQuestionsBundleForInstructor(feedbackSessionName, courseId, previewInstructor.email);
data.setSessionOpenForSubmission(true);
data.setPreview(true);
data.setHeaderHidden(true);
data.setPreviewInstructor(previewInstructor);
data.setSubmitAction(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT_SAVE);
data.bundle.resetAllResponses();
statusToAdmin = "Preview feedback session as instructor (" + previewInstructor.email + ")<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
data.init("", "", courseId);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, data);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class InstructorCourseRemindAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
CourseAttributes course = logic.getCourse(courseId);
if (course == null) {
throw new EntityDoesNotExistException("Course with ID " + courseId + " does not exist!");
}
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
boolean isSendingToStudent = studentEmail != null;
boolean isSendingToInstructor = instructorEmail != null;
if (isSendingToStudent) {
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
} else if (isSendingToInstructor) {
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
} else {
// this is sending registration emails to all students in the course and we will check if the instructor
// canmodifystudent for course level since for modifystudent privilege there is only course level setting for now
gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
}
/* Process sending emails and setup status to be shown to user and admin */
Map<String, JoinEmailData> emailDataMap = new TreeMap<>();
String redirectUrl = "";
if (isSendingToStudent) {
taskQueuer.scheduleCourseRegistrationInviteToStudent(courseId, studentEmail, false);
StudentAttributes studentData = logic.getStudentForEmail(courseId, studentEmail);
if (studentData == null) {
throw new EntityDoesNotExistException("Student with email " + studentEmail + " does not exist " + "in course " + courseId + "!");
}
emailDataMap.put(studentEmail, new JoinEmailData(studentData.getName(), extractStudentRegistrationKey(studentData)));
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + studentEmail, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
} else if (isSendingToInstructor) {
taskQueuer.scheduleCourseRegistrationInviteToInstructor(loggedInUser.googleId, instructorEmail, courseId);
InstructorAttributes instructorData = logic.getInstructorForEmail(courseId, instructorEmail);
if (instructorData == null) {
throw new EntityDoesNotExistException("Instructor with email " + instructorEmail + " does not exist " + "in course " + courseId + "!");
}
emailDataMap.put(instructorEmail, new JoinEmailData(instructorData.getName(), StringHelper.encrypt(instructorData.key)));
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDER_SENT_TO + instructorEmail, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE;
} else {
List<StudentAttributes> studentDataList = logic.getUnregisteredStudentsForCourse(courseId);
for (StudentAttributes student : studentDataList) {
taskQueuer.scheduleCourseRegistrationInviteToStudent(course.getId(), student.getEmail(), false);
emailDataMap.put(student.getEmail(), new JoinEmailData(student.getName(), extractStudentRegistrationKey(student)));
}
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_REMINDERS_SENT, StatusMessageColor.SUCCESS));
redirectUrl = Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE;
}
statusToAdmin = generateStatusToAdmin(emailDataMap, courseId);
/* Create redirection with URL based on type of sending email */
RedirectResult response = createRedirectResult(redirectUrl);
response.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return response;
}
Aggregations