Search in sources :

Example 1 with SessionAttributes

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorStudentRecordsAjaxPageData(teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData) SessionAttributes(teammates.common.datatransfer.attributes.SessionAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Example 2 with SessionAttributes

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));
    }
}
Also used : SessionAttributes(teammates.common.datatransfer.attributes.SessionAttributes) Instant(java.time.Instant) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

ArrayList (java.util.ArrayList)2 SessionAttributes (teammates.common.datatransfer.attributes.SessionAttributes)2 Instant (java.time.Instant)1 Test (org.testng.annotations.Test)1 FeedbackSessionResultsBundle (teammates.common.datatransfer.FeedbackSessionResultsBundle)1 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)1 StatusMessage (teammates.common.util.StatusMessage)1 InstructorStudentRecordsAjaxPageData (teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData)1