xiangpei
2024-06-26 2314da06436cd5c5b15c9a5fdf2a1634a90f04f5
随机试卷开始考试也是基于小标题
1个文件已修改
19 ■■■■■ 已修改文件
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
@@ -165,7 +165,6 @@
            }
            // 转换
            List<PaperFixQuestionVO> data = this.coverTo(examPaper);
            return Result.ok().data(data);
        } else if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) {
            // 根据随机试卷的配置,随机生成对应题目
@@ -173,8 +172,13 @@
                throw new RuntimeException("试卷配置异常,请联系老师");
            }
            List<PaperQuestionSettingDTO> paperSettingList = JSON.parseArray(examPaper.getContent(), PaperQuestionSettingDTO.class);
            List<DoQuestionVO> questionList = new ArrayList<>(24);
            // 试卷内容
            List<PaperFixQuestionVO> examData = new ArrayList<>(8);
            for (PaperQuestionSettingDTO paperSetting : paperSettingList) {
                PaperFixQuestionVO paperFixQuestionVO = new PaperFixQuestionVO();
                paperFixQuestionVO.setTitle(paperSetting.getTitle());
                paperFixQuestionVO.setQuestionType(paperSetting.getQuestionType());
                // 拿到课目下某类题型的x道随机题
                List<Question> questions = questionMapper.getRandomQuestion(examPaper.getSubjectId(), paperSetting.getQuestionType(), paperSetting.getNum());
                if (paperSetting.getNum() > questions.size()) {
@@ -194,16 +198,9 @@
                    doQuestionVO.setAudioFile(item.getAudioFile());
                    return doQuestionVO;
                }).collect(Collectors.toList());
                questionList.addAll(childQuestions);
                paperFixQuestionVO.setQuestionList(childQuestions);
                examData.add(paperFixQuestionVO);
            }
            // 保持随机试卷和固定试卷的格式一致
            List<PaperFixQuestionVO> examData = new ArrayList<>(1);
            PaperFixQuestionVO paperFixQuestionVO = new PaperFixQuestionVO();
            paperFixQuestionVO.setQuestionList(questionList);
            paperFixQuestionVO.setTitle("");
            paperFixQuestionVO.setQuestionType(null);
            examData.add(paperFixQuestionVO);
            return Result.ok(examData);
        }
        return Result.ok();