yangfeng 1 rok temu
rodzic
commit
006487ef11

+ 22 - 1
web/src/main/java/com/ynfy/buss/exam/examreview/service/impl/ExamReviewServiceImpl.java

@@ -123,8 +123,29 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
                 resultList.add(userExamQuestion);
                 subjectiveScore += o.getActualScore();
             }
+            //组合题
+            List<UserExamQuestion> combinationQuestionList = rootQuestionList.stream().filter(q ->
+                    QuestionType.COMBINATION.getCode().equals(q.getQuestionType())).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(combinationQuestionList)) {
+                combinationQuestionList.forEach(question -> {
+                    //组合题子题目中包含简答题,重新计算分值
+                    long simpleCount = question.getSubQuestionList().stream().filter(q -> QuestionType.SIMPLE.getCode()
+                            .equals(q.getQuestionType())).count();
+                    if (simpleCount > 0) {
+                        question.setActualScore(question.getSubQuestionList().stream().filter(o ->
+                                !Objects.isNull(o.getActualScore())).mapToInt(UserExamQuestion::getActualScore).sum());
+                        if (question.getActualScore() > 0) {
+                            question.setIsRight(true);
+                        } else {
+                            question.setIsRight(false);
+                        }
+                        resultList.add(question);
+                    }
+                });
+            }
+
             //更新评分
-            if(!CollectionUtils.isEmpty(resultList)){
+            if (!CollectionUtils.isEmpty(resultList)) {
                 userExamQuestionService.updateBatchById(resultList);
             }