Search in sources :

Example 6 with FloatedCourse

use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.

the class CourseRegistrationUploadService method registerStudents.

@Transactional
public List<CourseRegistration> registerStudents(Course course, Confirmation<CourseRegistration> confirmation) {
    Optional<FloatedCourse> floatedCourseOptional = floatedCourseService.getFloatedCourse(course);
    if (!floatedCourseOptional.isPresent())
        return Collections.emptyList();
    FloatedCourse floatedCourse = floatedCourseOptional.get();
    List<CourseRegistration> registrations = new ArrayList<>();
    for (CourseRegistration registration : confirmation.getData()) {
        registration.setFloatedCourse(floatedCourse);
        registration.getAttendance().setId(registration.generateId());
        registrations.add(registration);
    }
    floatedCourse.getCourseRegistrations().addAll(registrations);
    floatedCourseService.save(floatedCourse);
    return registrations;
}
Also used : CourseRegistration(amu.zhcet.data.course.registration.CourseRegistration) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse) ArrayList(java.util.ArrayList) Transactional(javax.transaction.Transactional)

Example 7 with FloatedCourse

use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.

the class FloatedCourseEditController method courseDetail.

@GetMapping("/{course}")
public String courseDetail(Model model, @PathVariable Course course, WebRequest webRequest) {
    FloatedCourse floatedCourse = floatedCourseService.getFloatedCourse(course).orElseThrow(FloatedCourseNotFoundException::new);
    if (!model.containsAttribute("success"))
        webRequest.removeAttribute("confirmRegistration", RequestAttributes.SCOPE_SESSION);
    model.addAttribute("page_title", course.getCode() + " - " + course.getTitle());
    model.addAttribute("page_subtitle", "Course management for " + course.getCode());
    model.addAttribute("page_description", "Register Students for the Floated course");
    List<CourseRegistration> courseRegistrations = floatedCourse.getCourseRegistrations();
    List<String> emails = FloatedCourseService.getEmailsFromCourseRegistrations(courseRegistrations.stream()).collect(Collectors.toList());
    SortUtils.sortCourseAttendance(courseRegistrations);
    model.addAttribute("courseRegistrations", courseRegistrations);
    model.addAttribute("floatedCourse", floatedCourse);
    model.addAttribute("email_list", emails);
    return "dean/floated_course";
}
Also used : FloatedCourseNotFoundException(amu.zhcet.data.course.floated.FloatedCourseNotFoundException) CourseRegistration(amu.zhcet.data.course.registration.CourseRegistration) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse)

Example 8 with FloatedCourse

use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.

the class FloatedCourseController method courseDetail.

@GetMapping
public String courseDetail(Model model, @PathVariable Course course, WebRequest webRequest) {
    FloatedCourse floatedCourse = floatedCourseService.getFloatedCourse(course).orElseThrow(FloatedCourseNotFoundException::new);
    if (!model.containsAttribute("success"))
        webRequest.removeAttribute("confirmRegistration", RequestAttributes.SCOPE_SESSION);
    model.addAttribute("page_title", course.getCode() + " - " + course.getTitle());
    model.addAttribute("page_subtitle", "Course management for " + course.getCode());
    model.addAttribute("page_description", "Register Students and add Faculty In-Charge for the course");
    model.addAttribute("page_path", getPath(course));
    List<CourseRegistration> courseRegistrations = floatedCourse.getCourseRegistrations();
    List<String> emails = FloatedCourseService.getEmailsFromCourseRegistrations(courseRegistrations.stream()).collect(Collectors.toList());
    SortUtils.sortCourseAttendance(courseRegistrations);
    model.addAttribute("courseRegistrations", courseRegistrations);
    model.addAttribute("floatedCourse", floatedCourse);
    model.addAttribute("sections", FloatedCourseService.getSections(floatedCourse));
    model.addAttribute("email_list", emails);
    return "department/floated_course";
}
Also used : FloatedCourseNotFoundException(amu.zhcet.data.course.floated.FloatedCourseNotFoundException) CourseRegistration(amu.zhcet.data.course.registration.CourseRegistration) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse)

Example 9 with FloatedCourse

use of amu.zhcet.data.course.floated.FloatedCourse in project zhcet-web by zhcet-amu.

the class FloatedCourseController method removeStudent.

@PostMapping("/unregister")
public String removeStudent(RedirectAttributes attributes, @PathVariable Course course, @RequestParam Student student) {
    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/department/floated/{course}";
}
Also used : FloatedCourseNotFoundException(amu.zhcet.data.course.floated.FloatedCourseNotFoundException) FloatedCourse(amu.zhcet.data.course.floated.FloatedCourse)

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