|
@@ -110,25 +110,39 @@ public class MarkPaperServiceImpl extends ServiceImpl<MarkPaperMapper, MarkPaper
|
|
|
public Boolean finishPaper(Long examId, List<String> paperNumbers, MarkPaperStatus status) {
|
|
|
for (String paperNumber : paperNumbers) {
|
|
|
MarkPaper markPaper = this.getByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
- String courseInfo = String.format("%s[%s],试卷编号%s,", markPaper.getCourseName(), markPaper.getCourseCode(), markPaper.getPaperNumber());
|
|
|
- // 主观题是否全部分组
|
|
|
- List<MarkQuestion> markQuestionObjectiveList = markQuestionService.listQuestionByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, null, true);
|
|
|
- if (CollectionUtils.isNotEmpty(markQuestionObjectiveList)) {
|
|
|
- if (markQuestionObjectiveList.stream().filter(m -> StringUtils.isBlank(m.getAnswer())).count() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(courseInfo + "客观题标答未设置,无法结束评卷");
|
|
|
+ if (MarkPaperStatus.FINISH.equals(status)) {
|
|
|
+ String courseInfo = String.format("%s[%s],试卷编号%s,", markPaper.getCourseName(), markPaper.getCourseCode(), markPaper.getPaperNumber());
|
|
|
+ // 主观题是否全部分组
|
|
|
+ List<MarkQuestion> markQuestionObjectiveList = markQuestionService.listQuestionByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, null, true);
|
|
|
+ if (CollectionUtils.isNotEmpty(markQuestionObjectiveList)) {
|
|
|
+ if (markQuestionObjectiveList.stream().filter(m -> StringUtils.isBlank(m.getAnswer())).count() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(courseInfo + "客观题标答未设置,无法结束评卷");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 主观题是否全部分组
|
|
|
- List<MarkQuestion> markQuestionSubjectiveList = markQuestionService.listQuestionByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, null, false);
|
|
|
- // 没有主观题,不校验考生评卷
|
|
|
- if (CollectionUtils.isNotEmpty(markQuestionSubjectiveList)) {
|
|
|
- if (markQuestionSubjectiveList.stream().filter(m -> m.getGroupNumber() == null).count() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(courseInfo + "主观题未全部分组,无法结束评卷");
|
|
|
+ // 主观题是否全部分组
|
|
|
+ List<MarkQuestion> markQuestionSubjectiveList = markQuestionService.listQuestionByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, null, false);
|
|
|
+ // 没有主观题,不校验考生评卷
|
|
|
+ if (CollectionUtils.isNotEmpty(markQuestionSubjectiveList)) {
|
|
|
+ if (markQuestionSubjectiveList.stream().filter(m -> m.getGroupNumber() == null).count() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(courseInfo + "主观题未全部分组,无法结束评卷");
|
|
|
+ }
|
|
|
+ // 未缺考、未违约且已上传图片的考生全部评完
|
|
|
+ if (markStudentService.countUnmarkByExamIdAndPaperNumber(examId, paperNumber) > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(courseInfo + "考生未全部评完,无法结束评卷");
|
|
|
+ }
|
|
|
}
|
|
|
- // 未缺考、未违约且已上传图片的考生全部评完
|
|
|
- if (markStudentService.countUnmarkByExamIdAndPaperNumber(examId, paperNumber) > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(courseInfo + "考生未全部评完,无法结束评卷");
|
|
|
+
|
|
|
+ // 结束评卷时,客观题统分
|
|
|
+ List<MarkStudent> markStudentList = markStudentService.listByExamIdAndCoursePaperId(examId, markPaper.getCoursePaperId());
|
|
|
+ for (MarkStudent markStudent : markStudentList) {
|
|
|
+ markStudentService.calculateObjectiveScore(markStudent);
|
|
|
+ UpdateWrapper<MarkStudent> objectiveUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ objectiveUpdateWrapper.lambda().set(MarkStudent::getObjectiveScore, markStudent.getObjectiveScore())
|
|
|
+ .set(MarkStudent::getObjectiveScoreList, markStudent.getObjectiveScoreList())
|
|
|
+ .eq(MarkStudent::getId, markStudent.getId());
|
|
|
+ markStudentService.update(objectiveUpdateWrapper);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -137,14 +151,6 @@ public class MarkPaperServiceImpl extends ServiceImpl<MarkPaperMapper, MarkPaper
|
|
|
.eq(MarkPaper::getExamId, examId)
|
|
|
.eq(MarkPaper::getPaperNumber, paperNumber);
|
|
|
this.update(updateWrapper);
|
|
|
-
|
|
|
- // 结束评卷时,客观题统分
|
|
|
- if (MarkPaperStatus.FINISH.equals(status)) {
|
|
|
- List<MarkStudent> markStudentList = markStudentService.listByExamIdAndCoursePaperId(examId, markPaper.getCoursePaperId());
|
|
|
- for (MarkStudent markStudent : markStudentList) {
|
|
|
- markStudentService.saveUploadStudent(markStudent);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
return true;
|