| | |
| | | } |
| | | // 转换 |
| | | List<PaperFixQuestionVO> data = this.coverTo(examPaper); |
| | | |
| | | return Result.ok().data(data); |
| | | } else if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) { |
| | | // 根据随机试卷的配置,随机生成对应题目 |
| | |
| | | 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()) { |
| | |
| | | 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(); |