use of teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
String instructorId = instructor1OfCourse1.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Invalid parameters");
// no parameters
verifyAssumptionFailure();
// null student email
String[] invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
verifyAssumptionFailure(invalidParams);
// null course id
invalidParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email };
verifyAssumptionFailure(invalidParams);
______TS("Typical case, edit student detail page");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId, Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.email };
InstructorCourseStudentDetailsEditPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
InstructorCourseStudentDetailsEditPageData pageData = (InstructorCourseStudentDetailsEditPageData) r.data;
assertEquals(instructorId, pageData.account.googleId);
assertEquals(student1InCourse1.name, pageData.getStudentInfoTable().getName());
assertEquals(student1InCourse1.email, pageData.getStudentInfoTable().getEmail());
assertEquals(student1InCourse1.section, pageData.getStudentInfoTable().getSection());
assertEquals(student1InCourse1.team, pageData.getStudentInfoTable().getTeam());
assertEquals(student1InCourse1.comments, pageData.getStudentInfoTable().getComments());
assertEquals(student1InCourse1.course, pageData.getStudentInfoTable().getCourse());
String expectedLogMessage = "TEAMMATESLOG|||instructorCourseStudentDetailsEdit|||instructorCourseStudentDetailsEdit" + "|||true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1" + "|||instr1@course1.tmt|||instructorCourseStudentEdit Page Load<br>Editing Student " + "<span class=\"bold\">student1InCourse1@gmail.tmt's</span> details in Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + "|||/page/instructorCourseStudentDetailsEdit";
AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
use of teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageDataTest method allTests.
@Test
public void allTests() {
InstructorCourseStudentDetailsEditPageData data = createData();
______TS("With no student profile (Details edit shows only the info table)");
assertNull(data.getStudentProfile());
StudentInfoTable studentInfoTable = data.getStudentInfoTable();
assertNotNull(studentInfoTable);
assertEquals(inputStudent.name, studentInfoTable.getName());
assertEquals(inputStudent.email, studentInfoTable.getEmail());
assertEquals(inputStudent.section, studentInfoTable.getSection());
assertEquals(inputStudent.team, studentInfoTable.getTeam());
assertEquals(inputStudent.comments, studentInfoTable.getComments());
assertEquals(inputStudent.course, studentInfoTable.getCourse());
assertEquals(hasSection, studentInfoTable.getHasSection());
}
use of teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageAction 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) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, StatusMessageColor.DANGER));
isError = true;
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
boolean hasSection = logic.hasIndicatedSections(courseId);
boolean isOpenOrPublishedEmailSentForTheCourse = logic.isOpenOrPublishedEmailSentForTheCourse(courseId);
InstructorCourseStudentDetailsEditPageData data = new InstructorCourseStudentDetailsEditPageData(account, sessionToken, student, student.email, hasSection, isOpenOrPublishedEmailSentForTheCourse);
statusToAdmin = "instructorCourseStudentEdit Page Load<br>" + "Editing Student <span class=\"bold\">" + studentEmail + "'s</span> details " + "in Course <span class=\"bold\">[" + courseId + "]</span>";
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, data);
}
use of teammates.ui.pagedata.InstructorCourseStudentDetailsEditPageData 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