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);
}
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;
}
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";
}
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";
}
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";
}
Aggregations