| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.base.SystemCode; |
| | |
| | | import com.ycl.jxkg.enums.ExamPaperTypeEnum; |
| | | import com.ycl.jxkg.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.enums.WebsocketCommendEnum; |
| | | import com.ycl.jxkg.enums.general.ClassesStatusEnum; |
| | | import com.ycl.jxkg.enums.general.ExamStatusEnum; |
| | | import com.ycl.jxkg.enums.general.ExamSubmitTempStatusEnum; |
| | | import com.ycl.jxkg.mapper.*; |
| | |
| | | throw new RuntimeException("只能修改还未开始的考试"); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), null)); |
| | | entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), new Date())); |
| | | // 如果修改成功发送mq消息 |
| | | if (baseMapper.updateById(entity) > 0) { |
| | | this.sendMQ(entity, entity.getUpdateVersion()); |
| | |
| | | item.setExamPaperId(null); |
| | | } |
| | | }); |
| | | // |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) |
| | | .one(); |
| | | if (Objects.nonNull(hasJoin)) { |
| | | //TODO:开发环境先关闭 |
| | | // if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){ |
| | | // throw new RuntimeException("您已提交试卷,请勿重复作答"); |
| | | // } |
| | | // 允许提交后继续作答 |
| | | if(ExamSubmitTempStatusEnum.finish.equals(hasJoin.getStatus())){ |
| | | throw new RuntimeException("您已提交试卷,请勿重复作答"); |
| | | } |
| | | StartExamVO startExamVO = new StartExamVO(); |
| | | startExamVO.setExamName(exam.getExamName()); |
| | | startExamVO.setId(hasJoin.getExamId()); |
| | |
| | | ExamSubmitTemp one = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getExamId, submitData.getId()) |
| | | .eq(ExamSubmitTemp::getUserId, webContext.getCurrentUser().getId()) |
| | | .eq(ExamSubmitTemp::getDeleted, 0) |
| | | .one(); |
| | | |
| | | if (Objects.nonNull(one)) { |
| | |
| | | for (PaperFixQuestionVO titleItem : titleItems) { |
| | | for (DoQuestionVO doQuestionVO : titleItem.getQuestionList()) { |
| | | Integer questionId = doQuestionVO.getId(); |
| | | Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst(); |
| | | if (first.isPresent()) { |
| | | QuestionAnswerCopyVO answerCopyVO = first.get(); |
| | | doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect()); |
| | | doQuestionVO.setAnalyze(answerCopyVO.getAnalyze()); |
| | | doQuestionVO.setDifficult(answerCopyVO.getDifficult()); |
| | | if(questionId!=null) { |
| | | Optional<QuestionAnswerCopyVO> first = answerList.stream().filter(answer -> questionId.equals(answer.getId())).findFirst(); |
| | | if (first.isPresent()) { |
| | | QuestionAnswerCopyVO answerCopyVO = first.get(); |
| | | doQuestionVO.setQuestionAnswer(answerCopyVO.getCorrect()); |
| | | doQuestionVO.setAnalyze(answerCopyVO.getAnalyze()); |
| | | doQuestionVO.setDifficult(answerCopyVO.getDifficult()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public Result monitorList(ExamQuery query) { |
| | | IPage<ExamSubmitTempVO> page = PageUtil.getPage(query, ExamSubmitTempVO.class); |
| | | return Result.ok((examSubmitTempMapper.monitorList(page, query))); |
| | | IPage<ExamSubmitTempVO> vo = examSubmitTempMapper.monitorList(page, query); |
| | | |
| | | return Result.ok(vo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | form.setAddTimeM(sed); |
| | | websocket.setData(form); |
| | | // 发送websocket消息 |
| | | websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(form)); |
| | | websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(websocket)); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | |
| | | websocket.setCommend(WebsocketCommendEnum.FORCE_SUBMIT.getCommand()); |
| | | websocket.setData(form); |
| | | // 发送websocket消息 |
| | | websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(form)); |
| | | websocketServer.sendOneMessage(form.getUserId(), JSON.toJSONString(websocket)); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 作废 |
| | | * |
| | | * @param id |
| | | * @return {@link Result } |
| | | * @author |
| | | */ |
| | | @Override |
| | | public Result cancel(Integer id) { |
| | | new LambdaUpdateChainWrapper<>(examMapper) |
| | | .eq(Exam::getId, id) |
| | | .set(Exam::getStatus, ExamStatusEnum.CANCEL) |
| | | .update(); |
| | | return Result.ok("作废成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result recover(Integer id) { |
| | | // 先查询当前考试记录的详细信息 |
| | | Exam examInfo = new LambdaQueryChainWrapper<>(examMapper) |
| | | .eq(Exam::getId, id) |
| | | .one(); |
| | | // 确定恢复后当前考试记录的状态 |
| | | Date currentTime = new Date(); |
| | | Date startTime = examInfo.getStartTime(); |
| | | Date endTime = examInfo.getEndTime(); |
| | | ExamStatusEnum statusByTime = ExamStatusEnum.getStatusByTime(startTime, endTime, currentTime); |
| | | examInfo.setStatus(statusByTime); |
| | | // 修改当前的考试状态 |
| | | new LambdaUpdateChainWrapper<>(examMapper) |
| | | .eq(Exam::getId, id) |
| | | .set(Exam::getStatus, examInfo.getStatus()) |
| | | .update(); |
| | | // 还原班级的考试信息 |
| | | return Result.ok("考试记录已经恢复正常"); |
| | | } |
| | | } |