From 05d7d61f69b04bd15bcf1105f86cd1eb3bf0d932 Mon Sep 17 00:00:00 2001
From: Radheshhathwar <radheshhathwar.bh@gmail.com>
Date: Thu, 2 Nov 2023 15:32:48 +0530
Subject: [PATCH] studentResults/manageResults
 studentResults/examMarksByInstitute

---
 .../repository/ExamRepository.java                |  1 +
 .../repository/StudentResultRepository.java       |  2 +-
 .../service/StudentResultService.java             | 15 +++++++--------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamRepository.java
index 62b1003..da91d33 100644
--- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamRepository.java
+++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/ExamRepository.java
@@ -26,5 +26,6 @@ public interface ExamRepository extends JpaRepository<Exam, Long> {
 
     @Query("SELECT e FROM Exam e JOIN StudentExamRegistration ser ON e.id = ser.exam.id WHERE ser.student.id = :studentId AND e.examCycleId = :examCycleId")
     List<Exam> findRegisteredExamsForStudentInCycle(Long studentId, Long examCycleId);
+    @Query("SELECT e.examName FROM Exam e WHERE e.id = :exam")
     String getExamNameById(Long exam);
 }
diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java
index f1823a9..6cd1fb1 100644
--- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java
+++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java
@@ -58,7 +58,7 @@ public interface StudentResultRepository extends JpaRepository<StudentResult, Lo
 
     List<StudentResult> findByStudent_EnrollmentNumberAndExamCycle_IdAndPublished(String enrollmentNumber, Long examCycleId, boolean b);
 
-    @Query("SELECT sr FROM StudentResult sr WHERE sr.examCycle_name = :examCycleName AND sr.exam_name = :examName AND sr.student.institute.id = :institute")
+    @Query("SELECT sr FROM StudentResult sr WHERE sr.examCycle_name = :examCycleName AND sr.exam_name = :examName AND sr.instituteId = :institute")
     List<StudentResult> findByExamCycleNameAndExamNameAndInstitute(String examCycleName, String examName, Long institute);
 
     @Query("SELECT sr FROM StudentResult sr WHERE sr.examCycle_name = :examCycleName")
diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java
index b94a0d2..9fe8906 100644
--- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java
+++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java
@@ -734,10 +734,9 @@ public class StudentResultService {
                 dto.setCourse(result.getCourse_name());
                 return dto;
             });
-            instituteResult.setHasFinalMarks(result.isInternalMarkFlag());
+            instituteResult.setHasInternalMarks(result.isInternalMarkFlag());
             instituteResult.setHasFinalMarks(result.isFinalMarkFlag());
             instituteResult.setHasRevisedFinalMarks(result.isRevisedFinalMarkFlag());
-
         }
         return processedResults;
     }
@@ -746,7 +745,7 @@ public class StudentResultService {
         ResponseDto response = new ResponseDto(Constants.API_SINGLE_EXAM_MARK);
         String examCycleName = examCycleRepository.getExamCycleNameById(examCycle);
         String examName = examRepository.getExamNameById(exam);
-        List<StudentResult> studentResults = studentResultRepository.findByExamCycleNameAndExamNameAndInstitute(examCycleName, examCycleName, institute);
+        List<StudentResult> studentResults = studentResultRepository.findByExamCycleNameAndExamNameAndInstitute(examCycleName, examName, institute);
 
         // If no results found, return a not found response.
         if(studentResults.isEmpty()) {
@@ -766,12 +765,12 @@ public class StudentResultService {
 
     private StudentResultDto convertToDto(StudentResult result) {
         StudentResultDto dto = new StudentResultDto();
-        dto.setFirstName(result.getStudent().getFirstName());
-        dto.setLastName(result.getStudent().getSurname());
-        dto.setCourseName(result.getCourse().getCourseName());
-        dto.setExam(result.getExam().getExamName());
+        dto.setFirstName(result.getFirstName());
+        dto.setLastName(result.getLastName());
+        dto.setCourseName(result.getCourse_name());
+        dto.setExam(result.getExam_name());
         dto.setInternalMark(result.getInternalMarksObtained());
-        dto.setLastName(result.getEnrollmentNumber());
+        dto.setEnrollmentNumber(result.getEnrollmentNumber());
         return dto;
     }
     public ResponseDto getExamsForExamCycleAndUploadStatusForInstitute(Long examCycleId, Long instituteId) {
-- 
GitLab