use of teammates.ui.pagedata.InstructorFeedbackEditPageData in project teammates by TEAMMATES.
the class InstructorFeedbackEditSaveAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(account, sessionToken);
// This is only for validation to pass; it will be overridden with its existing value at the logic layer
String dummyCreatorEmail = "dummy@example.com";
FeedbackSessionAttributes feedbackSession = extractFeedbackSessionData(feedbackSessionName, courseId, dummyCreatorEmail);
try {
validateTimeData(feedbackSession);
addResolvedTimeFieldsToDataIfRequired(feedbackSession, data);
logic.updateFeedbackSession(feedbackSession);
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS));
statusToAdmin = "Updated Feedback Session " + "<span class=\"bold\">(" + feedbackSession.getFeedbackSessionName() + ")</span> for Course " + "<span class=\"bold\">[" + feedbackSession.getCourseId() + "]</span> created.<br>" + "<span class=\"bold\">From:</span> " + feedbackSession.getStartTime() + "<span class=\"bold\"> to</span> " + feedbackSession.getEndTime() + "<br><span class=\"bold\">Session visible from:</span> " + feedbackSession.getSessionVisibleFromTime() + "<br><span class=\"bold\">Results visible from:</span> " + feedbackSession.getResultsVisibleFromTime() + "<br><br><span class=\"bold\">Instructions:</span> " + feedbackSession.getInstructions();
data.setHasError(false);
} catch (InvalidParametersException e) {
setStatusForException(e);
data.setHasError(true);
}
data.setStatusMessagesToUser(statusToUser);
return createAjaxResult(data);
}
use of teammates.ui.pagedata.InstructorFeedbackEditPageData in project teammates by TEAMMATES.
the class InstructorFeedbackEditPageDataTest method allTests.
@Test
public void allTests() {
______TS("Typical case");
// Setup
InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("session1InCourse1");
List<FeedbackQuestionAttributes> questions = new ArrayList<>();
questions.add(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"));
questions.add(dataBundle.feedbackQuestions.get("qn2InSession1InCourse1"));
questions.add(dataBundle.feedbackQuestions.get("qn3InSession1InCourse1"));
Map<String, Boolean> questionHasResponses = new HashMap<>();
questionHasResponses.put(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getId(), true);
List<StudentAttributes> studentList = new ArrayList<>();
studentList.add(dataBundle.students.get("student1InCourse1"));
List<InstructorAttributes> instructorList = new ArrayList<>();
instructorList.add(dataBundle.instructors.get("instructor1OfCourse1"));
InstructorAttributes instructor = getInstructorFromBundle("instructor1OfCourse1");
CourseDetailsBundle courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
// Test fs form
FeedbackSessionsForm fsForm = data.getFsForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
assertEquals(fs.getCourseId(), fsForm.getCourseId());
assertNull(fsForm.getCourses());
assertNull(fsForm.getCoursesSelectField());
assertFalse(fsForm.isFeedbackSessionTypeEditable());
assertTrue(fsForm.isEditFsButtonsVisible());
assertNull(fsForm.getFeedbackSessionTypeOptions());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_SAVE).toString(), fsForm.getFormSubmitAction());
assertEquals(data.getInstructorFeedbackDeleteLink(fs.getCourseId(), fs.getFeedbackSessionName(), Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE), fsForm.getFsDeleteLink());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getEndTimeLocal()), fsForm.getFsEndDate());
assertEquals(fs.getFeedbackSessionName(), fsForm.getFsName());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getStartTimeLocal()), fsForm.getFsStartDate());
assertEquals(SanitizationHelper.sanitizeForHtml(fs.getInstructions().getValue()), fsForm.getInstructions());
assertEquals("Save Changes", fsForm.getSubmitButtonText());
assertFalse(fsForm.isCourseIdEditable());
assertFalse(fsForm.isShowNoCoursesMessage());
assertFalse(fsForm.isSubmitButtonVisible());
assertFalse(fsForm.isSubmitButtonDisabled());
FeedbackSessionsAdditionalSettingsFormSegment additionalSettings = data.getFsForm().getAdditionalSettings();
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
assertTrue(additionalSettings.isResponseVisibleDateChecked());
assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
assertFalse(additionalSettings.isResponseVisibleDateDisabled());
assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
assertFalse(additionalSettings.isSessionVisibleDateDisabled());
assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
assertTrue(additionalSettings.isSendClosingEmailChecked());
assertTrue(additionalSettings.isSendOpeningEmailChecked());
assertTrue(additionalSettings.isSendPublishedEmailChecked());
// test question edit forms
List<FeedbackQuestionEditForm> questionForms = data.getQnForms();
assertEquals(3, questionForms.size());
assertEquals(Const.ActionURIs.INSTRUCTOR_FEEDBACK_QUESTION_EDIT, questionForms.get(0).getAction());
assertEquals(fs.getCourseId(), questionForms.get(0).getCourseId());
assertEquals(fs.getFeedbackSessionName(), questionForms.get(0).getFeedbackSessionName());
String questionTextOfFirstQuestion = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getQuestionDetails().getQuestionText();
assertEquals(questionTextOfFirstQuestion, questionForms.get(0).getQuestionText());
assertEquals(3, questionForms.get(0).getQuestionNumberOptions().size());
assertEquals("What is the best selling point of your product?", questionForms.get(0).getQuestionText());
FeedbackQuestionFeedbackPathSettings feedbackPath = questionForms.get(0).getFeedbackPathSettings();
assertTrue(feedbackPath.isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, feedbackPath.getNumOfEntitiesToGiveFeedbackToValue());
assertEquals(1, questionForms.get(0).getQuestionIndex());
// Test visibility settings for the zero'th question form
FeedbackQuestionVisibilitySettings visibilitySettings = questionForms.get(0).getVisibilitySettings();
verifyMapContains(visibilitySettings.getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(visibilitySettings.getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(visibilitySettings.getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
assertEquals("Rate 1 other student's product", questionForms.get(1).getQuestionText());
assertTrue(questionForms.get(1).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(1).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
verifyMapContains(questionForms.get(1).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
verifyMapContains(questionForms.get(1).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
verifyMapContains(questionForms.get(1).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
assertEquals("My comments on the class", questionForms.get(2).getQuestionText());
assertEquals(3, questionForms.get(2).getQuestionIndex());
assertFalse(questionForms.get(2).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(2).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
verifyMapContains(questionForms.get(2).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
verifyMapContains(questionForms.get(2).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
verifyMapContains(questionForms.get(2).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
// TODO test specific question edit form html after it is no longer html in java
// test question add form
FeedbackQuestionEditForm newQuestionForm = data.getNewQnForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(-1, newQuestionForm.getQuestionIndex());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
// preview form
FeedbackSessionPreviewForm previewForm = data.getPreviewForm();
assertEquals(1, previewForm.getStudentToPreviewAsOptions().size());
assertEquals(1, previewForm.getInstructorToPreviewAsOptions().size());
______TS("empty feedback session");
// setup
data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
fs = dataBundle.feedbackSessions.get("empty.session");
fs.setPublishedEmailEnabled(false);
fs.setClosingEmailEnabled(false);
questions = new ArrayList<>();
questionHasResponses = new HashMap<>();
studentList = new ArrayList<>();
instructorList = new ArrayList<>();
instructor = getInstructorFromBundle("instructor1OfCourse1");
courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
fsForm = data.getFsForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
assertEquals(fs.getCourseId(), fsForm.getCourseId());
assertNull(fsForm.getCourses());
assertNull(fsForm.getCoursesSelectField());
assertFalse(fsForm.isFeedbackSessionTypeEditable());
assertTrue(fsForm.isEditFsButtonsVisible());
assertNull(fsForm.getFeedbackSessionTypeOptions());
additionalSettings = data.getFsForm().getAdditionalSettings();
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
assertTrue(additionalSettings.isResponseVisibleDateChecked());
assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
assertFalse(additionalSettings.isResponseVisibleDateDisabled());
assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
assertFalse(additionalSettings.isSessionVisibleDateDisabled());
assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
assertFalse(additionalSettings.isSendClosingEmailChecked());
assertTrue(additionalSettings.isSendOpeningEmailChecked());
assertFalse(additionalSettings.isSendPublishedEmailChecked());
questionForms = data.getQnForms();
assertEquals(questions.size(), questionForms.size());
previewForm = data.getPreviewForm();
assertEquals(studentList.size(), previewForm.getStudentToPreviewAsOptions().size());
assertEquals(instructorList.size(), previewForm.getInstructorToPreviewAsOptions().size());
newQuestionForm = data.getNewQnForm();
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
______TS("Resolved time fields map");
data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
assertNotNull("Should be empty map if unused", data.getResolvedTimeFields());
assertTrue(data.getResolvedTimeFields().isEmpty());
Map<String, String> expected = new HashMap<>();
String startDate = "start date";
String startTime = "start time";
expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
assertEquals(expected, data.getResolvedTimeFields());
}
use of teammates.ui.pagedata.InstructorFeedbackEditPageData in project teammates by TEAMMATES.
the class InstructorFeedbackEditSaveActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
String expectedString = "";
______TS("failure: Not enough parameters");
gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
verifyAssumptionFailure();
// TODO make sure IFESA does assertNotNull for required parameters then uncomment
// verifyAssumptionFailure(Const.ParamsNames.COURSE_ID, instructor1ofCourse1.courseId,
// Const.ParamsNames.FEEDBACK_SESSION_NAME, session.feedbackSessionName);
______TS("success: Typical case");
String[] params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
InstructorFeedbackEditSaveAction a = getAction(params);
AjaxResult ar = getAjaxResult(a);
InstructorFeedbackEditPageData pageData = (InstructorFeedbackEditPageData) ar.data;
StatusMessage statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
assertFalse(pageData.getHasError());
expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T16:00:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T16:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2011-12-31T16:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-06-22T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
______TS("failure: Fixed offset time zone");
params[25] = "UTC+08:00";
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
expectedString = "\"UTC+08:00\" is not acceptable to TEAMMATES as a/an time zone because it is not " + "available as a choice. The value must be one of the values from the time zone dropdown selector.";
statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, expectedString, StatusMessageColor.DANGER);
assertTrue(pageData.getHasError());
______TS("failure: Invalid parameters");
params[15] = "Thu, 01 Mar, 2012";
params[25] = "UTC";
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
expectedString = "The start time for this feedback session cannot be " + "earlier than the time when the session will be visible.";
statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, expectedString, StatusMessageColor.DANGER);
assertTrue(pageData.getHasError());
______TS("success: Time zone with DST, gap start time, overlap end time");
params[25] = "Europe/Andorra";
// After Sun, 25 Mar 2012, 01:59:59 AM: clocks sprang forward to Sun, 25 Mar 2012, 03:00:00 AM
params[5] = "Sun, 25 Mar, 2012";
params[7] = "2";
// After Sun, 28 Oct 2012, 02:59:59 AM: clocks fell back to Sun, 28 Oct 2012, 02:00:00 AM
params[9] = "Sun, 28 Oct, 2012";
params[11] = "2";
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
expectedString = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_GAP, "start time", "Sun, 25 Mar 2012, 02:00 AM", "Sun, 25 Mar 2012, 03:00 AM CEST (UTC+0200)");
verifyStatusMessage(pageData.getStatusMessagesToUser().get(0), expectedString, StatusMessageColor.WARNING);
expectedString = String.format(Const.StatusMessages.AMBIGUOUS_LOCAL_DATE_TIME_OVERLAP, "end time", "Sun, 28 Oct 2012, 02:00 AM", "Sun, 28 Oct 2012, 02:00 AM CEST (UTC+0200)", "Sun, 28 Oct 2012, 02:00 AM CET (UTC+0100)", "Sun, 28 Oct 2012, 02:00 AM CEST (UTC+0200)");
verifyStatusMessage(pageData.getStatusMessagesToUser().get(1), expectedString, StatusMessageColor.WARNING);
expectedString = Const.StatusMessages.FEEDBACK_SESSION_EDITED;
verifyStatusMessage(pageData.getStatusMessagesToUser().get(2), expectedString, StatusMessageColor.SUCCESS);
assertFalse(pageData.getHasError());
______TS("success: Custom time zone, 'never' show session, 'custom' show results");
params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
params[25] = "Asia/Kathmandu";
params[13] = Const.INSTRUCTOR_FEEDBACK_SESSION_VISIBLE_TIME_NEVER;
params[19] = Const.INSTRUCTOR_FEEDBACK_RESULTS_VISIBLE_TIME_LATER;
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
assertFalse(pageData.getHasError());
expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-01-31T18:15:00Z" + "<span class=\"bold\"> to</span> 2014-12-31T18:15:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 1970-11-27T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-01-01T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
______TS("success: At open session visible time, custom results visible time, UTC");
params = createParamsCombinationForFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName(), 1);
params[25] = "UTC";
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
assertFalse(pageData.getHasError());
expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-02-01T00:00:00Z" + "<span class=\"bold\"> to</span> 2015-01-01T00:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 1970-12-31T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 2014-05-08T02:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
AssertHelper.assertLogMessageEquals(expectedString, a.getLogMessage());
______TS("success: Masquerade mode, manual release results, UTC");
String adminUserId = "admin.user";
gaeSimulation.loginAsAdmin(adminUserId);
params = createParamsForTypicalFeedbackSession(instructor1ofCourse1.courseId, session.getFeedbackSessionName());
params[19] = Const.INSTRUCTOR_FEEDBACK_RESULTS_VISIBLE_TIME_LATER;
params[25] = "UTC";
params = addUserIdToParams(instructor1ofCourse1.googleId, params);
a = getAction(params);
ar = getAjaxResult(a);
pageData = (InstructorFeedbackEditPageData) ar.data;
statusMessage = pageData.getStatusMessagesToUser().get(0);
verifyStatusMessage(statusMessage, Const.StatusMessages.FEEDBACK_SESSION_EDITED, StatusMessageColor.SUCCESS);
assertFalse(pageData.getHasError());
expectedString = "TEAMMATESLOG|||instructorFeedbackEditSave|||instructorFeedbackEditSave|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Updated Feedback Session " + "<span class=\"bold\">(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> created.<br>" + "<span class=\"bold\">From:</span> 2012-02-01T00:00:00Z" + "<span class=\"bold\"> to</span> 2015-01-01T00:00:00Z<br>" + "<span class=\"bold\">Session visible from:</span> 2012-01-01T00:00:00Z<br>" + "<span class=\"bold\">Results visible from:</span> 1970-01-01T00:00:00Z<br><br>" + "<span class=\"bold\">Instructions:</span> " + "<Text: instructions>|||/page/instructorFeedbackEditSave";
AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedString, a.getLogMessage(), adminUserId);
______TS("failure: Invalid time zone");
params[27] = "invalid time zone";
verifyAssumptionFailure(params);
______TS("failure: Null time zone");
params = ArrayUtils.remove(params, 26);
params = ArrayUtils.remove(params, 26);
verifyAssumptionFailure(params);
______TS("failure: Invalid grace period");
params[25] = "12dsf";
verifyAssumptionFailure(params);
______TS("failure: Null grace period");
params = ArrayUtils.remove(params, 26);
params = ArrayUtils.remove(params, 26);
verifyAssumptionFailure(params);
}
use of teammates.ui.pagedata.InstructorFeedbackEditPageData 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);
}
Aggregations