use of teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentRecordsAjaxPageActionTest method testAccessControl.
@Test
@Override
protected void testAccessControl() throws Exception {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
StudentAttributes student = typicalBundle.students.get("student2InCourse1");
CourseAttributes course = typicalBundle.courses.get("typicalCourse1");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.STUDENT_EMAIL, student.email, Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session" };
verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
______TS("Instructor cannot view sections without View-Student-In-Sections privilege");
instructor = typicalBundle.instructors.get("helperOfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.STUDENT_EMAIL, student.email, Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session" };
InstructorStudentRecordsAjaxPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
a = getAction(submissionParams);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, false, "idOfHelperOfCourse1"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
InstructorStudentRecordsAjaxPageData data = (InstructorStudentRecordsAjaxPageData) r.data;
assertEquals(0, data.getResultsTables().size());
}
use of teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentRecordsAjaxPageAction 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);
String targetSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, targetSessionName);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
if (student == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, StatusMessageColor.DANGER));
isError = true;
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsListForInstructor(account.googleId, false);
filterFeedbackSessions(courseId, feedbacks, instructor, student);
List<SessionAttributes> sessions = new ArrayList<>();
sessions.addAll(feedbacks);
sessions.sort(SessionAttributes.DESCENDING_ORDER);
List<FeedbackSessionResultsBundle> results = new ArrayList<>();
for (SessionAttributes session : sessions) {
if (session instanceof FeedbackSessionAttributes) {
if (!targetSessionName.isEmpty() && targetSessionName.equals(session.getSessionName())) {
FeedbackSessionResultsBundle result = logic.getFeedbackSessionResultsForInstructor(session.getSessionName(), courseId, instructor.email);
results.add(result);
}
} else {
Assumption.fail("Unknown session type");
}
}
statusToAdmin = "instructorStudentRecords Ajax Page Load<br>" + "Viewing <span class=\"bold\">" + studentEmail + "'s</span> records " + "for session <span class=\"bold\">[" + targetSessionName + "]</span> " + "in course <span class=\"bold\">[" + courseId + "]</span>";
InstructorStudentRecordsAjaxPageData data = new InstructorStudentRecordsAjaxPageData(account, student, sessionToken, results);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, data);
}
use of teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentRecordsAjaxPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
StudentAttributes student = typicalBundle.students.get("student2InCourse1");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Typical case: specific session name");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email, Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session" };
InstructorStudentRecordsAjaxPageAction a = getAction(submissionParams);
ShowPageResult r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, false, "idOfInstructor3"), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals("", r.getStatusMessage());
InstructorStudentRecordsAjaxPageData data = (InstructorStudentRecordsAjaxPageData) r.data;
assertEquals(1, data.getResultsTables().size());
}
Aggregations