| | |
| | | private final ExamPaperScoreMapper examPaperScoreMapper; |
| | | private final ExamPaperScoreService examPaperScoreService; |
| | | private static final String ANSWER_SPLIT = ","; |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | // 判断考试状态 |
| | | if (! ExamStatusEnum.NOT_START.equals(entity.getStatus())) { |
| | | if (!ExamStatusEnum.NOT_START.equals(entity.getStatus())) { |
| | | throw new RuntimeException("只能修改还未开始的考试"); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | |
| | | // 阅卷后才往exam_paper_answer保存考试成绩、以及保存到exam_paper_customer_answer |
| | | // 现在只需要保存到一张临时表 |
| | | // 该接口是主动提交,所以状态都设置为完成,以便后续老师阅卷 |
| | | saveTempExam(submitData, ExamSubmitTempStatusEnum.finish); |
| | | |
| | | //TODO:考试状态设定为结束 |
| | | |
| | | //TODO:暂时改为temp方便测试 |
| | | saveTempExam(submitData, ExamSubmitTempStatusEnum.temp); |
| | | return Result.ok(); |
| | | } |
| | | |
| | |
| | | Date now = new Date(); |
| | | one.setExamSubmit(JSON.toJSONString(submitData.getTitleList())); |
| | | one.setUpdateTime(now); |
| | | long doTimeL = now.getTime() - one.getCreateTime().getTime(); |
| | | Integer doTime = (int) doTimeL; |
| | | one.setDoTime(doTime); |
| | | int doTimeInSeconds = (int) (now.getTime() - one.getCreateTime().getTime()) / 1000; |
| | | one.setDoTime(doTimeInSeconds); |
| | | one.setStatus(status); |
| | | examSubmitTempMapper.updateById(one); |
| | | } else { |
| | |
| | | throw new RuntimeException("考试试卷不存在"); |
| | | } |
| | | List<ExamSubmitTemp> examSubmitTempList = new LambdaQueryChainWrapper<>(examSubmitTempMapper) |
| | | .eq(ExamSubmitTemp::getDeleted,0) |
| | | .eq(ExamSubmitTemp::getDeleted, 0) |
| | | .eq(ExamSubmitTemp::getExamId, id) |
| | | .list(); |
| | | // 参考人数 |
| | |
| | | // 参考但未完成提交人数 |
| | | Integer joinButNotFinishedNum = Math.toIntExact(examSubmitTempList.stream().filter(item -> ExamSubmitTempStatusEnum.temp.equals(item.getStatus())).count()); |
| | | |
| | | List<StudentExamInfoVO> studentExamList = classesUserMapper.getClassesUserList(exam.getClassesId()); |
| | | List<StudentExamInfoVO> studentExamList = classesUserMapper.getClassesUserList(exam.getId(), exam.getClassesId()); |
| | | // 应考人数 |
| | | Integer shouldUserNum = studentExamList.size(); |
| | | |
| | |
| | | if (StringUtils.isEmpty(doQuestionVO.getQuestionAnswer())) { |
| | | return Result.fail(SystemCode.InnerError.getCode(), "题目id为:" + doQuestionVO.getId() + "的题目缺少答案,请先完善"); |
| | | } |
| | | trueOrFalse(score,doQuestionVO, navbarVO, doQuestionVO.getQuestionAnswer().equals(doQuestionVO.getAnswer())); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, doQuestionVO.getQuestionAnswer().equals(doQuestionVO.getAnswer())); |
| | | } |
| | | /* 如果是多选 */ |
| | | else if (QuestionTypeEnum.MultipleChoice.getCode().equals(questionType)) { |
| | |
| | | List<String> questionAnswerList = Arrays.asList(questionAnswer.split(",")); |
| | | //学生答案为空,判断为错 |
| | | if (CollectionUtils.isEmpty(answerList)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, false); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, false); |
| | | num++; |
| | | navbar.add(navbarVO); |
| | | continue; |
| | |
| | | Set<String> set2 = new HashSet<>(questionAnswerList); |
| | | //答案完全一致,满分 |
| | | if (set1.equals(set2)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, true); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, true); |
| | | num++; |
| | | navbar.add(navbarVO); |
| | | continue; |
| | |
| | | } |
| | | //如果多选得分类型为 答错不得分 |
| | | if (Integer.valueOf(DeductTypeEnum.AllCorrect.getCode()).equals(paperMarkVO.getDeductType())) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, false); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, false); |
| | | } |
| | | //如果多选得分类型为 漏选得固定分值,包含错误选项不得分 |
| | | else if (Integer.valueOf(DeductTypeEnum.PartCorrect.getCode()).equals(paperMarkVO.getDeductType())) { |
| | | //学生答案移除所有正确答案,如果还有元素说明包含错误选项 |
| | | answerList.removeAll(questionAnswerList); |
| | | if (!CollectionUtils.isEmpty(answerList)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, false); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, false); |
| | | } else { |
| | | navbarVO.setRight(false); |
| | | doQuestionVO.setRight(false); |
| | | //漏选得固定分 |
| | | score = score.add(paperMarkVO.getDeductScore()); |
| | | doQuestionVO.setScore(paperMarkVO.getDeductScore()); |
| | | score = score.add(doQuestionVO.getScore()); |
| | | } |
| | | } |
| | | //如果多选得分类型为 每对一题得相应分值,包含错误选项不得分 |
| | |
| | | //学生答案移除所有正确答案,如果还有元素说明包含错误选项 |
| | | answerList.removeAll(questionAnswerList); |
| | | if (!CollectionUtils.isEmpty(answerList)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, false); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, false); |
| | | } else { |
| | | navbarVO.setRight(false); |
| | | doQuestionVO.setRight(false); |
| | | //漏选得分 |
| | | doQuestionVO.setScore(paperMarkVO.getDeductScore().multiply(new BigDecimal(answerCount))); |
| | | score = score.add(doQuestionVO.getScore()); |
| | | } |
| | | } |
| | | } |
| | |
| | | List<String> questionAnswerList = Arrays.asList(questionAnswer.split(",")); |
| | | //学生答案为空,判断为错 |
| | | if (CollectionUtils.isEmpty(answerList)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, false); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, false); |
| | | num++; |
| | | navbar.add(navbarVO); |
| | | continue; |
| | |
| | | int questionAnswerCount = questionAnswerList.size(); |
| | | //答案完全一致,满分 |
| | | if (answerList.equals(questionAnswerList)) { |
| | | trueOrFalse(score,doQuestionVO, navbarVO, true); |
| | | score = trueOrFalse(score, doQuestionVO, navbarVO, true); |
| | | } else { |
| | | navbarVO.setRight(false); |
| | | doQuestionVO.setRight(false); |
| | |
| | | //填空得分 |
| | | BigDecimal gapScore = scoreEach.multiply(new BigDecimal(count)); |
| | | doQuestionVO.setScore(gapScore); |
| | | score = score.add(doQuestionVO.getScore()); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | paperMarkVO.setTitleItems(titleItems); |
| | | paperMarkVO.setNavbar(navbar); |
| | | paperMarkVO.setScore(score + ""); |
| | | return null; |
| | | } |
| | | |
| | | //设置全对或全错 |
| | | private void trueOrFalse(BigDecimal score,DoQuestionVO doQuestionVO, ExamPaperMarkNavbarVO orderVO, Boolean isCorrect) { |
| | | private BigDecimal trueOrFalse(BigDecimal score, DoQuestionVO doQuestionVO, ExamPaperMarkNavbarVO orderVO, Boolean isCorrect) { |
| | | if (isCorrect) { |
| | | //正确 |
| | | orderVO.setRight(isCorrect); |
| | |
| | | doQuestionVO.setRight(isCorrect); |
| | | doQuestionVO.setScore(BigDecimal.ZERO); |
| | | } |
| | | return score; |
| | | } |
| | | |
| | | //封装阅卷返回数据 |
| | |
| | | long questionCorrect = 0; |
| | | long questionCount = 0; |
| | | if (!CollectionUtils.isEmpty(examPaperMark.getNavbar())) { |
| | | questionCorrect = examPaperMark.getNavbar().stream().filter(ExamPaperMarkNavbarVO::getRight).count(); |
| | | questionCorrect = examPaperMark.getNavbar().stream().filter(vo -> vo.getRight()!=null && vo.getRight()).count(); |
| | | questionCount = examPaperMark.getNavbar().size(); |
| | | } |
| | | examPaperScore.setQuestionCorrect(Integer.valueOf(questionCorrect + "")); |