Search in sources :

Example 1 with Course

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";
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) PathChain(amu.zhcet.common.page.PathChain) Department(amu.zhcet.data.department.Department) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) CourseService(amu.zhcet.data.course.CourseService) Course(amu.zhcet.data.course.Course) ErrorUtils(amu.zhcet.core.error.ErrorUtils) Slf4j(lombok.extern.slf4j.Slf4j) Model(org.springframework.ui.Model) List(java.util.List) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) Stream(java.util.stream.Stream) Path(amu.zhcet.common.page.Path) GetMapping(org.springframework.web.bind.annotation.GetMapping) DepartmentController(amu.zhcet.core.admin.department.DepartmentController) Comparator(java.util.Comparator) FloatedCourseService(amu.zhcet.data.course.floated.FloatedCourseService) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) Course(amu.zhcet.data.course.Course) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with Course

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";
}
Also used : Course(amu.zhcet.data.course.Course) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with 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";
}
Also used : Course(amu.zhcet.data.course.Course)

Aggregations

Course (amu.zhcet.data.course.Course)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Path (amu.zhcet.common.page.Path)1 PathChain (amu.zhcet.common.page.PathChain)1 DepartmentController (amu.zhcet.core.admin.department.DepartmentController)1 ErrorUtils (amu.zhcet.core.error.ErrorUtils)1 CourseService (amu.zhcet.data.course.CourseService)1 FloatedCourse (amu.zhcet.data.course.floated.FloatedCourse)1 FloatedCourseService (amu.zhcet.data.course.floated.FloatedCourseService)1 Department (amu.zhcet.data.department.Department)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Controller (org.springframework.stereotype.Controller)1 Model (org.springframework.ui.Model)1 PathVariable (org.springframework.web.bind.annotation.PathVariable)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 RequestParam (org.springframework.web.bind.annotation.RequestParam)1