use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.
the class FloatedCourseEditController method removeStudent.
@PostMapping("/{course}/unregister")
public String removeStudent(RedirectAttributes attributes, @PathVariable Course course, @RequestParam Student student) {
// TODO: Extract to shared package
ErrorUtils.requireNonNullCourse(course);
ErrorUtils.requireNonNullStudent(student);
FloatedCourse floatedCourse = floatedCourseService.getFloatedCourse(course).orElseThrow(FloatedCourseNotFoundException::new);
courseRegistrationService.removeRegistration(floatedCourse, student);
attributes.addFlashAttribute("flash_messages", Flash.success("Student removed from course"));
return "redirect:/admin/dean/floated/{course}";
}
use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.
the class CoursesController method getCourses.
@GetMapping
public String getCourses(Model model, @PathVariable Department department, @RequestParam(value = "all", required = false) Boolean all) {
ErrorUtils.requireNonNullDepartment(department);
// Determine if only active courses have to be should
boolean active = !(all != null && all);
model.addAttribute("page_description", "View and manage courses for the Department");
model.addAttribute("department", department);
model.addAttribute("page_title", "Courses : " + department.getName() + " Department");
model.addAttribute("page_subtitle", "Course Management");
model.addAttribute("page_path", getPath(department));
model.addAttribute("all", !active);
List<FloatedCourse> floatedCourses = floatedCourseService.getCurrentFloatedCourses(department);
List<Course> courses = courseService.getAllActiveCourse(department, active);
// Add meta tag and no of registrations to each course
for (FloatedCourse floatedCourse : floatedCourses) {
Stream.of(floatedCourse).map(FloatedCourse::getCourse).map(courses::indexOf).filter(index -> index != -1).map(courses::get).findFirst().ifPresent(course -> {
course.setMeta("Floated");
course.setRegistrations(floatedCourse.getCourseRegistrations().size());
});
}
courses.sort(Comparator.comparing(Course::getCode));
model.addAttribute("courses", courses);
return "department/courses";
}
use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.
the class FloatedCourseController method unfloat.
@PostMapping("/unfloat")
public String unfloat(RedirectAttributes redirectAttributes, @PathVariable Course course) {
FloatedCourse floatedCourse = floatedCourseService.getFloatedCourse(course).orElseThrow(FloatedCourseNotFoundException::new);
floatedCourseService.unfloatCourse(floatedCourse);
redirectAttributes.addFlashAttribute("course_success", "Course " + course.getCode() + " unfloated successfully!");
redirectAttributes.addAttribute("department", course.getDepartment());
return "redirect:/admin/department/{department}/courses?active=true";
}
use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.
the class InChargeManagementController method changeInCharge.
@PostMapping("/in_charge")
public String changeInCharge(RedirectAttributes redirectAttributes, @PathVariable Course course, @RequestParam(required = false) List<FacultyMember> facultyId, @RequestParam(required = false) List<String> section) {
FloatedCourse floatedCourse = floatedCourseService.getFloatedCourse(course).orElseThrow(FloatedCourseNotFoundException::new);
inChargeManagementService.saveInCharge(floatedCourse, facultyId, section);
redirectAttributes.addFlashAttribute("incharge_success", "Course In-Charge saved successfully");
return "redirect:/admin/department/floated/{course}";
}
use of amu.zhcet.data.course.floated.FloatedCourse 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