diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/StudentResult.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/StudentResult.java index e4bc277f0e7dc9071c9ad716af62fa4f61b78639..67ef190c19563efe28881ff8d8053933241897f0 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/StudentResult.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/StudentResult.java @@ -6,6 +6,7 @@ import lombok.*; import javax.persistence.*; import java.time.LocalDate; +import java.util.Date; @Entity @Table(name = "student_results") @@ -87,6 +88,7 @@ public class StudentResult { private String grade; @JsonProperty("Result") private String result; + private Date publishedDate; @Enumerated(EnumType.STRING) private ResultStatus status = ResultStatus.ENTERED; @@ -97,52 +99,4 @@ public class StudentResult { private boolean revisedFinalMarkFlag; private LocalDate lastDateToUploadInternalMarks; private long instituteId; - - public StudentResult(Student student, String firstName, String lastName, String enrollmentNumber, - String motherName, String fatherName, Course course, String course_name, - ExamCycle examCycle, String examCycle_name, Exam exam, String exam_name, - Integer internalMarks, Integer passingInternalMarks, Integer internalMarksObtained, - Integer practicalMarks, Integer passingPracticalMarks, Integer practicalMarksObtained, - Integer otherMarks, Integer passingOtherMarks, Integer otherMarksObtained, - Integer externalMarks, Integer passingExternalMarks, Integer externalMarksObtained, - Integer totalMarks, Integer passingTotalMarks, Integer totalMarksObtained, - String grade, String result, ResultStatus status, boolean published, boolean internalMarkFlag, boolean finalMarkFlag, boolean revisedFinalMarkFlag,LocalDate lastDateToUploadInternalMarks, long instituteId) { - - this.student = student; - this.firstName = firstName; - this.lastName = lastName; - this.enrollmentNumber = enrollmentNumber; - this.motherName = motherName; - this.fatherName = fatherName; - this.course = course; - this.course_name = course_name; - this.examCycle = examCycle; - this.examCycle_name = examCycle_name; - this.exam = exam; - this.exam_name = exam_name; - this.internalMarks = internalMarks; - this.passingInternalMarks = passingInternalMarks; - this.internalMarksObtained = internalMarksObtained; - this.practicalMarks = practicalMarks; - this.passingPracticalMarks = passingPracticalMarks; - this.practicalMarksObtained = practicalMarksObtained; - this.otherMarks = otherMarks; - this.passingOtherMarks = passingOtherMarks; - this.otherMarksObtained = otherMarksObtained; - this.externalMarks = externalMarks; - this.passingExternalMarks = passingExternalMarks; - this.externalMarksObtained = externalMarksObtained; - this.totalMarks = totalMarks; - this.passingTotalMarks = passingTotalMarks; - this.totalMarksObtained = totalMarksObtained; - this.grade = grade; - this.result = result; - this.status = status; - this.published = published; - this.internalMarkFlag = internalMarkFlag; - this.finalMarkFlag = finalMarkFlag; - this.revisedFinalMarkFlag = revisedFinalMarkFlag; - this.lastDateToUploadInternalMarks=lastDateToUploadInternalMarks; - this.instituteId=instituteId; - } } \ No newline at end of file diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamDetailsDTO.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamDetailsDTO.java index 2a188a5da9df84039e833a6c2a7b992557888f30..3dca6d1c1d6661ed362b9bb4fadd233469af02d2 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamDetailsDTO.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamDetailsDTO.java @@ -14,4 +14,5 @@ public class ExamDetailsDTO { private String result; private String status; private Long examId; + private boolean hasRevisedFinalMarkFlag; } diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ProcessedResultDto.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ProcessedResultDto.java index eefab08eabadd33722e102e48af07f2d99f541ea..4ec33f1e732e5584cc8cfe87b5308b379e1b0e09 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ProcessedResultDto.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ProcessedResultDto.java @@ -12,6 +12,7 @@ public class ProcessedResultDto { private boolean hasInternalMarks; private boolean hasFinalMarks; private boolean hasRevisedFinalMarks; + private boolean hasPublished; private String instituteName; private Long instituteId; private String course; diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/StudentResultDTO.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/StudentResultDTO.java index b6f176dc7eb1118a3468346c77c570245a5aa5d8..aab5bcfc7f57a4d30c231973ec08c6d7bb760616 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/StudentResultDTO.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/StudentResultDTO.java @@ -4,6 +4,7 @@ import com.tarento.upsmf.examsAndAdmissions.enums.ResultStatus; import lombok.*; import java.time.LocalDate; +import java.util.Date; import java.util.List; @Getter @@ -16,5 +17,6 @@ public class StudentResultDTO { private LocalDate dateOfBirth; private String courseName; private String courseYear; + private Date publishedDate; private List<ExamDetailsDTO> examDetails; } 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 397c7e58ab2243c7aaebf051d481c78b7b473312..f41a91b25408887c22e70450da0620133008112a 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java @@ -21,6 +21,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; @@ -391,10 +393,12 @@ public class StudentResultService { public ResponseDto publishResultsForCourseWithinCycle(Long courseId, Long examCycleId) { ResponseDto response = new ResponseDto(Constants.API_PUBLISH_RESULTS_FOR_COURSE_WITHIN_CYCLE); List<StudentResult> resultsForCourse = studentResultRepository.findByCourse_IdAndExam_ExamCycleIdAndPublished(courseId, examCycleId, false); - + LocalDateTime localDateTime = LocalDateTime.now(); + Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); if (!resultsForCourse.isEmpty()) { for (StudentResult result : resultsForCourse) { result.setPublished(true); + result.setPublishedDate(date); } studentResultRepository.saveAll(resultsForCourse); response.put(Constants.MESSAGE, "Successfully published results."); @@ -445,6 +449,7 @@ public class StudentResultService { Student student = studentRepository.findByEnrollmentNumber(firstResult.getEnrollmentNumber()).orElseThrow(); // dto.setDateOfBirth(firstResult.getStudent().getDateOfBirth()); dto.setDateOfBirth(student.getDateOfBirth()); + dto.setPublishedDate(firstResult.getPublishedDate()); if (firstResult.getExamCycle_name() != null) { ExamCycle examCycle = examCycleRepository.findByExamCycleName(firstResult.getExamCycle_name()); if (examCycle.getCourse() != null) { @@ -466,6 +471,7 @@ public class StudentResultService { Long examCycleId = examCycleRepository.getIdByExamCycleName(studentResult.getExamCycle_name()); Long examId = examRepository.getIdByExamName(studentResult.getExam_name(),examCycleId); examDto.setExamId(examId); + examDto.setHasRevisedFinalMarkFlag(studentResult.isRevisedFinalMarkFlag()); return examDto; }) .collect(Collectors.toList()); @@ -799,6 +805,7 @@ public class StudentResultService { instituteResult.setHasInternalMarks(result.isInternalMarkFlag()); instituteResult.setHasFinalMarks(result.isFinalMarkFlag()); instituteResult.setHasRevisedFinalMarks(result.isRevisedFinalMarkFlag()); + instituteResult.setHasPublished(result.isPublished()); } return processedResults; }