Search in sources :

Example 1 with InstructorFeedbackEditCopyPageData

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

the class InstructorFeedbackEditCopyPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor2");
    String instructorId = instructor.googleId;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Successful case");
    String[] submissionParams = { Const.ParamsNames.COURSE_ID, "valid course id", Const.ParamsNames.FEEDBACK_SESSION_NAME, "valid fs name" };
    InstructorFeedbackEditCopyPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertFalse(r.isError);
    InstructorFeedbackEditCopyPageData pageData = (InstructorFeedbackEditCopyPageData) r.data;
    assertEquals(4, pageData.getCourses().size());
    List<String> idOfCourses = new ArrayList<>();
    for (CourseAttributes course : pageData.getCourses()) {
        idOfCourses.add(course.getId());
    }
    // course is archived
    assertFalse(idOfCourses.contains("FeedbackEditCopy.CS1101"));
    // instructor does not have sufficient permissions
    assertFalse(idOfCourses.contains("FeedbackEditCopy.CS2107"));
    assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2102"));
    assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103"));
    assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2103R"));
    assertTrue(idOfCourses.contains("FeedbackEditCopy.CS2104"));
}
Also used : InstructorFeedbackEditCopyPageData(teammates.ui.pagedata.InstructorFeedbackEditCopyPageData) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorFeedbackEditCopyPageAction(teammates.ui.controller.InstructorFeedbackEditCopyPageAction) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 2 with InstructorFeedbackEditCopyPageData

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

the class InstructorFeedbackEditCopyPageAction method execute.

@Override
protected ActionResult execute() {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    List<InstructorAttributes> instructors = logic.getInstructorsForGoogleId(account.googleId);
    Assumption.assertNotNull(instructors);
    List<CourseAttributes> allCourses = logic.getCoursesForInstructor(account.googleId);
    List<CourseAttributes> coursesToAddToData = new ArrayList<>();
    // Only add courses to data if the course is not archived and instructor has sufficient permissions
    for (CourseAttributes course : allCourses) {
        InstructorAttributes instructor = logic.getInstructorForGoogleId(course.getId(), account.googleId);
        boolean isAllowedToMakeSession = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
        if (!instructor.isArchived && isAllowedToMakeSession) {
            coursesToAddToData.add(course);
        }
    }
    CourseAttributes.sortByCreatedDate(coursesToAddToData);
    InstructorFeedbackEditCopyPageData data = new InstructorFeedbackEditCopyPageData(account, sessionToken, coursesToAddToData, courseId, feedbackSessionName);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_COPY_MODAL, data);
}
Also used : InstructorFeedbackEditCopyPageData(teammates.ui.pagedata.InstructorFeedbackEditCopyPageData) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

ArrayList (java.util.ArrayList)2 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 InstructorFeedbackEditCopyPageData (teammates.ui.pagedata.InstructorFeedbackEditCopyPageData)2 Test (org.testng.annotations.Test)1 InstructorFeedbackEditCopyPageAction (teammates.ui.controller.InstructorFeedbackEditCopyPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1