Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
examsAndAdmissions
Commits
cc771b92
Unverified
Commit
cc771b92
authored
1 year ago
by
Ankit Verma
Committed by
GitHub
1 year ago
Browse files
Options
Download
Plain Diff
Merge pull request #34 from jaypratapsingh1/feature/exam_results_dev
Feature/exam results dev
parents
2da34575
e808ba6b
uri_access_check
Response_fixes
auxillary_apis
bug_fix_question_paper_upload
development
fee_changes
fee_workflow
github/fork/ruksana2808/filter_bug_examCycle
instituteApis_shishir
No related merge requests found
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamController.java
+5
-4
...o/upsmf/examsAndAdmissions/controller/ExamController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamCycleController.java
+34
-7
...mf/examsAndAdmissions/controller/ExamCycleController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentController.java
+1
-4
...psmf/examsAndAdmissions/controller/StudentController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentExamRegistrationController.java
+4
-2
...issions/controller/StudentExamRegistrationController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentResultController.java
+8
-30
...xamsAndAdmissions/controller/StudentResultController.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/enums/ExamCycleStatus.java
+5
-0
...rento/upsmf/examsAndAdmissions/enums/ExamCycleStatus.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/enums/RetotallingStatus.java
+6
-0
...nto/upsmf/examsAndAdmissions/enums/RetotallingStatus.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/enums/VerificationStatus.java
+1
-1
...to/upsmf/examsAndAdmissions/enums/VerificationStatus.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/DocumentVerification.java
+1
-0
.../upsmf/examsAndAdmissions/model/DocumentVerification.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCycle.java
+2
-5
...com/tarento/upsmf/examsAndAdmissions/model/ExamCycle.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/RetotallingRequest.java
+2
-1
...to/upsmf/examsAndAdmissions/model/RetotallingRequest.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/Student.java
+1
-0
...a/com/tarento/upsmf/examsAndAdmissions/model/Student.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamCycleWithExamsDTO.java
+18
-0
...f/examsAndAdmissions/model/dto/ExamCycleWithExamsDTO.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/RetotallingRequestRepository.java
+4
-0
...ndAdmissions/repository/RetotallingRequestRepository.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentRepository.java
+1
-1
...psmf/examsAndAdmissions/repository/StudentRepository.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCycleService.java
+23
-7
...to/upsmf/examsAndAdmissions/service/ExamCycleService.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamService.java
+2
-2
...tarento/upsmf/examsAndAdmissions/service/ExamService.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/RetotallingService.java
+37
-6
.../upsmf/examsAndAdmissions/service/RetotallingService.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentExamRegistrationService.java
+2
-3
...AndAdmissions/service/StudentExamRegistrationService.java
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java
+13
-9
...psmf/examsAndAdmissions/service/StudentResultService.java
with
170 additions
and
82 deletions
+170
-82
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamController.java
+
5
−
4
View file @
cc771b92
...
...
@@ -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
());
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/ExamCycleController.java
+
34
−
7
View file @
cc771b92
...
...
@@ -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
>
exam
s
,
@RequestAttribute
(
Constants
.
Parameters
.
USER_ID
)
String
userId
)
{
try
{
ExamCycle
examCycle
=
service
.
addExamsToCycle
(
id
,
exam
);
ExamCycle
examCycle
=
service
.
addExamsToCycle
(
id
,
exam
s
,
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
<>(
exam
s
,
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
<>();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentController.java
+
1
−
4
View file @
cc771b92
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentExamRegistrationController.java
+
4
−
2
View file @
cc771b92
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/controller/StudentResultController.java
+
8
−
30
View file @
cc771b92
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
re
totallingRe
quest
)
{
@PostMapping
(
"/re
questRe
totalling"
)
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."
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/enums/ExamCycleStatus.java
0 → 100644
+
5
−
0
View file @
cc771b92
package
com.tarento.upsmf.examsAndAdmissions.enums
;
public
enum
ExamCycleStatus
{
DRAFT
,
PUBLISHED
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/enums/RetotallingStatus.java
0 → 100644
+
6
−
0
View file @
cc771b92
package
com.tarento.upsmf.examsAndAdmissions.enums
;
public
enum
RetotallingStatus
{
PENDING
,
COMPLETED
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/
model
/VerificationStatus.java
→
src/main/java/com/tarento/upsmf/examsAndAdmissions/
enums
/VerificationStatus.java
+
1
−
1
View file @
cc771b92
package
com.tarento.upsmf.examsAndAdmissions.
model
;
package
com.tarento.upsmf.examsAndAdmissions.
enums
;
public
enum
VerificationStatus
{
PENDING
,
VERIFIED
,
CLOSED
,
REJECTED
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/DocumentVerification.java
+
1
−
0
View file @
cc771b92
package
com.tarento.upsmf.examsAndAdmissions.model
;
import
com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/ExamCycle.java
+
2
−
5
View file @
cc771b92
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
ExamCycle
Status
status
;
@Column
(
name
=
"obsolete"
,
nullable
=
false
,
columnDefinition
=
"int default 0"
)
private
Integer
obsolete
=
0
;
public
enum
Status
{
PUBLISH
,
DRAFT
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/RetotallingRequest.java
+
2
−
1
View file @
cc771b92
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
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/Student.java
+
1
−
0
View file @
cc771b92
package
com.tarento.upsmf.examsAndAdmissions.model
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus
;
import
lombok.*
;
import
javax.persistence.*
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/model/dto/ExamCycleWithExamsDTO.java
0 → 100644
+
18
−
0
View file @
cc771b92
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
;
}
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/RetotallingRequestRepository.java
+
4
−
0
View file @
cc771b92
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
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentRepository.java
+
1
−
1
View file @
cc771b92
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
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamCycleService.java
+
23
−
7
View file @
cc771b92
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
(
u
pdatedExamCycle
.
getModifiedBy
()
);
existingExamCycle
.
setModifiedOn
(
updatedExamCycle
.
getModifiedOn
());
// Current date/time
existingExamCycle
.
setModifiedBy
(
u
serId
);
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
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/ExamService.java
+
2
−
2
View file @
cc771b92
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/RetotallingService.java
+
37
−
6
View file @
cc771b92
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
()
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentExamRegistrationService.java
+
2
−
3
View file @
cc771b92
...
...
@@ -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
);
});
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java
+
13
−
9
View file @
cc771b92
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
(
updated
Result
.
get
Status
()
);
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
);
}
}
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets