Browse Source

保存答案时判断已有答案错误

mingfu 1 month ago
parent
commit
d3e7a4db40

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

@@ -181,7 +181,7 @@ public class ExamService {
                              List<LearnAnswer> addList, List<LearnAnswer> updateList) {
         LearnAnswer answer = new LearnAnswer();
         PaperVO.QuestionAnswer exist = questionMap.remove(question.getId());
-        if(null == exist) {
+        if(null == exist || null == exist.getAnswerId()) {
             answer.setExamineeId(answerSheet.getExamineeId());
             answer.setStudentId(SecurityUtils.getUserId());
             answer.setQuestionId(question.getId());

+ 2 - 2
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnQuestionsServiceImpl.java

@@ -115,9 +115,9 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
             map.put("userId", userId);
             map.put("ids", ids);
             List<LearnQuestions> collectInfos = learnQuestionsMapper.selectCollectInfo(map);
-//            Set<Long> collected = collectInfos.stream().map(LearnQuestions::getId).collect(Collectors.toSet());
+            Set<Long> collected = collectInfos.stream().map(LearnQuestions::getId).collect(Collectors.toSet());
             questions.forEach(e -> {
-                e.setCollect(true);
+                e.setCollect(collected.contains(e.getId()));
             });
         }
     }