use of amu.zhcet.data.course.Course 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.Course in project zhcet-web by zhcet-amu.
the class CourseCreationController method addCourse.
@GetMapping
public String addCourse(Model model, @PathVariable Department department) {
ErrorUtils.requireNonNullDepartment(department);
model.addAttribute("page_description", "Create new global course for the Department");
model.addAttribute("department", department);
model.addAttribute("page_title", "Add Course : " + department.getName() + " Department");
model.addAttribute("page_subtitle", "Course Management");
model.addAttribute("page_path", getPath(department));
model.addAttribute("course_types", CourseType.values());
if (!model.containsAttribute("course")) {
Course course = new Course();
course.setDepartment(department);
model.addAttribute("course", course);
}
return "department/add_course";
}
use of amu.zhcet.data.course.Course in project zhcet-web by zhcet-amu.
the class FloatCourseController method floatCourses.
@PostMapping
public String floatCourses(RedirectAttributes redirectAttributes, @PathVariable Department department, @RequestParam("code") List<Course> courseList) {
ErrorUtils.requireNonNullDepartment(department);
for (Course course : courseList) floatedCourseService.floatCourse(course);
redirectAttributes.addFlashAttribute("float_success", "Courses floated successfully!");
if (courseList.size() == 1)
return String.format("redirect:/admin/department/floated/%s", courseList.get(0).getCode());
return "redirect:/admin/department/{department}/float";
}
Aggregations