Search in sources :

Example 1 with CourseInCharge

use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.

the class AttendanceDownloadController method downloadAttendanceForFaculty.

/**
 * Downloads attendance for course taught by faculty. Shown in attendance upload section of the course in Faculty Panel
 * @param response Response object to be sent, containing the attendance CSV
 * @param code The course and section code for faculty, of the form course:section
 */
@GetMapping("/admin/faculty/courses/{code}/attendance.csv")
public ResponseEntity<InputStreamResource> downloadAttendanceForFaculty(HttpServletResponse response, @PathVariable String code) {
    CourseInCharge courseInCharge = courseInChargeService.getCourseInCharge(code).orElseThrow(CourseInChargeNotFoundException::new);
    String section = StringUtils.defaultString(CourseInChargeService.getCodeAndSection(code).getRight(), "all");
    List<CourseRegistration> courseRegistrations = courseInChargeService.getCourseRegistrations(courseInCharge);
    String suffix = courseInCharge.getFloatedCourse().getCourse().getCode() + "_" + section;
    return downloadAttendance("faculty", suffix, courseRegistrations);
}
Also used : CourseRegistration(amu.zhcet.data.course.registration.CourseRegistration) CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge) CourseInChargeNotFoundException(amu.zhcet.data.course.incharge.CourseInChargeNotFoundException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with CourseInCharge

use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.

the class InChargeManagementService method getInCharge.

private CourseInCharge getInCharge(FloatedCourse floatedCourse, FacultyMember facultyMember, String section) {
    CourseInCharge courseInCharge = new CourseInCharge();
    courseInCharge.setFloatedCourse(floatedCourse);
    courseInCharge.setFacultyMember(facultyMember);
    courseInCharge.setSection(section);
    return courseInCharge;
}
Also used : CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge)

Example 3 with CourseInCharge

use of amu.zhcet.data.course.incharge.CourseInCharge 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)

Example 4 with CourseInCharge

use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.

the class FacultyCourseAttendanceController method attendance.

@GetMapping
public String attendance(Model model, @PathVariable String code) {
    CourseInCharge courseInCharge = courseInChargeService.getCourseInCharge(code).orElseThrow(CourseInChargeNotFoundException::new);
    model.addAttribute("page_title", courseInCharge.getFloatedCourse().getCourse().getCode() + " - " + courseInCharge.getFloatedCourse().getCourse().getTitle());
    model.addAttribute("page_subtitle", "Attendance management for " + courseInCharge.getFloatedCourse().getCourse().getCode());
    model.addAttribute("page_description", "Upload attendance for the floated course");
    List<CourseRegistration> courseRegistrations = courseInChargeService.getCourseRegistrations(courseInCharge);
    List<String> emails = FloatedCourseService.getEmailsFromCourseRegistrations(courseRegistrations.stream()).collect(Collectors.toList());
    SortUtils.sortCourseAttendance(courseRegistrations);
    model.addAttribute("incharge", courseInCharge);
    model.addAttribute("courseRegistrations", courseRegistrations);
    model.addAttribute("course", courseInCharge.getFloatedCourse().getCourse());
    model.addAttribute("email_list", emails);
    return "faculty/course_attendance";
}
Also used : CourseRegistration(amu.zhcet.data.course.registration.CourseRegistration) CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge) CourseInChargeNotFoundException(amu.zhcet.data.course.incharge.CourseInChargeNotFoundException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with CourseInCharge

use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.

the class AttendanceUploadController method uploadAttendance.

@PostMapping("/confirm")
public String uploadAttendance(RedirectAttributes attributes, @PathVariable String code, @Valid @ModelAttribute AttendanceModel attendanceModel, BindingResult bindingResult) {
    CourseInCharge courseInCharge = courseInChargeService.getCourseInCharge(code).orElseThrow(CourseInChargeNotFoundException::new);
    if (bindingResult.hasErrors()) {
        attributes.addFlashAttribute("attendanceModel", attendanceModel);
        attributes.addFlashAttribute("org.springframework.validation.BindingResult.attendanceModel", bindingResult);
    } else {
        try {
            attendanceUploadService.updateAttendance(courseInCharge, attendanceModel.getUploadList());
            attributes.addFlashAttribute("updated", true);
        } catch (Exception e) {
            log.error("Attendance Confirm", e);
            attributes.addFlashAttribute("attendanceModel", attendanceModel);
            attributes.addFlashAttribute("unknown_error", true);
        }
    }
    return "redirect:/admin/faculty/courses/{code}/attendance";
}
Also used : CourseInCharge(amu.zhcet.data.course.incharge.CourseInCharge) CourseInChargeNotFoundException(amu.zhcet.data.course.incharge.CourseInChargeNotFoundException) IOException(java.io.IOException) CourseInChargeNotFoundException(amu.zhcet.data.course.incharge.CourseInChargeNotFoundException)

Aggregations

CourseInCharge (amu.zhcet.data.course.incharge.CourseInCharge)13 CourseInChargeNotFoundException (amu.zhcet.data.course.incharge.CourseInChargeNotFoundException)5 Test (org.junit.Test)4 IOException (java.io.IOException)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 CourseRegistration (amu.zhcet.data.course.registration.CourseRegistration)2 List (java.util.List)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Attendance (amu.zhcet.data.attendance.Attendance)1 AttendanceService (amu.zhcet.data.attendance.AttendanceService)1 FloatedCourse (amu.zhcet.data.course.floated.FloatedCourse)1 CourseInChargeService (amu.zhcet.data.course.incharge.CourseInChargeService)1 FacultyMember (amu.zhcet.data.user.faculty.FacultyMember)1 FacultyMemberNotFoundException (amu.zhcet.data.user.faculty.FacultyMemberNotFoundException)1 FacultyService (amu.zhcet.data.user.faculty.FacultyService)1 Confirmation (amu.zhcet.storage.csv.Confirmation)1 UploadResult (amu.zhcet.storage.csv.UploadResult)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1