Search in sources :

Example 76 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackEditPageDataTest method allTests.

@Test
public void allTests() {
    ______TS("Typical case");
    // Setup
    InstructorFeedbackEditPageData data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("session1InCourse1");
    List<FeedbackQuestionAttributes> questions = new ArrayList<>();
    questions.add(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"));
    questions.add(dataBundle.feedbackQuestions.get("qn2InSession1InCourse1"));
    questions.add(dataBundle.feedbackQuestions.get("qn3InSession1InCourse1"));
    Map<String, Boolean> questionHasResponses = new HashMap<>();
    questionHasResponses.put(dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getId(), true);
    List<StudentAttributes> studentList = new ArrayList<>();
    studentList.add(dataBundle.students.get("student1InCourse1"));
    List<InstructorAttributes> instructorList = new ArrayList<>();
    instructorList.add(dataBundle.instructors.get("instructor1OfCourse1"));
    InstructorAttributes instructor = getInstructorFromBundle("instructor1OfCourse1");
    CourseDetailsBundle courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
    data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
    // Test fs form
    FeedbackSessionsForm fsForm = data.getFsForm();
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
    assertEquals(fs.getCourseId(), fsForm.getCourseId());
    assertNull(fsForm.getCourses());
    assertNull(fsForm.getCoursesSelectField());
    assertFalse(fsForm.isFeedbackSessionTypeEditable());
    assertTrue(fsForm.isEditFsButtonsVisible());
    assertNull(fsForm.getFeedbackSessionTypeOptions());
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_SAVE).toString(), fsForm.getFormSubmitAction());
    assertEquals(data.getInstructorFeedbackDeleteLink(fs.getCourseId(), fs.getFeedbackSessionName(), Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE), fsForm.getFsDeleteLink());
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getEndTimeLocal()), fsForm.getFsEndDate());
    assertEquals(fs.getFeedbackSessionName(), fsForm.getFsName());
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getStartTimeLocal()), fsForm.getFsStartDate());
    assertEquals(SanitizationHelper.sanitizeForHtml(fs.getInstructions().getValue()), fsForm.getInstructions());
    assertEquals("Save Changes", fsForm.getSubmitButtonText());
    assertFalse(fsForm.isCourseIdEditable());
    assertFalse(fsForm.isShowNoCoursesMessage());
    assertFalse(fsForm.isSubmitButtonVisible());
    assertFalse(fsForm.isSubmitButtonDisabled());
    FeedbackSessionsAdditionalSettingsFormSegment additionalSettings = data.getFsForm().getAdditionalSettings();
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
    assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
    assertTrue(additionalSettings.isResponseVisibleDateChecked());
    assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
    assertFalse(additionalSettings.isResponseVisibleDateDisabled());
    assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
    assertFalse(additionalSettings.isSessionVisibleDateDisabled());
    assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
    assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
    assertTrue(additionalSettings.isSendClosingEmailChecked());
    assertTrue(additionalSettings.isSendOpeningEmailChecked());
    assertTrue(additionalSettings.isSendPublishedEmailChecked());
    // test question edit forms
    List<FeedbackQuestionEditForm> questionForms = data.getQnForms();
    assertEquals(3, questionForms.size());
    assertEquals(Const.ActionURIs.INSTRUCTOR_FEEDBACK_QUESTION_EDIT, questionForms.get(0).getAction());
    assertEquals(fs.getCourseId(), questionForms.get(0).getCourseId());
    assertEquals(fs.getFeedbackSessionName(), questionForms.get(0).getFeedbackSessionName());
    String questionTextOfFirstQuestion = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1").getQuestionDetails().getQuestionText();
    assertEquals(questionTextOfFirstQuestion, questionForms.get(0).getQuestionText());
    assertEquals(3, questionForms.get(0).getQuestionNumberOptions().size());
    assertEquals("What is the best selling point of your product?", questionForms.get(0).getQuestionText());
    FeedbackQuestionFeedbackPathSettings feedbackPath = questionForms.get(0).getFeedbackPathSettings();
    assertTrue(feedbackPath.isNumberOfEntitiesToGiveFeedbackToChecked());
    assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, feedbackPath.getNumOfEntitiesToGiveFeedbackToValue());
    assertEquals(1, questionForms.get(0).getQuestionIndex());
    // Test visibility settings for the zero'th question form
    FeedbackQuestionVisibilitySettings visibilitySettings = questionForms.get(0).getVisibilitySettings();
    verifyMapContains(visibilitySettings.getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
    verifyMapContains(visibilitySettings.getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
    verifyMapContains(visibilitySettings.getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
    assertEquals("Rate 1 other student's product", questionForms.get(1).getQuestionText());
    assertTrue(questionForms.get(1).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
    assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(1).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
    verifyMapContains(questionForms.get(1).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
    verifyMapContains(questionForms.get(1).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS));
    verifyMapContains(questionForms.get(1).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER));
    assertEquals("My comments on the class", questionForms.get(2).getQuestionText());
    assertEquals(3, questionForms.get(2).getQuestionIndex());
    assertFalse(questionForms.get(2).getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
    assertEquals(DEFAULT_NUM_ENTITIES_TO_GIVE_RESPONSES_TO, questionForms.get(2).getFeedbackPathSettings().getNumOfEntitiesToGiveFeedbackToValue());
    verifyMapContains(questionForms.get(2).getVisibilitySettings().getResponseVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
    verifyMapContains(questionForms.get(2).getVisibilitySettings().getGiverNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
    verifyMapContains(questionForms.get(2).getVisibilitySettings().getRecipientNameVisibleFor(), Arrays.asList(FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.OWN_TEAM_MEMBERS));
    // TODO test specific question edit form html after it is no longer html in java
    // test question add form
    FeedbackQuestionEditForm newQuestionForm = data.getNewQnForm();
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
    assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
    assertEquals(-1, newQuestionForm.getQuestionIndex());
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
    // preview form
    FeedbackSessionPreviewForm previewForm = data.getPreviewForm();
    assertEquals(1, previewForm.getStudentToPreviewAsOptions().size());
    assertEquals(1, previewForm.getInstructorToPreviewAsOptions().size());
    ______TS("empty feedback session");
    // setup
    data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
    fs = dataBundle.feedbackSessions.get("empty.session");
    fs.setPublishedEmailEnabled(false);
    fs.setClosingEmailEnabled(false);
    questions = new ArrayList<>();
    questionHasResponses = new HashMap<>();
    studentList = new ArrayList<>();
    instructorList = new ArrayList<>();
    instructor = getInstructorFromBundle("instructor1OfCourse1");
    courseDetails = new CourseDetailsBundle(dataBundle.courses.get("typicalCourse1"));
    data.init(fs, questions, questionHasResponses, studentList, instructorList, instructor, true, instructorList.size(), courseDetails);
    fsForm = data.getFsForm();
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE).withUserId(instructor.googleId).toString(), fsForm.getCopyToLink());
    assertEquals(fs.getCourseId(), fsForm.getCourseId());
    assertNull(fsForm.getCourses());
    assertNull(fsForm.getCoursesSelectField());
    assertFalse(fsForm.isFeedbackSessionTypeEditable());
    assertTrue(fsForm.isEditFsButtonsVisible());
    assertNull(fsForm.getFeedbackSessionTypeOptions());
    additionalSettings = data.getFsForm().getAdditionalSettings();
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getResultsVisibleFromTimeLocal()), additionalSettings.getResponseVisibleDateValue());
    assertEquals(TimeHelper.formatDateForSessionsForm(fs.getSessionVisibleFromTimeLocal()), additionalSettings.getSessionVisibleDateValue());
    assertFalse(additionalSettings.isResponseVisiblePublishManuallyChecked());
    assertTrue(additionalSettings.isResponseVisibleDateChecked());
    assertFalse(additionalSettings.isResponseVisibleImmediatelyChecked());
    assertFalse(additionalSettings.isResponseVisibleDateDisabled());
    assertFalse(additionalSettings.isSessionVisibleAtOpenChecked());
    assertFalse(additionalSettings.isSessionVisibleDateDisabled());
    assertTrue(additionalSettings.isSessionVisibleDateButtonChecked());
    assertFalse(additionalSettings.isSessionVisiblePrivateChecked());
    assertFalse(additionalSettings.isSendClosingEmailChecked());
    assertTrue(additionalSettings.isSendOpeningEmailChecked());
    assertFalse(additionalSettings.isSendPublishedEmailChecked());
    questionForms = data.getQnForms();
    assertEquals(questions.size(), questionForms.size());
    previewForm = data.getPreviewForm();
    assertEquals(studentList.size(), previewForm.getStudentToPreviewAsOptions().size());
    assertEquals(instructorList.size(), previewForm.getInstructorToPreviewAsOptions().size());
    newQuestionForm = data.getNewQnForm();
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
    assertFalse(newQuestionForm.getFeedbackPathSettings().isNumberOfEntitiesToGiveFeedbackToChecked());
    assertEquals(Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructor.googleId).withCourseId(fs.getCourseId()).withSessionName(fs.getFeedbackSessionName()).toString(), newQuestionForm.getDoneEditingLink());
    ______TS("Resolved time fields map");
    data = new InstructorFeedbackEditPageData(dataBundle.accounts.get("instructor1OfCourse1"), dummySessionToken);
    assertNotNull("Should be empty map if unused", data.getResolvedTimeFields());
    assertTrue(data.getResolvedTimeFields().isEmpty());
    Map<String, String> expected = new HashMap<>();
    String startDate = "start date";
    String startTime = "start time";
    expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
    expected.put(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
    data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE, startDate);
    data.putResolvedTimeField(Const.ParamsNames.FEEDBACK_SESSION_STARTTIME, startTime);
    assertEquals(expected, data.getResolvedTimeFields());
}
Also used : InstructorFeedbackEditPageData(teammates.ui.pagedata.InstructorFeedbackEditPageData) FeedbackQuestionVisibilitySettings(teammates.ui.template.FeedbackQuestionVisibilitySettings) HashMap(java.util.HashMap) FeedbackSessionPreviewForm(teammates.ui.template.FeedbackSessionPreviewForm) ArrayList(java.util.ArrayList) FeedbackSessionsForm(teammates.ui.template.FeedbackSessionsForm) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) FeedbackQuestionFeedbackPathSettings(teammates.ui.template.FeedbackQuestionFeedbackPathSettings) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackQuestionEditForm(teammates.ui.template.FeedbackQuestionEditForm) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackSessionsAdditionalSettingsFormSegment(teammates.ui.template.FeedbackSessionsAdditionalSettingsFormSegment) Test(org.testng.annotations.Test)

Example 77 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes 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 78 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes 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 79 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class AdminSessionsPageData method getFeedbackSessionRows.

public List<AdminFeedbackSessionRow> getFeedbackSessionRows(List<FeedbackSessionAttributes> feedbackSessions, Map<String, String> sessionToInstructorIdMap) {
    List<AdminFeedbackSessionRow> feedbackSessionRows = new ArrayList<>();
    for (FeedbackSessionAttributes feedbackSession : feedbackSessions) {
        String googleId = sessionToInstructorIdMap.get(feedbackSession.getIdentificationString());
        feedbackSessionRows.add(new AdminFeedbackSessionRow(getSessionStatusForShow(feedbackSession), getFeedbackSessionStatsLink(feedbackSession.getCourseId(), feedbackSession.getFeedbackSessionName(), googleId), TimeHelper.formatTime12H(feedbackSession.getStartTimeLocal()), feedbackSession.getStartTimeInIso8601UtcFormat(), TimeHelper.formatTime12H(feedbackSession.getEndTimeLocal()), feedbackSession.getEndTimeInIso8601UtcFormat(), getInstructorHomePageViewLink(googleId), feedbackSession.getCreatorEmail(), feedbackSession.getCourseId(), feedbackSession.getFeedbackSessionName()));
    }
    return feedbackSessionRows;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AdminFeedbackSessionRow(teammates.ui.template.AdminFeedbackSessionRow) ArrayList(java.util.ArrayList)

Example 80 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class StudentCourseJoinAuthenticatedAction method addStatusMessageToUser.

private void addStatusMessageToUser() throws EntityDoesNotExistException {
    CourseAttributes course = logic.getCourse(getStudent().course);
    String courseDisplayText = "[" + course.getId() + "] " + SanitizationHelper.sanitizeForHtml(course.getName());
    statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, courseDisplayText), StatusMessageColor.SUCCESS));
    List<FeedbackSessionAttributes> fsa = logic.getFeedbackSessionsForUserInCourse(getStudent().course, getStudent().email);
    if (fsa.isEmpty()) {
        statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, courseDisplayText), StatusMessageColor.INFO));
        StudentProfileAttributes spa = logic.getStudentProfile(account.googleId);
        String updateProfileMessage = spa.generateUpdateMessageForStudent();
        if (!updateProfileMessage.isEmpty()) {
            statusToUser.add(new StatusMessage(updateProfileMessage, StatusMessageColor.INFO));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) StatusMessage(teammates.common.util.StatusMessage)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9