use of amu.zhcet.data.user.faculty.FacultyMemberNotFoundException in project zhcet-web by zhcet-amu.
the class FacultyCourseController method facultyCourses.
@GetMapping
public String facultyCourses(Model model) {
model.addAttribute("page_title", "Course Management");
model.addAttribute("page_subtitle", "Faculty Floated Course Management");
model.addAttribute("page_description", "Manage and upload attendance for currently floated courses");
FacultyMember facultyMember = facultyService.getLoggedInMember().orElseThrow(FacultyMemberNotFoundException::new);
List<CourseInCharge> courseInCharges = courseInChargeService.getCourseByFaculty(facultyMember);
// Set the no of registrations for each course
for (CourseInCharge courseInCharge : courseInCharges) {
FloatedCourse floatedCourse = courseInCharge.getFloatedCourse();
floatedCourse.getCourse().setRegistrations(floatedCourse.getCourseRegistrations().size());
}
// Sort courses by semester
courseInCharges.sort(Comparator.comparing(o -> {
Integer compared = o.getFloatedCourse().getCourse().getSemester();
return compared != null ? compared : 0;
}));
model.addAttribute("courseInCharges", courseInCharges);
return "faculty/courses";
}
Aggregations