Search in sources :

Example 1 with FeedbackSessionsCopyFromModal

use of teammates.ui.template.FeedbackSessionsCopyFromModal 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 2 with FeedbackSessionsCopyFromModal

use of teammates.ui.template.FeedbackSessionsCopyFromModal 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)

Example 3 with FeedbackSessionsCopyFromModal

use of teammates.ui.template.FeedbackSessionsCopyFromModal in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageDataTest method testInit.

@Test
public void testInit() {
    AccountAttributes instructorAccount = dataBundle.accounts.get("instructor1OfCourse1");
    ______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.init(courses, null, fsList, courseInstructorMap, fsa, null, null);
    ______TS("typical success case with existing fs passed in: 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("Fri, 30 Apr, 2027", formModel.getFsEndDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsEndTimeOptions().size());
    assertEquals("First feedback session", formModel.getFsName());
    assertEquals("Sun, 01 Apr, 2012", formModel.getFsStartDate());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getFsStartTimeOptions().size());
    assertEquals(7, formModel.getGracePeriodOptions().size());
    int expectedDefaultGracePeriodOptionsIndex = 2;
    assertNull(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().get("selected"));
    assertTrue(formModel.getGracePeriodOptions().get(expectedDefaultGracePeriodOptionsIndex).getAttributes().containsKey("selected"));
    assertEquals("Please please fill in the following questions.", formModel.getInstructions());
    assertEquals("Sat, 01 May, 2027", formModel.getAdditionalSettings().getResponseVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getResponseVisibleTimeOptions().size());
    assertEquals("Wed, 28 Mar, 2012", formModel.getAdditionalSettings().getSessionVisibleDateValue());
    assertEquals(NUMBER_OF_HOURS_IN_DAY, formModel.getAdditionalSettings().getSessionVisibleTimeOptions().size());
    assertFalse(formModel.getAdditionalSettings().isResponseVisiblePublishManuallyChecked());
    assertTrue(formModel.getAdditionalSettings().isResponseVisibleDateChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleImmediatelyChecked());
    assertFalse(formModel.getAdditionalSettings().isResponseVisibleDateDisabled());
    assertFalse(formModel.getAdditionalSettings().isSessionVisibleAtOpenChecked());
    assertFalse(formModel.getAdditionalSettings().isSessionVisibleDateDisabled());
    assertTrue(formModel.getAdditionalSettings().isSessionVisibleDateButtonChecked());
    assertFalse(formModel.getAdditionalSettings().isSessionVisiblePrivateChecked());
    ______TS("typical success case with existing fs passed in: 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 with existing fs passed in: copy modal");
    FeedbackSessionsCopyFromModal copyModalModel = data.getCopyFromModal();
    assertEquals(1, copyModalModel.getCoursesSelectField().size());
    assertEquals("First feedback session", copyModalModel.getFsName());
    assertEquals(6, copyModalModel.getExistingFeedbackSessions().size());
}
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)

Example 4 with FeedbackSessionsCopyFromModal

use of teammates.ui.template.FeedbackSessionsCopyFromModal in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageData method buildCopyFromModal.

private void buildCopyFromModal(List<CourseAttributes> courses, String courseIdForNewSession, List<FeedbackSessionAttributes> existingFeedbackSessions, Map<String, InstructorAttributes> instructors, FeedbackSessionAttributes newFeedbackSession, String feedbackSessionNameForSessionList) {
    List<FeedbackSessionAttributes> filteredFeedbackSessions = new ArrayList<>();
    for (FeedbackSessionAttributes existingFeedbackSession : existingFeedbackSessions) {
        if (instructors.get(existingFeedbackSession.getCourseId()).isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION)) {
            filteredFeedbackSessions.add(existingFeedbackSession);
        }
    }
    List<FeedbackSessionsTableRow> filteredFeedbackSessionsRow = convertFeedbackSessionAttributesToSessionRows(filteredFeedbackSessions, instructors, feedbackSessionNameForSessionList, courseIdForNewSession);
    String fsName = newFeedbackSession == null ? "" : newFeedbackSession.getFeedbackSessionName();
    List<ElementTag> courseIdOptions = getCourseIdOptions(courses, courseIdForNewSession, instructors, newFeedbackSession);
    addPlaceholderIfEmpty(courseIdOptions, determinePlaceholderMessage(!courses.isEmpty()));
    copyFromModal = new FeedbackSessionsCopyFromModal(filteredFeedbackSessionsRow, fsName, courseIdOptions);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) FeedbackSessionsTableRow(teammates.ui.template.FeedbackSessionsTableRow) ElementTag(teammates.ui.template.ElementTag) FeedbackSessionsCopyFromModal(teammates.ui.template.FeedbackSessionsCopyFromModal)

Aggregations

ArrayList (java.util.ArrayList)4 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)4 FeedbackSessionsCopyFromModal (teammates.ui.template.FeedbackSessionsCopyFromModal)4 HashMap (java.util.HashMap)3 Test (org.testng.annotations.Test)3 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)3 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)3 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)3 FeedbackSessionsForm (teammates.ui.template.FeedbackSessionsForm)3 FeedbackSessionsTableRow (teammates.ui.template.FeedbackSessionsTableRow)3 FeedbackSessionsTable (teammates.ui.template.FeedbackSessionsTable)2 ElementTag (teammates.ui.template.ElementTag)1