|
|
@@ -519,8 +519,18 @@ public class AssignmentServiceImpl implements AssignmentService {
|
|
|
List<Engagement> allRecords = studentAssignmentMapper.selectList(
|
|
|
new QueryWrapper<Engagement>()
|
|
|
.eq("assignment_id", assignmentId)
|
|
|
- // 可以在此添加其他查询条件
|
|
|
+ .exists("""
|
|
|
+ SELECT 1
|
|
|
+ FROM assignment a
|
|
|
+ JOIN course_student cs ON cs.course_id = a.course_id
|
|
|
+ WHERE a.assignment_id = student_assignment.assignment_id
|
|
|
+ AND cs.student_id = student_assignment.student_id
|
|
|
+ """)
|
|
|
);
|
|
|
+ if (allRecords.isEmpty()) {
|
|
|
+ throw MyException.create(HttpStatus.BAD_REQUEST, "当前作业没有可批改的在课学生");
|
|
|
+ }
|
|
|
+
|
|
|
// 对记录进行排序:status为4或6的记录排到最后,其他记录保持原始顺序
|
|
|
List<Engagement> sortedList = allRecords.stream()
|
|
|
.sorted(Comparator.comparing(
|
|
|
@@ -535,7 +545,7 @@ public class AssignmentServiceImpl implements AssignmentService {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (currentIndex == allRecords.size() - 1 || currentIndex == -1) {
|
|
|
+ if (currentIndex == sortedList.size() - 1 || currentIndex == -1) {
|
|
|
return sortedList.get(0).getStudentId();
|
|
|
}
|
|
|
|
|
|
@@ -548,11 +558,7 @@ public class AssignmentServiceImpl implements AssignmentService {
|
|
|
if(assignment == null){
|
|
|
throw MyException.create(HttpStatus.BAD_REQUEST, "作业不存在");
|
|
|
}
|
|
|
- if(assignment.getEngageNumber() != null && assignment.getCorrectNumber() != null){
|
|
|
- return new EngageNumberVo(assignment.getEngageNumber(), assignment.getCorrectNumber());
|
|
|
- } else {
|
|
|
- throw MyException.create(HttpStatus.BAD_REQUEST, "未建立作业统计");
|
|
|
- }
|
|
|
+ return studentAssignmentMapper.countEngageNumberByCurrentClassStudents(assignmentId);
|
|
|
}
|
|
|
|
|
|
private Assignment convertToPO(AssignmentDTO assignmentDTO) {
|