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

Merge pull request #34 from jaypratapsingh1/feature/exam_results_dev

Feature/exam results dev
Showing with 170 additions and 82 deletions
+170 -82
......@@ -3,6 +3,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.service.ExamService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -18,8 +19,8 @@ public class ExamController {
private ExamService examService;
@PostMapping("/create")
public ResponseEntity<?> createExam(@RequestBody Exam exam) {
ResponseDto response = examService.createExam(exam);
public ResponseEntity<?> createExam(@RequestBody Exam exam, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseDto response = examService.createExam(exam, userId);
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/list")
......@@ -41,8 +42,8 @@ public class ExamController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateExam(@PathVariable Long id, @RequestBody Exam exam) {
ResponseDto response = examService.updateExam(id, exam);
public ResponseEntity<?> updateExam(@PathVariable Long id, @RequestBody Exam exam, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseDto response = examService.updateExam(id, exam, userId);
return new ResponseEntity<>(response, response.getResponseCode());
}
......
......@@ -9,9 +9,11 @@ import com.tarento.upsmf.examsAndAdmissions.service.ExamCycleService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.codehaus.jettison.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.tarento.upsmf.examsAndAdmissions.model.dto.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
......@@ -31,9 +33,9 @@ public class ExamCycleController {
@PostMapping("/create")
public ResponseEntity<?> createExamCycle(@RequestBody ExamCycle examCycle) {
public ResponseEntity<?> createExamCycle(@RequestBody ExamCycle examCycle, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle createdExamCycle = service.createExamCycle(examCycle);
ExamCycle createdExamCycle = service.createExamCycle(examCycle,userId);
return new ResponseEntity<>(createdExamCycle, HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>("Failed to create ExamCycle.", HttpStatus.INTERNAL_SERVER_ERROR);
......@@ -66,9 +68,9 @@ public class ExamCycleController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateExamCycle(@PathVariable Long id, @RequestBody ExamCycle examCycle) {
public ResponseEntity<?> updateExamCycle(@PathVariable Long id, @RequestBody ExamCycle examCycle, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle updatedExamCycle = service.updateExamCycle(id, examCycle);
ExamCycle updatedExamCycle = service.updateExamCycle(id, examCycle, userId);
if (updatedExamCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
......@@ -99,13 +101,13 @@ public class ExamCycleController {
}
@PostMapping("/{id}/addExam")
public ResponseEntity<?> addExamToCycle(@PathVariable Long id, @RequestBody List<Exam> exam) {
public ResponseEntity<?> addExamToCycle(@PathVariable Long id, @RequestBody List<Exam> exams, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle examCycle = service.addExamsToCycle(id, exam);
ExamCycle examCycle = service.addExamsToCycle(id, exams, userId);
if (examCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(exam, HttpStatus.CREATED);
return new ResponseEntity<>(exams, HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>("Failed to add exam to ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
......@@ -122,6 +124,31 @@ public class ExamCycleController {
return new ResponseEntity<>("Failed to remove exam from ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PutMapping("/{id}/publish")
public ResponseEntity<?> publishExamCycle(@PathVariable Long id) {
try {
ExamCycle publishedExamCycle = service.publishExamCycle(id);
if (publishedExamCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(publishedExamCycle, HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>("Failed to publish ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PostMapping("/createExamCycleWithExams")
public ResponseEntity<?> createExamCycleWithExams(@RequestBody ExamCycleWithExamsDTO examCycleWithExamsDTO, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
// Create the ExamCycle
ExamCycle createdExamCycle = service.createExamCycle(examCycleWithExamsDTO.getExamCycle(), userId);
// Add Exams to the ExamCycle
service.addExamsToCycle(createdExamCycle.getId(), examCycleWithExamsDTO.getExams(), userId);
return ResponseEntity.ok("ExamCycle with Exams created successfully.");
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to create ExamCycle with Exams.");
@PostMapping("/bulkUpload")
public ResponseEntity<Map<String, Object>> processBulkExamUploads(@RequestParam("file") MultipartFile file, @RequestParam("fileType") String fileType) {
Map<String, Object> response = new HashMap<>();
......
......@@ -2,7 +2,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.VerificationStatus;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import com.tarento.upsmf.examsAndAdmissions.model.dto.StudentDto;
import com.tarento.upsmf.examsAndAdmissions.service.StudentService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
......@@ -11,12 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
......
......@@ -2,6 +2,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.dto.StudentExamRegistrationDTO;
import com.tarento.upsmf.examsAndAdmissions.service.StudentExamRegistrationService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -19,8 +20,9 @@ public class StudentExamRegistrationController {
private StudentExamRegistrationService registrationService;
@PostMapping("/register")
public ResponseEntity<?> registerStudentForExam(@RequestBody List<StudentExamRegistrationDTO> registrationDetails) {
ResponseEntity<?> registration = registrationService.registerStudentsForExams(registrationDetails);
public ResponseEntity<?> registerStudentForExam(@RequestBody List<StudentExamRegistrationDTO> registrationDetails, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseEntity<?> registration = registrationService.registerStudentsForExams(registrationDetails, userId);
return new ResponseEntity<>(registration, HttpStatus.CREATED);
}
......
package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.enums.RetotallingStatus;
import com.tarento.upsmf.examsAndAdmissions.model.RetotallingRequest;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
......@@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -31,7 +33,6 @@ public class StudentResultController {
@Autowired
private StudentResultService studentResultService;
@Autowired
private RetotallingService retotallingService;
@Autowired
......@@ -104,37 +105,14 @@ public class StudentResultController {
}
}
@PostMapping("/retotalling")
public ResponseEntity<String> requestRetotalling(@RequestBody RetotallingRequest retotallingRequest) {
@PostMapping("/requestRetotalling")
public ResponseEntity<?> requestRetotalling(@RequestBody RetotallingRequest request) {
try {
// Fetch the student from the database using the enrollmentNumber
Student existingStudent = studentResultService.fetchStudentByEnrollmentNumber(retotallingRequest.getStudent().getEnrollmentNumber());
if (existingStudent == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Student not found.");
}
// Set the fetched student to the retotallingRequest
retotallingRequest.setStudent(existingStudent);
// Check for each exam
for (Exam exam : retotallingRequest.getExams()) {
// Check if payment was successful
if (!retotallingService.isPaymentSuccessful(existingStudent.getEnrollmentNumber(), exam.getId())) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment not completed for exam ID: " + exam.getId() + ". Please make the payment before requesting re-totalling.");
}
// Check if a re-totalling request already exists
if (retotallingService.hasAlreadyRequestedRetotalling(existingStudent.getEnrollmentNumber(), exam.getId())) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("You have already requested re-totalling for exam ID: " + exam.getId());
}
}
// Save the re-totalling request
retotallingService.requestRetotalling(retotallingRequest);
return ResponseEntity.ok("Re-totalling request submitted successfully.");
RetotallingRequest result = retotallingService.requestRetotalling(request);
return ResponseEntity.ok(result);
} catch (RuntimeException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
} catch (Exception e) {
log.error("Error processing re-totalling request", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to process re-totalling request.");
}
}
......
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum ExamCycleStatus {
DRAFT, PUBLISHED
}
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum RetotallingStatus {
PENDING,
COMPLETED
}
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.model;
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum VerificationStatus {
PENDING, VERIFIED, CLOSED, REJECTED
......
package com.tarento.upsmf.examsAndAdmissions.model;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import lombok.Getter;
import lombok.Setter;
......
package com.tarento.upsmf.examsAndAdmissions.model;
import com.tarento.upsmf.examsAndAdmissions.enums.ExamCycleStatus;
import lombok.*;
import javax.persistence.*;
......@@ -46,12 +47,8 @@ public class ExamCycle {
@Enumerated(EnumType.STRING)
@Column(name = "status")
private Status status;
private ExamCycleStatus status;
@Column(name = "obsolete", nullable = false, columnDefinition = "int default 0")
private Integer obsolete = 0;
public enum Status {
PUBLISH, DRAFT
}
}
package com.tarento.upsmf.examsAndAdmissions.model;
import com.tarento.upsmf.examsAndAdmissions.enums.RetotallingStatus;
import lombok.*;
import javax.persistence.*;
......@@ -35,7 +36,7 @@ public class RetotallingRequest {
private LocalDate requestDate;
@Column(name = "status")
private String status; // PENDING, COMPLETED, etc.
private RetotallingStatus status;
@Column(name = "remarks")
private String remarks; // Any additional information or comments
......
package com.tarento.upsmf.examsAndAdmissions.model;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import lombok.*;
import javax.persistence.*;
......
package com.tarento.upsmf.examsAndAdmissions.model.dto;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.ExamCycle;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ExamCycleWithExamsDTO {
private ExamCycle examCycle;
private List<Exam> exams;
}
package com.tarento.upsmf.examsAndAdmissions.repository;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.RetotallingRequest;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface RetotallingRequestRepository extends JpaRepository<RetotallingRequest, Long> {
List<RetotallingRequest> findByStudentId(Long studentId);
boolean existsByStudent_EnrollmentNumberAndExams_Id(String enrolmentNumber, Long examId);
Optional<RetotallingRequest> findByStudentAndExams(Student student, Exam exam);
}
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.repository;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.VerificationStatus;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
......
package com.tarento.upsmf.examsAndAdmissions.service;
import com.tarento.upsmf.examsAndAdmissions.enums.ExamCycleStatus;
import com.tarento.upsmf.examsAndAdmissions.model.*;
import com.tarento.upsmf.examsAndAdmissions.repository.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Optional;
......@@ -28,11 +29,14 @@ public class ExamCycleService {
private CourseRepository courseRepository;
// Create a new exam cycle
public ExamCycle createExamCycle(ExamCycle examCycle) {
public ExamCycle createExamCycle(ExamCycle examCycle, String userId) {
log.info("Creating new ExamCycle: {}", examCycle);
if (examCycle != null && examCycle.getId() == null) {
examCycle.setObsolete(0);
examCycle.setCreatedOn(LocalDateTime.now());
examCycle.setStatus(ExamCycleStatus.DRAFT);
examCycle.setCreatedBy(userId);
examCycle = repository.save(examCycle);
}
......@@ -72,7 +76,7 @@ public class ExamCycleService {
}
// Update an existing exam cycle
public ExamCycle updateExamCycle(Long id, ExamCycle updatedExamCycle) {
public ExamCycle updateExamCycle(Long id, ExamCycle updatedExamCycle, String userId) {
log.info("Updating ExamCycle with ID: {}", id);
ExamCycle existingExamCycle = repository.findById(id).orElse(null);
if (existingExamCycle != null) {
......@@ -80,12 +84,12 @@ public class ExamCycleService {
existingExamCycle.setCourseId(updatedExamCycle.getCourseId());
existingExamCycle.setStartDate(updatedExamCycle.getStartDate());
existingExamCycle.setEndDate(updatedExamCycle.getEndDate());
existingExamCycle.setStatus(updatedExamCycle.getStatus());
//existingExamCycle.setStatus(updatedExamCycle.getStatus());
// Update auditing metadata
// Assuming you have a way to fetch the current user, e.g., a utility method
existingExamCycle.setModifiedBy(updatedExamCycle.getModifiedBy());
existingExamCycle.setModifiedOn(updatedExamCycle.getModifiedOn()); // Current date/time
existingExamCycle.setModifiedBy(userId);
existingExamCycle.setModifiedOn(LocalDateTime.now()); // Current date/time
return repository.save(existingExamCycle);
}
......@@ -116,7 +120,7 @@ public class ExamCycleService {
log.warn("ExamCycle with ID: {} not found for restoration!", id);
}
}
public ExamCycle addExamsToCycle(Long id, List<Exam> exams) {
public ExamCycle addExamsToCycle(Long id, List<Exam> exams, String userId) {
ExamCycle examCycle = repository.findById(id).orElse(null);
if (examCycle != null) {
for (Exam exam : exams) {
......@@ -138,6 +142,8 @@ public class ExamCycleService {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
exam.setStartTime(LocalTime.parse(exam.getStartTime().format(formatter)));
exam.setEndTime(LocalTime.parse(exam.getEndTime().format(formatter)));
exam.setCreatedBy(userId);
exam.setCreatedOn(LocalDateTime.now());
// Link exam to exam cycle
exam.setExamCycleId(examCycle.getId());
......@@ -158,4 +164,14 @@ public class ExamCycleService {
}
return null;
}
public ExamCycle publishExamCycle(Long id) {
Optional<ExamCycle> optionalExamCycle = repository.findById(id);
if(!optionalExamCycle.isPresent()) {
return null;
}
ExamCycle examCycle = optionalExamCycle.get();
examCycle.setStatus(ExamCycleStatus.PUBLISHED);
return repository.save(examCycle);
}
}
\ No newline at end of file
......@@ -6,13 +6,13 @@ import org.springframework.stereotype.Service;
@Service
public interface ExamService {
public ResponseDto createExam(Exam exam);
public ResponseDto createExam(Exam exam, String userId);
public ResponseDto getAllExams();
public ResponseDto getExamById(Long id);
public ResponseDto updateExam(Long id, Exam updatedExam);
public ResponseDto updateExam(Long id, Exam updatedExam, String userId);
public ResponseDto deleteExam(Long id);
......
package com.tarento.upsmf.examsAndAdmissions.service;
import com.tarento.upsmf.examsAndAdmissions.enums.RetotallingStatus;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.RetotallingRequest;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.dao.Payment;
import com.tarento.upsmf.examsAndAdmissions.repository.PaymentRepository;
import com.tarento.upsmf.examsAndAdmissions.repository.RetotallingRequestRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
public class RetotallingService {
@Autowired
......@@ -20,17 +26,42 @@ public class RetotallingService {
@Autowired
private PaymentRepository paymentRepository;
@Autowired
private StudentResultService studentResultService;
public void markRequestAsCompleted(Long requestId) {
RetotallingRequest request = retotallingRequestRepository.findById(requestId)
.orElseThrow(() -> new RuntimeException("Request not found."));
request.setStatus("Completed");
request.setStatus(RetotallingStatus.COMPLETED);
retotallingRequestRepository.save(request);
}
public RetotallingRequest requestRetotalling(RetotallingRequest request) {
request.setRequestDate(LocalDate.now());
request.setStatus("PENDING");
return retotallingRequestRepository.save(request);
public RetotallingRequest requestRetotalling(RetotallingRequest retotallingRequest) {
// Fetch the student from the database using the enrollmentNumber
Student existingStudent = studentResultService.fetchStudentByEnrollmentNumber(retotallingRequest.getStudent().getEnrollmentNumber());
if (existingStudent == null) {
throw new RuntimeException("Student not found.");
}
// Set the fetched student to the retotallingRequest
retotallingRequest.setStudent(existingStudent);
// Check for each exam
for (Exam exam : retotallingRequest.getExams()) {
// Check if payment was successful
if (!isPaymentSuccessful(existingStudent.getEnrollmentNumber(), exam.getId())) {
throw new RuntimeException("Payment not completed for exam ID: " + exam.getId() + ". Please make the payment before requesting re-totalling.");
}
// Check if a re-totalling request already exists
if (hasAlreadyRequestedRetotalling(existingStudent.getEnrollmentNumber(), exam.getId())) {
throw new RuntimeException("You have already requested re-totalling for exam ID: " + exam.getId());
}
}
// Save the re-totalling request
retotallingRequest.setRequestDate(LocalDate.now());
retotallingRequest.setStatus(RetotallingStatus.PENDING);
return retotallingRequestRepository.save(retotallingRequest);
}
public List<RetotallingRequest> getAllPendingRequests() {
......
......@@ -31,7 +31,7 @@ public class StudentExamRegistrationService {
@Autowired
private StudentRepository studentRepository;
@Transactional
public ResponseEntity<?> registerStudentsForExams(List<StudentExamRegistrationDTO> requests)
public ResponseEntity<?> registerStudentsForExams(List<StudentExamRegistrationDTO> requests, String userId)
{
// Validate input
if (requests == null || requests.isEmpty()) {
......@@ -112,8 +112,7 @@ public class StudentExamRegistrationService {
registration.setRegistrationDate(request.getRegistrationDate());
registration.setStatus(request.getStatus());
registration.setRemarks(request.getRemarks());
registration.setCreatedBy(request.getCreatedBy());
registration.setUpdatedBy(request.getUpdatedBy());
registration.setUpdatedBy(userId);
newRegistrations.add(registration);
});
......
package com.tarento.upsmf.examsAndAdmissions.service;
import com.tarento.upsmf.examsAndAdmissions.model.Course;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.StudentResult;
import com.tarento.upsmf.examsAndAdmissions.repository.CourseRepository;
import com.tarento.upsmf.examsAndAdmissions.repository.ExamRepository;
import com.tarento.upsmf.examsAndAdmissions.repository.StudentRepository;
import com.tarento.upsmf.examsAndAdmissions.repository.StudentResultRepository;
import com.tarento.upsmf.examsAndAdmissions.enums.ResultStatus;
import com.tarento.upsmf.examsAndAdmissions.enums.RetotallingStatus;
import com.tarento.upsmf.examsAndAdmissions.model.*;
import com.tarento.upsmf.examsAndAdmissions.repository.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.*;
......@@ -40,6 +36,8 @@ public class StudentResultService {
@Autowired
private ExamRepository examRepository;
@Autowired
private RetotallingRequestRepository retotallingRequestRepository;
public void importInternalMarksFromExcel(MultipartFile file) throws IOException {
// Parse the Excel file
......@@ -257,9 +255,15 @@ public class StudentResultService {
existingResult.setTotalMarksObtained(updatedResult.getTotalMarksObtained());
existingResult.setGrade(updatedResult.getGrade());
existingResult.setResult(updatedResult.getResult());
existingResult.setStatus(updatedResult.getStatus());
existingResult.setStatus(ResultStatus.REVALUATED);
studentResultRepository.save(existingResult);
// Update the RetotallingRequest status
RetotallingRequest retotallingRequest = retotallingRequestRepository.findByStudentAndExams(existingResult.getStudent(), updatedResult.getExam())
.orElseThrow(() -> new EntityNotFoundException("No RetotallingRequest found for student and exam"));
retotallingRequest.setStatus(RetotallingStatus.COMPLETED);
retotallingRequestRepository.save(retotallingRequest);
}
}
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