| | |
| | | return RestResponse.ok(list); |
| | | } else if (PracticeTypeEnum.RANDOM.getValue().equals(en.getPracticeType())) { |
| | | // 随机练习,是一道题一道题练习 |
| | | List<QuestionVO> one = questionSubjectMapper.getRandomQuestionId(subjectIds, 1); |
| | | List<QuestionVO> one = questionSubjectMapper.getRandomQuestionId(subjectIds, PracticeQuestionTypeEnum.getDataBaseValueByValue(en.getQuestionType()), 1); |
| | | if (one.size() < 1) { |
| | | throw new RuntimeException("没有找到题目,可能所选课目包含题目不足"); |
| | | } |
| | | return RestResponse.ok(one.get(0)); |
| | | QuestionVO questionVO = one.get(0); |
| | | jsonQuestion(questionVO); |
| | | return RestResponse.ok(questionVO); |
| | | } |
| | | return RestResponse.ok(); |
| | | } |
| | |
| | | throw new RuntimeException("练习不存在"); |
| | | } |
| | | List<Integer> subjectIds = JSON.parseArray(en.getSubjects(), Integer.class); |
| | | List<QuestionVO> one = questionSubjectMapper.getRandomQuestionId(subjectIds, 1); |
| | | List<QuestionVO> one = questionSubjectMapper.getRandomQuestionId(subjectIds, PracticeQuestionTypeEnum.getDataBaseValueByValue(en.getQuestionType()), 1); |
| | | if (one.size() < 1) { |
| | | throw new RuntimeException("没有找到题目,可能所选课目包含题目不足"); |
| | | } |
| | | QuestionVO questionVO = one.get(0); |
| | | jsonQuestion(questionVO); |
| | | |
| | | return RestResponse.ok(questionVO); |
| | | } |
| | | |
| | | /** |
| | | * 处理题目内容JSON |
| | | * |
| | | * @param questionVO |
| | | */ |
| | | public void jsonQuestion(QuestionVO questionVO) { |
| | | if (StringUtils.hasText(questionVO.getContentJson())) { |
| | | QuestionContentVO questionContent = JSON.parseObject(questionVO.getContentJson(), QuestionContentVO.class); |
| | | questionVO.setContent(questionContent); |
| | | } |
| | | if (QuestionTypeEnum.MultipleChoice.getCode().equals(questionVO.getQuestionType())) { |
| | | // 多选题需要返回答案数量,学员选中对应数量才查询答案 |
| | | if (StringUtils.hasText(questionVO.getCorrect())) { |
| | |
| | | questionVO.setCorrect(""); |
| | | questionVO.getContent().setCorrect(""); |
| | | questionVO.getContent().setAnalyze(""); |
| | | return RestResponse.ok(questionVO); |
| | | } |
| | | |
| | | /** |
| | | * 处理题目内容JSON |
| | | * |
| | | * @param vo |
| | | */ |
| | | public void jsonQuestion(QuestionVO vo) { |
| | | if (StringUtils.hasText(vo.getContentJson())) { |
| | | QuestionContentVO questionContent = JSON.parseObject(vo.getContentJson(), QuestionContentVO.class); |
| | | vo.setContent(questionContent); |
| | | } |
| | | } |
| | | } |