Skip to content

Commit

Permalink
fix: abnormal submission status
Browse files Browse the repository at this point in the history
  • Loading branch information
hui1601 committed Feb 15, 2025
1 parent e75deae commit 49c654c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/com/example/newsper/api/AssignmentApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,21 @@ public ResponseEntity<?> grade(

private List<AssignmentListDto> getProgress(List<AssignmentListDto> dtos, String userId) {
for (AssignmentListDto dto : dtos) {
SubmitEntity submitEntity = submitService.findByUserId(userId);
Date date = new Date();
SubmitEntity submitEntity = submitService.findByAssignmentIdAndUserId(dto.getAssignmentId(), userId);
if (submitEntity != null) {
if (submitEntity.getScore() != null) {
dto.setProgress(AssignmentStatus.GRADED.getStatus());
}
else {
dto.setProgress(AssignmentStatus.SUBMITTED.getStatus());
}
continue;
}
if (date.getTime() >= dto.getDeadline().getTime()) {
dto.setProgress(AssignmentStatus.ENDED.getStatus());
} else {
if (submitEntity != null && submitEntity.getAssignmentId().equals(dto.getAssignmentId())) {
if (submitEntity.getScore() != null)
dto.setProgress(AssignmentStatus.GRADED.getStatus());
else
dto.setProgress(AssignmentStatus.SUBMITTED.getStatus());
} else {
dto.setProgress(AssignmentStatus.PROGRESS.getStatus());
}
dto.setProgress(AssignmentStatus.PROGRESS.getStatus());
}
}
return dtos;
Expand Down

0 comments on commit 49c654c

Please sign in to comment.