use of teammates.ui.datatransfer.InstructorStudentListPageCourseData in project teammates by TEAMMATES.
the class InstructorStudentListPageAction method execute.
@Override
public ActionResult execute() {
gateKeeper.verifyInstructorPrivileges(account);
String searchKey = getRequestParamValue(Const.ParamsNames.SEARCH_KEY);
Boolean displayArchive = getRequestParamAsBoolean(Const.ParamsNames.DISPLAY_ARCHIVE);
Map<String, InstructorAttributes> instructors = new HashMap<>();
List<CourseAttributes> courses = logic.getCoursesForInstructor(account.googleId);
// Sort by creation date
courses.sort(Comparator.comparing(course -> course.createdAt));
// Get instructor attributes
List<InstructorAttributes> instructorList = logic.getInstructorsForGoogleId(account.googleId);
for (InstructorAttributes instructor : instructorList) {
instructors.put(instructor.courseId, instructor);
}
if (courses.isEmpty()) {
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_NO_COURSE_AND_STUDENTS, StatusMessageColor.WARNING));
}
statusToAdmin = "instructorStudentList Page Load<br>" + "Total Courses: " + courses.size();
List<InstructorStudentListPageCourseData> coursesToDisplay = new ArrayList<>();
for (CourseAttributes course : courses) {
InstructorAttributes instructor = instructors.get(course.getId());
boolean isInstructorAllowedToModify = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
boolean isCourseDisplayed = displayArchive || !instructor.isArchived;
if (isCourseDisplayed) {
coursesToDisplay.add(new InstructorStudentListPageCourseData(course, instructor.isArchived, isInstructorAllowedToModify));
}
}
InstructorStudentListPageData data = new InstructorStudentListPageData(account, sessionToken, searchKey, displayArchive, coursesToDisplay);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, data);
}
use of teammates.ui.datatransfer.InstructorStudentListPageCourseData in project teammates by TEAMMATES.
the class InstructorStudentListPageDataTest method initializeDataWithSearchKey.
private InstructorStudentListPageData initializeDataWithSearchKey() {
acct = AccountAttributes.builder().withGoogleId(// only googleId is used
"valid.id").build();
searchKey = "<script>alert(\"A search key\");</script>";
shouldDisplayArchive = false;
// only course ID and name are used
sampleCourse = CourseAttributes.builder("validCourseId", "Sample course name", ZoneId.of("UTC")).build();
isCourseArchived = false;
isInstructorAllowedToModify = true;
coursesToDisplay = new ArrayList<>();
coursesToDisplay.add(new InstructorStudentListPageCourseData(sampleCourse, isCourseArchived, isInstructorAllowedToModify));
return new InstructorStudentListPageData(acct, dummySessionToken, searchKey, shouldDisplayArchive, coursesToDisplay);
}
Aggregations