Unverified Commit fb90d26d authored by Ankit Verma's avatar Ankit Verma Committed by GitHub
Browse files

Merge pull request #183 from Radheshhathwar/development

Hall ticket and Attendance changes
Showing with 21 additions and 9 deletions
+21 -9
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
......@@ -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();
......
......@@ -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) {
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment