Browse Source

保存时处理子题场景

mingfu 4 weeks ago
parent
commit
f6fed5ca17
1 changed files with 12 additions and 1 deletions
  1. 12 1
      ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

+ 12 - 1
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -3,6 +3,7 @@ package com.ruoyi.web.service;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.util.DateUtils;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -129,7 +130,17 @@ public class ExamService {
         LearnAnswer aCond = new LearnAnswer();
         aCond.setExamineeId(answerSheet.getExamineeId());
         Map<Long, LearnAnswer> answerMap = learnAnswerMapper.selectLearnAnswerList(aCond).stream().collect(Collectors.toMap(LearnAnswer::getQuestionId, t -> t));
-        Map<Long, PaperVO.QuestionAnswer> questionMap = paperService.loadPaperQuestionAnswers(null, exitExaminee.getPaperId(), answerMap, true).stream().collect(Collectors.toMap(PaperVO.QuestionAnswer::getId, t -> t));
+        List<PaperVO.QuestionAnswer> qaList = paperService.loadPaperQuestionAnswers(null, exitExaminee.getPaperId(), answerMap, true);
+        Map<Long, PaperVO.QuestionAnswer> questionMap = Maps.newHashMap();
+        for(PaperVO.QuestionAnswer qa : qaList) {
+            if(CollectionUtils.isNotEmpty(qa.getSubQuestions())) {
+                for(PaperVO.QuestionAnswer sqa : qa.getSubQuestions()) {
+                    questionMap.put(sqa.getId(), qa);
+                }
+            } else {
+                questionMap.put(qa.getId(), qa);
+            }
+        }
 
         List<LearnAnswer> answersList = Lists.newArrayList();
         Integer wrongCount = 0;