use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.
the class AttendanceUploadService method updateAttendance.
@Transactional
public void updateAttendance(CourseInCharge courseInCharge, List<AttendanceUpload> uploadList) {
Map<String, AttendanceUpload> attendanceUploadMap = uploadList.stream().collect(Collectors.toMap(AttendanceUpload::getEnrolmentNo, item -> item));
List<Attendance> attendances = attendanceService.getAttendanceByCourseInChargeAndStudents(courseInCharge, attendanceUploadMap.keySet());
for (Attendance attendance : attendances) {
AttendanceUpload attendanceUpload = attendanceUploadMap.get(attendance.getCourseRegistration().getStudent().getEnrolmentNumber());
attendance.setDelivered(attendanceUpload.getDelivered());
attendance.setAttended(attendanceUpload.getAttended());
}
attendanceService.save(attendances);
eventPublisher.publishEvent(new AttendanceUploadEvent(courseInCharge, attendances));
}
use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.
the class DiffUtilsTest method courseInChargeShouldBeDifferentWithDifferentSection.
@Test
public void courseInChargeShouldBeDifferentWithDifferentSection() {
CourseInCharge courseInCharge1 = getCourseInCharge(23L, floatedCourse, dean, null);
CourseInCharge courseInCharge2 = getCourseInCharge(23L, floatedCourse, dean, "A4PE");
assertFalse(courseInCharge1.equals(courseInCharge2));
assertFalse(courseInCharge2.equals(courseInCharge1));
}
use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.
the class AttendanceUploadController method uploadFile.
@PostMapping
public String uploadFile(RedirectAttributes attributes, @PathVariable String code, @RequestParam MultipartFile file) {
CourseInCharge courseInCharge = courseInChargeService.getCourseInCharge(code).orElseThrow(CourseInChargeNotFoundException::new);
try {
UploadResult<AttendanceUpload> result = attendanceUploadService.handleUpload(file);
if (!result.getErrors().isEmpty()) {
attributes.addFlashAttribute("errors", result.getErrors());
} else {
attributes.addFlashAttribute("success", true);
Confirmation<AttendanceUpload> confirmation = attendanceUploadService.confirmUpload(courseInCharge, result);
if (confirmation.getErrors().isEmpty()) {
AttendanceModel attendanceModel = new AttendanceModel();
List<AttendanceUpload> attendanceUploads = new ArrayList<>(confirmation.getData());
SortUtils.sortAttendanceUpload(attendanceUploads);
attendanceModel.setUploadList(attendanceUploads);
attributes.addFlashAttribute("attendanceModel", attendanceModel);
} else {
attributes.addFlashAttribute("confirmAttendanceErrors", confirmation);
}
}
} catch (IOException ioe) {
log.error("Attendance Upload", ioe);
}
return "redirect:/admin/faculty/courses/{code}/attendance";
}
use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.
the class AttendanceUploadController method edit.
@GetMapping
public String edit(RedirectAttributes attributes, @PathVariable String code) {
CourseInCharge courseInCharge = courseInChargeService.getCourseInCharge(code).orElseThrow(CourseInChargeNotFoundException::new);
AttendanceModel attendanceModel = new AttendanceModel();
List<AttendanceUpload> attendanceUploads = courseInChargeService.getCourseRegistrations(courseInCharge).stream().map(attendanceMapper::fromCourseRegistration).collect(Collectors.toList());
SortUtils.sortAttendanceUpload(attendanceUploads);
attendanceModel.setUploadList(attendanceUploads);
attributes.addFlashAttribute("attendanceModel", attendanceModel);
return "redirect:/admin/faculty/courses/{code}/attendance";
}
use of amu.zhcet.data.course.incharge.CourseInCharge in project zhcet-web by zhcet-amu.
the class DiffUtilsTest method courseInChargeShouldBeSameWithDifferentId.
@Test
public void courseInChargeShouldBeSameWithDifferentId() {
CourseInCharge courseInCharge1 = getCourseInCharge(23L, floatedCourse, dean, null);
CourseInCharge courseInCharge2 = getCourseInCharge(54L, floatedCourse, dean, null);
assertTrue(courseInCharge1.equals(courseInCharge2));
assertTrue(courseInCharge2.equals(courseInCharge1));
}
Aggregations