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"));
}
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);
}
Aggregations