Search in sources :

Example 1 with FloatedCourse

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}";
}
Also used : FloatedCourseNotFoundException(amu.zhcet.data.course.floated.FloatedCourseNotFoundException) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse)

Example 2 with FloatedCourse

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";
}
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 3 with FloatedCourse

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";
}
Also used : FloatedCourseNotFoundException(amu.zhcet.data.course.floated.FloatedCourseNotFoundException) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse)

Example 4 with FloatedCourse

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

Example 5 with FloatedCourse

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";
}
Also used : FacultyService(amu.zhcet.data.user.faculty.FacultyService) CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge) FacultyMemberNotFoundException(amu.zhcet.data.user.faculty.FacultyMemberNotFoundException) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) CourseInChargeService(amu.zhcet.data.course.incharge.CourseInChargeService) FacultyMember(amu.zhcet.data.user.faculty.FacultyMember) Slf4j(lombok.extern.slf4j.Slf4j) Model(org.springframework.ui.Model) List(java.util.List) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) GetMapping(org.springframework.web.bind.annotation.GetMapping) Comparator(java.util.Comparator) CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) FacultyMemberNotFoundException(amu.zhcet.data.user.faculty.FacultyMemberNotFoundException) FacultyMember(amu.zhcet.data.user.faculty.FacultyMember) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

FloatedCourse (amu.zhcet.data.course.floated.FloatedCourse)9 FloatedCourseNotFoundException (amu.zhcet.data.course.floated.FloatedCourseNotFoundException)6 CourseRegistration (amu.zhcet.data.course.registration.CourseRegistration)3 Comparator (java.util.Comparator)2 List (java.util.List)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Controller (org.springframework.stereotype.Controller)2 Model (org.springframework.ui.Model)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)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 Course (amu.zhcet.data.course.Course)1 CourseService (amu.zhcet.data.course.CourseService)1 FloatedCourseService (amu.zhcet.data.course.floated.FloatedCourseService)1 CourseInCharge (amu.zhcet.data.course.incharge.CourseInCharge)1 CourseInChargeService (amu.zhcet.data.course.incharge.CourseInChargeService)1