Commit 611a334b authored by Radheshhathwar's avatar Radheshhathwar
Browse files

delete api

Added examId in result
Showing with 15 additions and 6 deletions
+15 -6
......@@ -13,4 +13,5 @@ public class ExamDetailsDTO {
private String grade;
private String result;
private String status;
private Long examId;
}
......@@ -31,4 +31,6 @@ public interface ExamCycleRepository extends JpaRepository<ExamCycle, Long> {
List<ExamCycle> searchExamCycleByCourseIdAndStartYearAndEndYear(@Param("courseId") String courseId, @Param("startYear") Integer startYear, @Param("endYear") Integer endYear);
List<ExamCycle> findByCourseInAndEndDateAfter(List<Course> courses, LocalDate currentDate);
@Query("select ec.id from ExamCycle ec where ec.examCycleName =:examCycleName")
Long getIdByExamCycleName(String examCycleName);
}
......@@ -28,4 +28,7 @@ public interface ExamRepository extends JpaRepository<Exam, Long> {
List<Exam> findRegisteredExamsForStudentInCycle(Long studentId, Long examCycleId);
@Query("SELECT e.examName FROM Exam e WHERE e.id = :exam")
String getExamNameById(Long exam);
@Query("SELECT e.id FROM Exam e WHERE e.examName = :examName and e.examCycleId = :examCycleId")
Long getIdByExamName(String examName,Long examCycleId);
}
......@@ -37,9 +37,8 @@ public interface StudentResultRepository extends JpaRepository<StudentResult, Lo
Optional<StudentResult> findByExamIdAndStudentId(Long examId, Long studentId);
@Modifying
@Transactional
@Query(value = "UPDATE student_results SET external_marks = null FROM exam, students WHERE student_results.exam_cycle_id = exam.exam_cycle_id AND student_results.student_id = students.id AND exam.exam_cycle_id = :examCycleId AND students.institute_id = :instituteId", nativeQuery = true)
int setExternalMarksToNull(@Param("examCycleId") Long examCycleId, @Param("instituteId") Long instituteId);
@Query("UPDATE StudentResult sr SET sr.externalMarks = null, sr.passingExternalMarks = null, sr.externalMarksObtained = null WHERE sr.examCycle_name = :examCycleName AND sr.instituteId = :instituteId")
int setExternalMarksToNull(@Param("examCycleName") String examCycleName, @Param("instituteId") Long instituteId);
@Query("SELECT sr FROM StudentResult sr WHERE sr.firstName = :firstName AND sr.lastName = :lastName AND sr.enrollmentNumber = :enrollmentNumber")
StudentResult findByFirstNameAndLastNameAndEnrollmentNumber(
@Param("firstName") String firstName,
......
......@@ -407,7 +407,7 @@ public class StudentResultService {
}
public ResponseDto findByStudentIdAndExamCycleId(Long studentId, Long examCycleId) {
ResponseDto response = new ResponseDto(Constants.API_FIND_BY_ENROLLMENT_NUMBER_AND_DOB);
ResponseDto response = new ResponseDto(Constants.API_FIND_BY_ENROLLMENT_NUMBER_AND_ExamCycle);
// List<StudentResult> studentResultList = studentResultRepository.findByStudent_EnrollmentNumberAndExamCycle_IdAndPublished(enrollmentNumber, examCycleId, true);
String examCycleName = examCycleRepository.getExamCycleNameById(examCycleId);
......@@ -463,6 +463,9 @@ public class StudentResultService {
examDto.setGrade(studentResult.getGrade());
examDto.setResult(studentResult.getResult());
examDto.setStatus(studentResult.getStatus().name());
Long examCycleId = examCycleRepository.getIdByExamCycleName(studentResult.getExamCycle_name());
Long examId = examRepository.getIdByExamName(studentResult.getExam_name(),examCycleId);
examDto.setExamId(examId);
return examDto;
})
.collect(Collectors.toList());
......@@ -841,8 +844,9 @@ public class StudentResultService {
public ResponseDto deleteExternalMarks(Long examCycleId, Long instituteId) {
ResponseDto response = new ResponseDto(Constants.API_DELETE_FINAL_MARKS);
String examCycleName = examCycleRepository.getExamCycleNameById(examCycleId);
// Logic to set external marks to null for all students of the given institute for the specified exam cycle
int updatedCount = studentResultRepository.setExternalMarksToNull(examCycleId, instituteId);
int updatedCount = studentResultRepository.setExternalMarksToNull(examCycleName, instituteId);
if(updatedCount == 0) {
ResponseDto.setErrorResponse(response, "NO_DATA_FOUND", "No external marks found for the provided criteria.", HttpStatus.NOT_FOUND);
......
......@@ -116,7 +116,7 @@ public class Constants {
public static final String API_FETCH_COURSE_BY_NAME = "api.studentResult.fetchCourseByName";
public static final String API_FETCH_EXAM_BY_NAME = "api.studentResult.fetchExamByName";
public static final String API_PUBLISH_RESULTS_FOR_COURSE_WITHIN_CYCLE = "api.studentResult.publishForCourse";
public static final String API_FIND_BY_ENROLLMENT_NUMBER_AND_DOB = "api.studentResult.findByEnrollmentAndDob";
public static final String API_FIND_BY_ENROLLMENT_NUMBER_AND_ExamCycle = "api.studentResult.findByEnrollmentAndExamCycle";
public static final String API_UPDATE_RESULT_AFTER_RETOTALLING = "api.studentResult.updateAfterRetotalling";
public static final String API_GET_RESULTS_BY_EXAM_CYCLE_AND_EXAM_GROUPED_BY_INSTITUTE = "api.studentResult.getByExamCycleAndGroupedByInstitute";
public static final String API_BULK_UPLOAD_RESULTS = "api.studentResult.bulkUpload";
......
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