| | |
| | | if (Objects.isNull(exam.getExamPaperId())) { |
| | | throw new RuntimeException("考试未绑定试卷"); |
| | | } |
| | | if (ExamStatusEnum.NOT_START.equals(exam.getStatus())) { |
| | | throw new RuntimeException("考试还未开始"); |
| | | } |
| | | if (ExamStatusEnum.FINISHED.equals(exam.getStatus())) { |
| | | throw new RuntimeException("考试已经结束"); |
| | | } |
| | | // 查出考试试卷 |
| | | ExamPaper examPaper = examPaperMapper.selectById(exam.getExamPaperId()); |
| | | if (Objects.isNull(examPaper)) { |
| | |
| | | } |
| | | // 转换 |
| | | 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); |
| | | } |
| | | return Result.ok(examData); |
| | | } |
| | | return Result.ok(); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | private List<PaperFixQuestionVO> coverTo(ExamPaper examPaper) { |
| | | if (! StringUtils.hasText(examPaper.getContent())) { |
| | | throw new RuntimeException("试卷未配置题目,请联系老师"); |
| | | } |
| | | List<PaperFixQuestionDTO> questionWarpList = JSON.parseArray(examPaper.getContent(), PaperFixQuestionDTO.class); |
| | | return questionWarpList.stream().map(item -> { |
| | | PaperFixQuestionVO vo = new PaperFixQuestionVO(); |
| | |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | /** |
| | | * 主动提交试卷 |
| | | * |
| | | * @param submitData 试卷做题提交数据 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result examSubmit(ExamSubmitVO submitData) { |
| | | // 校验 |
| | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 临时保存试卷 |
| | | * |
| | | * @param submitData |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result timingSubmit(ExamSubmitVO submitData) { |
| | | saveTempExam(submitData, ExamSubmitTempStatusEnum.TEMP); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存临时试卷 |
| | | * 保存试卷:如果接口是定时保存那么是临时试卷。如果接口是自主提交那么是完成试卷 |
| | | * |
| | | * @param submitData 前端传递的试卷数据 |
| | | * @param status 试卷的状态 |