Ver código fonte

在线练习

yangfeng 1 ano atrás
pai
commit
8aa7af2dba

+ 1 - 1
web/src/main/java/com/ynfy/buss/practice/userpractice/entity/dto/PracticeQuestionDTO.java

@@ -34,7 +34,7 @@ public class PracticeQuestionDTO {
     /**
      * 题目序号
      */
-    private Integer questionIndex;
+    private String questionIndex;
 
     /**
      * 填空题答案

+ 6 - 2
web/src/main/java/com/ynfy/buss/practice/userpractice/service/impl/UserPracticeServiceImpl.java

@@ -133,9 +133,13 @@ public class UserPracticeServiceImpl extends ServiceImpl<UserPracticeMapper, Use
             questionList = questionService.listByIds(questionIdList);
         }
         questionService.setQuestionAnswer(questionList);
-        Map<String, Question> questionMap = questionList.stream().collect(Collectors.toMap(Question::getId, a -> a, (k1, k2) -> k1));
+
+        Map<String, Question> questionMap = null;
+        if (!CollectionUtils.isEmpty(questionList)) {
+            questionMap = questionList.stream().collect(Collectors.toMap(Question::getId, a -> a, (k1, k2) -> k1));
+        }
         for (UserPracticeQuestion userPracticeQuestion : userPracticeQuestionList) {
-            if (!Objects.isNull(questionMap.get(userPracticeQuestion.getQuestionId()))) {
+            if (!Objects.isNull(questionMap) && !Objects.isNull(questionMap.get(userPracticeQuestion.getQuestionId()))) {
                 Question question = questionMap.get(userPracticeQuestion.getQuestionId());
                 //渲染填空题的题干,填充进答案
                 if (QuestionType.BLANK.getCode().equals(userPracticeQuestion.getQuestionType())) {