Search in sources :

Example 1 with InstructorFeedbackSessionsPageData

use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    String instructorId = typicalBundle.instructors.get("instructor1OfCourse1").googleId;
    String adminUserId = "admin.user";
    String[] submissionParams = new String[] { Const.ParamsNames.IS_USING_AJAX, "true" };
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    ______TS("Typical case, 2 courses");
    if (CoursesLogic.inst().isCoursePresent("new-course")) {
        CoursesLogic.inst().deleteCourseCascade("new-course");
    }
    CoursesLogic.inst().createCourseAndInstructor(instructorId, "new-course", "New course", "UTC");
    gaeSimulation.loginAsInstructor(instructorId);
    InstructorFeedbackSessionsPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorFeedbackSessionsPageData pageData = (InstructorFeedbackSessionsPageData) r.data;
    assertEquals(instructorId, pageData.account.googleId);
    assertEquals(2, pageData.getNewFsForm().getCourses().size());
    assertEquals(6, pageData.getFsList().getExistingFeedbackSessions().size());
    assertEquals("", pageData.getNewFsForm().getFsName());
    assertNull(pageData.getNewFsForm().getCourseId());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackSessionsPage|||instructorFeedbackSessionsPage|||" + "true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Number of feedback sessions: 6|||/page/instructorFeedbackSessionsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("0 sessions");
    FeedbackSessionsLogic.inst().deleteFeedbackSessionsForCourseCascade(instructor1ofCourse1.courseId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1ofCourse1.courseId, Const.ParamsNames.IS_USING_AJAX, "true" };
    a = getAction(addUserIdToParams(instructorId, submissionParams));
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_EMPTY, r.getStatusMessage());
    assertFalse(r.isError);
    pageData = (InstructorFeedbackSessionsPageData) r.data;
    assertEquals(instructorId, pageData.account.googleId);
    assertEquals(2, pageData.getNewFsForm().getCourses().size());
    assertEquals(0, pageData.getFsList().getExistingFeedbackSessions().size());
    assertEquals("", pageData.getNewFsForm().getFsName());
    assertEquals(instructor1ofCourse1.courseId, pageData.getNewFsForm().getCourseId());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackSessionsPage|||instructorFeedbackSessionsPage|||" + "true|||Instructor|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Number of feedback sessions: 0|||/page/instructorFeedbackSessionsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Masquerade mode, 0 courses");
    gaeSimulation.loginAsAdmin(adminUserId);
    CoursesLogic.inst().deleteCourseCascade(instructor1ofCourse1.courseId);
    CoursesLogic.inst().deleteCourseCascade("new-course");
    submissionParams = new String[] { Const.ParamsNames.IS_USING_AJAX, "true" };
    a = getAction(addUserIdToParams(instructorId, submissionParams));
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals("You have not created any courses yet, or you have no active courses. " + "Go <a href=\"/page/instructorCoursesPage?user=idOfInstructor1OfCourse1\">here</a> " + "to create or unarchive a course.", r.getStatusMessage());
    assertFalse(r.isError);
    pageData = (InstructorFeedbackSessionsPageData) r.data;
    assertEquals(instructorId, pageData.account.googleId);
    assertEquals(0, pageData.getNewFsForm().getCourses().size());
    assertEquals(0, pageData.getFsList().getExistingFeedbackSessions().size());
    assertEquals("", pageData.getNewFsForm().getFsName());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackSessionsPage|||instructorFeedbackSessionsPage|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||idOfInstructor1OfCourse1|||" + "instr1@course1.tmt|||Number of feedback sessions: 0|||/page/instructorFeedbackSessionsPage";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, a.getLogMessage(), adminUserId);
}
Also used : InstructorFeedbackSessionsPageAction(teammates.ui.controller.InstructorFeedbackSessionsPageAction) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) Test(org.testng.annotations.Test)

Example 2 with InstructorFeedbackSessionsPageData

use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.

the class InstructorFeedbackAddAction method execute.

@Override
protected ActionResult execute() {
    String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertNotEmpty(courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    String feedbackSessionName = SanitizationHelper.sanitizeTitle(getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME));
    FeedbackSessionAttributes fs = extractFeedbackSessionData(feedbackSessionName, courseId, instructor.email);
    String feedbackSessionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_TYPE);
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(account, sessionToken);
    try {
        validateTimeData(fs);
        logic.createFeedbackSession(fs);
        try {
            createTemplateFeedbackQuestions(fs.getCourseId(), fs.getFeedbackSessionName(), fs.getCreatorEmail(), feedbackSessionType);
        } catch (InvalidParametersException e) {
            // Failed to create feedback questions for specified template/feedback session type.
            // TODO: let the user know an error has occurred? delete the feedback session?
            log.severe(TeammatesException.toStringWithStackTrace(e));
        }
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_ADDED, StatusMessageColor.SUCCESS));
        statusToAdmin = "New Feedback Session <span class=\"bold\">(" + fs.getFeedbackSessionName() + ")</span> for Course " + "<span class=\"bold\">[" + fs.getCourseId() + "]</span> created.<br>" + "<span class=\"bold\">From:</span> " + fs.getStartTime() + "<span class=\"bold\"> to</span> " + fs.getEndTime() + "<br>" + "<span class=\"bold\">Session visible from:</span> " + fs.getSessionVisibleFromTime() + "<br>" + "<span class=\"bold\">Results visible from:</span> " + fs.getResultsVisibleFromTime() + "<br><br>" + "<span class=\"bold\">Instructions:</span> " + fs.getInstructions();
        // (similar to the one below)
        return createRedirectResult(data.getInstructorFeedbackEditLink(fs.getCourseId(), fs.getFeedbackSessionName()));
    } catch (EntityAlreadyExistsException e) {
        setStatusForException(e, Const.StatusMessages.FEEDBACK_SESSION_EXISTS);
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
    // isError == true if an exception occurred above
    boolean shouldOmitArchived = true;
    Map<String, InstructorAttributes> instructors = loadCourseInstructorMap(shouldOmitArchived);
    List<InstructorAttributes> instructorList = new ArrayList<>(instructors.values());
    List<CourseAttributes> courses = loadCoursesList(instructorList);
    List<FeedbackSessionAttributes> feedbackSessions = loadFeedbackSessionsList(instructorList);
    FeedbackSessionAttributes.sortFeedbackSessionsByCreationTimeDescending(feedbackSessions);
    if (feedbackSessions.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_ADD_DB_INCONSISTENCY, StatusMessageColor.WARNING));
    }
    data.initWithoutHighlightedRow(courses, courseId, feedbackSessions, instructors, fs, feedbackSessionType);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, data);
}
Also used : EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) ArrayList(java.util.ArrayList) InvalidParametersException(teammates.common.exception.InvalidParametersException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 3 with InstructorFeedbackSessionsPageData

use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageAction method execute.

@Override
protected ActionResult execute() {
    // This can be null. Non-null value indicates the page is being loaded
    // to add a feedback to the specified course
    String courseIdForNewSession = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    String feedbackSessionToHighlight = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    String isUsingAjax = getRequestParamValue(Const.ParamsNames.IS_USING_AJAX);
    gateKeeper.verifyInstructorPrivileges(account);
    if (courseIdForNewSession != null) {
        gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseIdForNewSession, account.googleId), logic.getCourse(courseIdForNewSession), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
    }
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(account, sessionToken);
    data.setUsingAjax(isUsingAjax != null);
    // TODO: implement as a request parameter
    boolean shouldOmitArchived = true;
    // HashMap with courseId as key and InstructorAttributes as value
    Map<String, InstructorAttributes> instructors = loadCourseInstructorMap(shouldOmitArchived);
    List<InstructorAttributes> instructorList = new ArrayList<>(instructors.values());
    List<CourseAttributes> courses = loadCoursesList(instructorList);
    List<FeedbackSessionAttributes> existingFeedbackSessions;
    if (courses.isEmpty() || !data.isUsingAjax()) {
        existingFeedbackSessions = new ArrayList<>();
    } else {
        existingFeedbackSessions = loadFeedbackSessionsList(instructorList);
        if (existingFeedbackSessions.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_EMPTY, StatusMessageColor.WARNING));
        }
    }
    if (courses.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_EMPTY_IN_INSTRUCTOR_FEEDBACKS.replace("${user}", "?user=" + account.googleId), StatusMessageColor.WARNING));
    }
    statusToAdmin = "Number of feedback sessions: " + existingFeedbackSessions.size();
    data.initWithoutDefaultFormValues(courses, courseIdForNewSession, existingFeedbackSessions, instructors, feedbackSessionToHighlight);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SESSIONS, data);
}
Also used : ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 4 with InstructorFeedbackSessionsPageData

use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageDataTest method testInitWithoutHighlighting.

@Test
public void testInitWithoutHighlighting() {
    AccountAttributes instructorAccount = dataBundle.accounts.get("instructor2OfCourse1");
    ______TS("typical success case with existing fs passed in");
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
    Map<String, InstructorAttributes> courseInstructorMap = new HashMap<>();
    List<InstructorAttributes> instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        courseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForUser = new ArrayList<>(courseInstructorMap.values());
    List<CourseAttributes> courses = getCoursesForInstructor(instructorsForUser);
    List<FeedbackSessionAttributes> fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
    FeedbackSessionAttributes fsa = dataBundle.feedbackSessions.get("session1InCourse1");
    data.initWithoutHighlightedRow(courses, "idOfTypicalCourse1", fsList, courseInstructorMap, fsa, "STANDARD");
    FeedbackSessionsForm formModel = data.getNewFsForm();
    assertEquals("idOfTypicalCourse1", formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(2, formModel.getFeedbackSessionTypeOptions().size());
    assertEquals("session with my own questions", formModel.getFeedbackSessionTypeOptions().get(0).getContent());
    assertNull(formModel.getFeedbackSessionTypeOptions().get(0).getAttributes().get("selected"));
    assertTrue(formModel.getFeedbackSessionTypeOptions().get(0).getAttributes().containsKey("selected"));
    FeedbackSessionsCopyFromModal modal = data.getCopyFromModal();
    assertEquals("First feedback session", modal.getFsName());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeedbackSessionsForm(teammates.ui.template.FeedbackSessionsForm) FeedbackSessionsCopyFromModal(teammates.ui.template.FeedbackSessionsCopyFromModal) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 5 with InstructorFeedbackSessionsPageData

use of teammates.ui.pagedata.InstructorFeedbackSessionsPageData in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageDataTest method testInitWithoutDefaultFormValues.

@Test
public void testInitWithoutDefaultFormValues() {
    AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
    ______TS("typical success case");
    InstructorFeedbackSessionsPageData data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
    HashMap<String, InstructorAttributes> courseInstructorMap = new HashMap<>();
    List<InstructorAttributes> instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        courseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForUser = new ArrayList<>(courseInstructorMap.values());
    List<CourseAttributes> courses = getCoursesForInstructor(instructorsForUser);
    List<FeedbackSessionAttributes> fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
    data.initWithoutDefaultFormValues(courses, null, fsList, courseInstructorMap, null);
    ______TS("typical success case: test new fs form");
    // Test new fs form model
    FeedbackSessionsForm formModel = data.getNewFsForm();
    assertNull(formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(2, formModel.getFeedbackSessionTypeOptions().size());
    assertEquals("session using template: team peer evaluation", formModel.getFeedbackSessionTypeOptions().get(1).getContent());
    assertNull(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().get("selected"));
    assertTrue(formModel.getFeedbackSessionTypeOptions().get(1).getAttributes().containsKey("selected"));
    assertEquals("", formModel.getFsEndDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsEndTimeOptions().size());
    assertEquals("", formModel.getFsName());
    assertEquals("", formModel.getFsStartDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsStartTimeOptions().size());
    assertEquals("", formModel.getFsTimeZone());
    assertEquals(7, formModel.getGracePeriodOptions().size());
    int expectedDefaultGracePeriodOptionsIndex = 3;
    assertNull(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().get("selected"));
    assertTrue(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().containsKey("selected"));
    assertEquals("Please answer all the given questions.", formModel.getInstructions());
    assertEquals("", formModel.getAdditionalSettings().getResponseVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getResponseVisibleTimeOptions().size());
    assertEquals("", formModel.getAdditionalSettings().getSessionVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getSessionVisibleTimeOptions().size());
    assertTrue(formModel.getAdditionalSettings().isResponseVisiblePublishManuallyChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleDateChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleImmediatelyChecked());
    assertTrue(formModel.getAdditionalSettings().isResponseVisibleDateDisabled());
    assertTrue(formModel.getAdditionalSettings().isSessionVisibleAtOpenChecked());
    assertTrue(formModel.getAdditionalSettings().isSessionVisibleDateDisabled());
    assertFalse(formModel.getAdditionalSettings().isSessionVisibleDateButtonChecked());
    assertFalse(formModel.getAdditionalSettings().isSessionVisiblePrivateChecked());
    ______TS("typical success case: session rows");
    FeedbackSessionsTable fsTableModel = data.getFsList();
    List<FeedbackSessionsTableRow> fsRows = fsTableModel.getExistingFeedbackSessions();
    assertEquals(6, fsRows.size());
    String firstFsName = "Grace Period Session";
    assertEquals(firstFsName, fsRows.get(0).getName());
    String lastFsName = "First feedback session";
    assertEquals(lastFsName, fsRows.get(fsRows.size() - 1).getName());
    ______TS("typical success case: copy modal");
    FeedbackSessionsCopyFromModal copyModalModel = data.getCopyFromModal();
    assertEquals(1, copyModalModel.getCoursesSelectField().size());
    assertEquals("", copyModalModel.getFsName());
    assertEquals(6, copyModalModel.getExistingFeedbackSessions().size());
    ______TS("case with instructor with only archived course");
    AccountAttributes instructorOfArchivedCourseAccount = dataBundle.accounts.get("instructorOfArchivedCourse");
    InstructorFeedbackSessionsPageData instructorArchivedCourseData = new InstructorFeedbackSessionsPageData(instructorOfArchivedCourseAccount, dummySessionToken);
    Map<String, InstructorAttributes> archivedCourseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(instructorOfArchivedCourseAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        archivedCourseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForArchivedCourse = new ArrayList<>(archivedCourseInstructorMap.values());
    List<CourseAttributes> archivedCourses = getCoursesForInstructor(instructorsForArchivedCourse);
    List<FeedbackSessionAttributes> archivedFsList = getFeedbackSessionsListForInstructor(instructorsForArchivedCourse);
    instructorArchivedCourseData.initWithoutDefaultFormValues(archivedCourses, null, archivedFsList, archivedCourseInstructorMap, null);
    ______TS("case with instructor with only archived course: test new fs form");
    // Test new fs form model
    formModel = instructorArchivedCourseData.getNewFsForm();
    assertNull(formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(Const.StatusMessages.INSTRUCTOR_NO_ACTIVE_COURSES, formModel.getCoursesSelectField().get(0).getContent());
    assertTrue(formModel.isSubmitButtonDisabled());
    ______TS("case with instructor with restricted permissions");
    AccountAttributes helperAccount = dataBundle.accounts.get("helperOfCourse1");
    InstructorFeedbackSessionsPageData helperData = new InstructorFeedbackSessionsPageData(helperAccount, dummySessionToken);
    Map<String, InstructorAttributes> helperCourseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(helperAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        helperCourseInstructorMap.put(instructor.courseId, instructor);
    }
    List<InstructorAttributes> instructorsForHelper = new ArrayList<>(helperCourseInstructorMap.values());
    List<CourseAttributes> helperCourses = getCoursesForInstructor(instructorsForHelper);
    List<FeedbackSessionAttributes> helperFsList = getFeedbackSessionsListForInstructor(instructorsForHelper);
    helperData.initWithoutDefaultFormValues(helperCourses, null, helperFsList, helperCourseInstructorMap, null);
    ______TS("case with instructor with restricted permissions: test new fs form");
    // Test new fs form model
    formModel = helperData.getNewFsForm();
    assertNull(formModel.getCourseId());
    assertEquals(1, formModel.getCoursesSelectField().size());
    assertEquals(Const.StatusMessages.INSTRUCTOR_NO_MODIFY_PERMISSION_FOR_ACTIVE_COURSES_SESSIONS, formModel.getCoursesSelectField().get(0).getContent());
    assertTrue(formModel.isSubmitButtonDisabled());
    ______TS("case with instructor with restricted permissions: session rows");
    fsTableModel = helperData.getFsList();
    fsRows = fsTableModel.getExistingFeedbackSessions();
    assertEquals(6, fsRows.size());
    ______TS("case with instructor with restricted permissions: copy modal");
    copyModalModel = helperData.getCopyFromModal();
    assertEquals(1, copyModalModel.getCoursesSelectField().size());
    assertEquals("", copyModalModel.getFsName());
    assertEquals(0, copyModalModel.getExistingFeedbackSessions().size());
    ______TS("case with highlighted session in session table");
    instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
    data = new InstructorFeedbackSessionsPageData(instructorAccount, dummySessionToken);
    courseInstructorMap = new HashMap<>();
    instructors = getInstructorsForGoogleId(instructorAccount.googleId, true);
    for (InstructorAttributes instructor : instructors) {
        courseInstructorMap.put(instructor.courseId, instructor);
    }
    instructorsForUser = new ArrayList<>(courseInstructorMap.values());
    courses = getCoursesForInstructor(instructorsForUser);
    fsList = getFeedbackSessionsListForInstructor(instructorsForUser);
    data.initWithoutDefaultFormValues(courses, "idOfTypicalCourse1", fsList, courseInstructorMap, "First feedback session");
    List<FeedbackSessionsTableRow> sessionRows = data.getFsList().getExistingFeedbackSessions();
    boolean isFirstFeedbackSessionHighlighted = false;
    boolean isOtherFeedbackSessionHighlighted = false;
    for (FeedbackSessionsTableRow row : sessionRows) {
        if ("First feedback session".equals(row.getName())) {
            isFirstFeedbackSessionHighlighted = row.getRowAttributes().getAttributes().get("class").matches(".*\\bwarning\\b.*");
        } else {
            if (row.getRowAttributes().getAttributes().get("class").matches(".*\\bwarning\\b.*")) {
                isOtherFeedbackSessionHighlighted = true;
            }
        }
    }
    assertTrue(isFirstFeedbackSessionHighlighted);
    assertFalse(isOtherFeedbackSessionHighlighted);
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeedbackSessionsForm(teammates.ui.template.FeedbackSessionsForm) FeedbackSessionsCopyFromModal(teammates.ui.template.FeedbackSessionsCopyFromModal) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionsTableRow(teammates.ui.template.FeedbackSessionsTableRow) FeedbackSessionsTable(teammates.ui.template.FeedbackSessionsTable) InstructorFeedbackSessionsPageData(teammates.ui.pagedata.InstructorFeedbackSessionsPageData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)6 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)6 ArrayList (java.util.ArrayList)5 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)5 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)5 Test (org.testng.annotations.Test)4 HashMap (java.util.HashMap)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 FeedbackSessionsCopyFromModal (teammates.ui.template.FeedbackSessionsCopyFromModal)3 FeedbackSessionsForm (teammates.ui.template.FeedbackSessionsForm)3 StatusMessage (teammates.common.util.StatusMessage)2 FeedbackSessionsTable (teammates.ui.template.FeedbackSessionsTable)2 FeedbackSessionsTableRow (teammates.ui.template.FeedbackSessionsTableRow)2 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)1 InvalidParametersException (teammates.common.exception.InvalidParametersException)1 InstructorFeedbackSessionsPageAction (teammates.ui.controller.InstructorFeedbackSessionsPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1