|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamStudentFinalScoreRepo;
|
|
@@ -107,34 +108,42 @@ public class ExamStudentFinalScoreServiceImpl implements ExamStudentFinalScoreSe
|
|
|
/**
|
|
|
* 计算得出最终有效成绩
|
|
|
*/
|
|
|
- private ExamScoreEntity getFinalEffectiveExamScore(List<ExamRecordDataEntity> effectiveExamRecordList, String examType, String markingType) {
|
|
|
- if (effectiveExamRecordList == null || effectiveExamRecordList.size() == 0) {
|
|
|
+ private ExamScoreEntity getFinalEffectiveExamScore(List<ExamRecordDataEntity> examRecords, String examType, String markingType) {
|
|
|
+ if (examRecords == null || examRecords.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ if (examType == null) {
|
|
|
+ throw new StatusException("examType is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (markingType == null) {
|
|
|
+ throw new StatusException("markingType is null");
|
|
|
+ }
|
|
|
+
|
|
|
//取出有效记录的id
|
|
|
- List<Long> examRecordDataIds = effectiveExamRecordList.stream().map(ExamRecordDataEntity::getId).collect(Collectors.toList());
|
|
|
+ List<Long> examRecordDataIds = examRecords.stream().map(ExamRecordDataEntity::getId).collect(Collectors.toList());
|
|
|
|
|
|
- List<ExamScoreEntity> effectiveExamScoreList = examScoreRepo.findByExamRecordDataIdIn(examRecordDataIds);
|
|
|
- if (effectiveExamScoreList == null || effectiveExamScoreList.size() == 0) {
|
|
|
- LOG.warn("effectiveExamScoreList is empty, examRecordDataIds = {}", examRecordDataIds);
|
|
|
+ List<ExamScoreEntity> examScoreList = examScoreRepo.findByExamRecordDataIdIn(examRecordDataIds);
|
|
|
+ if (examScoreList == null || examScoreList.isEmpty()) {
|
|
|
+ LOG.warn("examScoreList is empty, examRecordDataIds = {}", examRecordDataIds);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
//离线考试
|
|
|
if (ExamType.OFFLINE.name().equals(examType)) {
|
|
|
- return effectiveExamScoreList.get(0);
|
|
|
+ return examScoreList.get(0);
|
|
|
}
|
|
|
|
|
|
if (markingType.equals(MarkingType.ALL.name()) || markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
|
|
|
//全部评阅规则或客观分最高规则:取总分最高
|
|
|
- List<ExamScoreEntity> examScores = effectiveExamScoreList.stream()
|
|
|
+ List<ExamScoreEntity> examScores = examScoreList.stream()
|
|
|
.sorted((o1, o2) -> o2.getTotalScore().compareTo(o1.getTotalScore()))
|
|
|
.collect(Collectors.toList());
|
|
|
return examScores.get(0);
|
|
|
} else if (markingType.equals(MarkingType.LAST_SUBMIT.name())) {
|
|
|
//最后一次提交规则:取最后一次的成绩
|
|
|
- List<ExamScoreEntity> examScores = effectiveExamScoreList.stream()
|
|
|
+ List<ExamScoreEntity> examScores = examScoreList.stream()
|
|
|
.sorted((o1, o2) -> o2.getId().compareTo(o1.getId()))
|
|
|
.collect(Collectors.toList());
|
|
|
return examScores.get(0);
|