diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java index b82a7fc8ca9c7a904292259868ff5e5a7253612f..2c2e7bccb041cf46e23565ac24c34e603ed15807 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/HallTicketController.java @@ -103,8 +103,8 @@ public class HallTicketController { @GetMapping("/dataCorrection/requests") - public ResponseEntity<ResponseDto> viewDataCorrectionRequests() { - ResponseDto responseDto = hallTicketService.getAllDataCorrectionRequests(); + public ResponseEntity<ResponseDto> viewDataCorrectionRequests(@RequestParam(value = "examCycleId", required = false) Optional<Long> examCycleId) { + ResponseDto responseDto = hallTicketService.getAllDataCorrectionRequests(examCycleId); return ResponseEntity.status(responseDto.getResponseCode().value()).body(responseDto); } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/AttendanceRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/AttendanceRepository.java index 113e6d8d3a18c788c99b4fce0e351b043ff45f1e..385e9b55859026dbbdf80942f834b138a4ebdfa8 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/AttendanceRepository.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/AttendanceRepository.java @@ -8,7 +8,7 @@ import java.util.List; @Repository public interface AttendanceRepository extends JpaRepository<AttendanceRecord, Long> { - boolean existsByStudentEnrollmentNumber(String studentEnrollmentNumber); + boolean existsByStudentEnrollmentNumberAndExamCycleData(String studentEnrollmentNumber, String examCycleName); AttendanceRecord findByStudentEnrollmentNumber(String studentEnrollmentNumber); List<AttendanceRecord> findByExamCycleId(Long examCycleId); diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/DataCorrectionRequestRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/DataCorrectionRequestRepository.java index 6bf81b4d7f826ecd5aa1035cd5873f8890ca7114..4f07c6fdbff63f1bb9b049d4a034765abb219096 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/DataCorrectionRequestRepository.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/DataCorrectionRequestRepository.java @@ -4,7 +4,12 @@ import com.tarento.upsmf.examsAndAdmissions.model.dto.DataCorrectionRequest; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Optional; + @Repository public interface DataCorrectionRequestRepository extends JpaRepository<DataCorrectionRequest, Long> { String getProofAttachmentPathById(Long requestId); + + List<DataCorrectionRequest> getByExamCycleId(Optional<Long> examCycleId); } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/AttendanceService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/AttendanceService.java index fbd4ac25898b161ab365b35f785c46f3b61465b0..cb5e2aee9f90bc57debb6dcf8aad502b3d5edefa 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/AttendanceService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/AttendanceService.java @@ -65,10 +65,11 @@ public class AttendanceService { continue; // Skip this iteration if the row is empty } String studentEnrollmentNumber = getStringValue(row.getCell(2)); + String examCycleId = getStringValue(row.getCell(6)); AttendanceRecord record; // If record already exists, fetch it, otherwise create a new one - if (attendanceRepository.existsByStudentEnrollmentNumber(studentEnrollmentNumber)) { + if (attendanceRepository.existsByStudentEnrollmentNumberAndExamCycleData(studentEnrollmentNumber,examCycleId)) { record = attendanceRepository.findByStudentEnrollmentNumber(studentEnrollmentNumber); } else { record = new AttendanceRecord(); diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java index 34411026cbf6d109210ea0fbe0972c673f97adcb..afcf47b518aaf69bc0564191836364e717776b4a 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java @@ -777,7 +777,7 @@ public class DataImporterService { } private boolean checkIfDataExists(AttendanceRecord dto) { - return attendanceRepository.existsByStudentEnrollmentNumber(dto.getStudentEnrollmentNumber()); + return attendanceRepository.existsByStudentEnrollmentNumberAndExamCycleData(dto.getStudentEnrollmentNumber(),dto.getExamCycleData()); } private boolean checkIfDataExists(ExamUploadData dto) { diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java index 0609cc938bc4741998826cb7de3316da0af3e329..60685a293df15e657bb4c6a2a73bdd00501cb066 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/HallTicketService.java @@ -321,9 +321,14 @@ public class HallTicketService { return dto; } - public ResponseDto getAllDataCorrectionRequests() { + public ResponseDto getAllDataCorrectionRequests(Optional<Long> examCycleId) { ResponseDto response = new ResponseDto(Constants.API_HALLTICKET_GET_ALL_DATA_CORRECTION_REQUESTS); - List<DataCorrectionRequest> requests = dataCorrectionRequestRepository.findAll(); + List<DataCorrectionRequest> requests; + if (examCycleId.isPresent()) { + requests = dataCorrectionRequestRepository.getByExamCycleId(examCycleId); + } else { + requests = dataCorrectionRequestRepository.findAll(); + } List<Map<String, Object>> formattedRequests = new ArrayList<>(); for (DataCorrectionRequest request : requests) { @@ -340,7 +345,7 @@ public class HallTicketService { formattedRequest.put("lastName", student.getSurname()); // changed from 'surName' formattedRequest.put("enrollmentNumber", student.getEnrollmentNumber()); - StudentExamRegistration registration = studentExamRegistrationRepository.getByStudentIdAndExamCycleId(student.getId(),request.getExamCycle().getId()); + StudentExamRegistration registration = studentExamRegistrationRepository.getByStudentIdAndExamCycleId(student.getId(), request.getExamCycle().getId()); if (registration != null) { Map<String, Object> examCycleData = new HashMap<>(); ExamCycle examCycle = registration.getExamCycle(); @@ -660,9 +665,10 @@ public class HallTicketService { private double computeAttendancePercentage(StudentExamRegistration registration) { // Fetch the student enrollment number from the associated student String studentEnrollmentNumber = registration.getStudent().getEnrollmentNumber(); + String examCycleData = registration.getExamCycle().getExamCycleName(); // Check if an attendance record exists for this student enrollment number - if (!attendanceRepository.existsByStudentEnrollmentNumber(studentEnrollmentNumber)) { + if (!attendanceRepository.existsByStudentEnrollmentNumberAndExamCycleData(studentEnrollmentNumber,examCycleData)) { return 0.0; }