use of teammates.common.datatransfer.attributes.SessionAttributes 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.common.datatransfer.attributes.SessionAttributes in project teammates by TEAMMATES.
the class SessionAttributesTest method testSort.
@Test
public void testSort() {
ArrayList<SessionAttributes> testList = new ArrayList<>();
ArrayList<SessionAttributes> expected = new ArrayList<>();
Instant time1 = TimeHelper.parseInstant("2014-01-01 12:00 AM +0000");
Instant time2 = TimeHelper.parseInstant("2014-02-01 12:00 AM +0000");
Instant time3 = TimeHelper.parseInstant("2014-03-01 12:00 AM +0000");
SessionAttributes s1 = new MiniFeedback(time1, time2, "Session 1");
SessionAttributes s2 = new MiniEval(time2, time3, "Session 2");
SessionAttributes s3 = new MiniFeedback(time1, time2, "Session 3");
SessionAttributes s4 = new MiniEval(time1, time3, "Session 4");
SessionAttributes s5 = new MiniFeedback(time2, time3, "Session 5");
testList.add(s1);
testList.add(s2);
testList.add(s3);
testList.add(s4);
testList.add(s5);
expected.add(s1);
expected.add(s3);
expected.add(s4);
expected.add(s2);
expected.add(s5);
testList.sort(SessionAttributes.ASCENDING_ORDER);
for (int i = 0; i < testList.size(); i++) {
assertEquals(expected.get(i), testList.get(i));
}
testList.clear();
testList.add(s1);
testList.add(s2);
testList.add(s3);
testList.add(s4);
testList.add(s5);
expected.clear();
expected.add(s2);
expected.add(s5);
expected.add(s4);
expected.add(s1);
expected.add(s3);
testList.sort(SessionAttributes.DESCENDING_ORDER);
for (int i = 0; i < testList.size(); i++) {
assertEquals(expected.get(i), testList.get(i));
}
}
Aggregations