| | |
| | | import com.ycl.jxkg.domain.question.QuestionObject; |
| | | import com.ycl.jxkg.domain.vo.*; |
| | | import com.ycl.jxkg.enums.ExamPaperTypeEnum; |
| | | import com.ycl.jxkg.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.enums.WebsocketCommendEnum; |
| | | import com.ycl.jxkg.enums.general.ExamStatusEnum; |
| | | import com.ycl.jxkg.enums.general.ExamSubmitTempStatusEnum; |
| | |
| | | if (Objects.isNull(examPaper)) { |
| | | throw new RuntimeException("试卷不存在"); |
| | | } |
| | | // 如果已经参加过考试,直接返回数据 |
| | | ExamSubmitTemp hasJoin = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, id) |
| | | .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) |
| | | .one(); |
| | | if (Objects.nonNull(hasJoin)) { |
| | | StartExamVO startExamVO = new StartExamVO(); |
| | | startExamVO.setExamName(exam.getExamName()); |
| | | startExamVO.setId(hasJoin.getExamId()); |
| | | startExamVO.setTitleList(JSON.parseArray(hasJoin.getExamSubmit(), PaperFixQuestionVO.class)); |
| | | startExamVO.setSuggestTime(examPaper.getSuggestTime()); |
| | | startExamVO.setDoTime(hasJoin.getDoTime()); |
| | | return Result.ok(startExamVO); |
| | | } |
| | | // 将题目转换为可临时保存的题目结构。固定试卷和随序试卷的题目是直接保存到content字段的 |
| | | if (ExamPaperTypeEnum.Fixed.getCode().equals(examPaper.getPaperType()) |
| | | || ExamPaperTypeEnum.RandomOrder.getCode().equals(examPaper.getPaperType())) { |
| | |
| | | DoQuestionVO doQuestionVO = new DoQuestionVO(); |
| | | doQuestionVO.setTitle(question.getTitle()); |
| | | doQuestionVO.setQuestionType(item.getQuestionType()); |
| | | // 填空题需要抹除content(因为是答案) |
| | | if (QuestionTypeEnum.GapFilling.getCode().equals(doQuestionVO.getQuestionType())) { |
| | | question.getItems().stream().forEach(option -> { |
| | | option.setContent(""); |
| | | }); |
| | | } |
| | | doQuestionVO.setQuestionItemList(question.getItems()); |
| | | doQuestionVO.setId(question.getId()); |
| | | doQuestionVO.setOriginalFile(question.getOriginalFile()); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result examSubmit(ExamSubmitVO submitData) { |
| | | public Result examSubmit(StartExamVO submitData) { |
| | | // 校验 |
| | | Exam exam = examMapper.selectById(submitData.getExamId()); |
| | | Exam exam = examMapper.selectById(submitData.getId()); |
| | | if (Objects.isNull(exam)) { |
| | | throw new RuntimeException("该考试不存在"); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result timingSubmit(ExamSubmitVO submitData) { |
| | | public Result timingSubmit(StartExamVO submitData) { |
| | | saveTempExam(submitData, ExamSubmitTempStatusEnum.TEMP); |
| | | return Result.ok(); |
| | | } |
| | |
| | | * @param submitData 前端传递的试卷数据 |
| | | * @param status 试卷的状态 |
| | | */ |
| | | public void saveTempExam(ExamSubmitVO submitData, ExamSubmitTempStatusEnum status) { |
| | | public void saveTempExam(StartExamVO submitData, ExamSubmitTempStatusEnum status) { |
| | | ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, submitData.getExamId()) |
| | | .eq(ExamSubmitTemp::getExamId, submitData.getId()) |
| | | .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) |
| | | .one(); |
| | | if (Objects.nonNull(one)) { |
| | |
| | | return; |
| | | } |
| | | one.setDoTime(submitData.getDoTime()); |
| | | one.setExamSubmit(JSON.toJSONString(submitData.getPaperQuestionList())); |
| | | one.setExamSubmit(JSON.toJSONString(submitData.getTitleList())); |
| | | one.setCreateTime(new Date()); |
| | | one.setStatus(status); |
| | | examSubmitTempMapper.updateById(one); |
| | | } else { |
| | | ExamSubmitTemp examSubmitTemp = new ExamSubmitTemp(); |
| | | examSubmitTemp.setExamId(submitData.getExamId()); |
| | | examSubmitTemp.setExamId(submitData.getId()); |
| | | examSubmitTemp.setDoTime(submitData.getDoTime()); |
| | | examSubmitTemp.setStatus(status); |
| | | examSubmitTemp.setUserId(webContext.getCurrentUser().getId()); |
| | | examSubmitTemp.setExamSubmit(JSON.toJSONString(submitData.getPaperQuestionList())); |
| | | examSubmitTemp.setExamSubmit(JSON.toJSONString(submitData.getTitleList())); |
| | | examSubmitTemp.setMarkPaperStatus(ExamSubmitTempStatusEnum.TEMP); |
| | | examSubmitTempMapper.insert(examSubmitTemp); |
| | | } |
| | |
| | | @Override |
| | | public Result monitorList(ExamQuery query) { |
| | | IPage<ExamSubmitTempVO> page = PageUtil.getPage(query, ExamSubmitTempVO.class); |
| | | return Result.ok().data(examSubmitTempMapper.monitorList(page, query)); |
| | | return Result.ok((examSubmitTempMapper.monitorList(page, query))); |
| | | } |
| | | |
| | | @Override |