|
@@ -215,10 +215,10 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
wrapperpaper.eq(UserExamPapers::getUserExamId, userExam.getId())
|
|
|
.eq(UserExamPapers::getState, PaperState.ING);
|
|
|
userExamPapersList=BeanContext.getApplicationContext().getBean(IUserExamPapersService.class).list(wrapperpaper);
|
|
|
- if (userExamPapersList.size()>0){
|
|
|
+ if (!userExamPapersList.isEmpty()){
|
|
|
throw new JeecgBootException("有正在进行的考试!");
|
|
|
}
|
|
|
- //获取已经考了几张试卷开始考下一张
|
|
|
+ //获取已经考了几张试卷开始考下一张
|
|
|
paper=iPaperService.getById(examPapersList.get(iUserExamPapersService.UserExamIdAllUserExamPapers2(userExam.getId()).size()).getPaperId());
|
|
|
}
|
|
|
|
|
@@ -712,6 +712,15 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 在线考试试卷详情,包括答题卡,试题(不包含正确答案和解析) 新
|
|
|
+ *
|
|
|
+ * @param userExamId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public UserExamDTO examDetailPapers(String userExamId) {
|
|
|
+ return examDetailPapers(userExamId, false, false, true, false);
|
|
|
+ } /**
|
|
|
* 在线考试试卷详情,包括答题卡,试题(不包含正确答案和解析)
|
|
|
*
|
|
|
* @param userExamId
|
|
@@ -721,10 +730,40 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
public UserExamDTO examDetail(String userExamId) {
|
|
|
return examDetail(userExamId, false, false, true, false);
|
|
|
}
|
|
|
-
|
|
|
public UserExamDTO examDetail(String userExamId, boolean needAnswerFlag, boolean needAnalysis, boolean needClearBlankContent, boolean needRenderBlank) {
|
|
|
UserExamDTO dto = new UserExamDTO();
|
|
|
UserExam userExam = userExamService.listUserExam(userExamId);
|
|
|
+// System.out.println("yyz显示提交"+userExam);
|
|
|
+ if (Objects.isNull(userExam)) {
|
|
|
+ throw new JeecgBootException("考试不存在!");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(userExam, dto);
|
|
|
+ List<UserExamQuestion> userExamQuestionList = dto.getUserExamQuestionList();
|
|
|
+ List<Map<String, AnswerCardDTO>> answerCardList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(userExamQuestionList)) {
|
|
|
+ List<UserExamQuestion> rootQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && !r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ List<UserExamQuestion> childQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(rootQuestionList)) {
|
|
|
+ //获取题目和答案
|
|
|
+ assembleUserExamQuestion(userExamId, rootQuestionList, childQuestionList, needAnswerFlag, needAnalysis, false, true, needClearBlankContent);
|
|
|
+
|
|
|
+ //设置题目
|
|
|
+ setUserExamQuestion(rootQuestionList, needRenderBlank);
|
|
|
+
|
|
|
+ //设置答题卡
|
|
|
+ setAnswerCard(rootQuestionList, answerCardList);
|
|
|
+ dto.setUserExamQuestionList(rootQuestionList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setAnswerCardList(answerCardList);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ public UserExamDTO examDetailPapers(String userExamId, boolean needAnswerFlag, boolean needAnalysis, boolean needClearBlankContent, boolean needRenderBlank) {
|
|
|
+ UserExamDTO dto = new UserExamDTO();
|
|
|
+ UserExam userExam = userExamService.listUserExamPapers(userExamId);
|
|
|
//显示试卷详情
|
|
|
if (Objects.isNull(userExam)) {
|
|
|
throw new JeecgBootException("考试不存在!");
|
|
@@ -908,12 +947,25 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public UserExamDTO userExamResultDetail(String userExamId,String paperId) {
|
|
|
- UserExamDTO userExamDTO = userExamResultDetail(userExamId,paperId, true, true, false, true);
|
|
|
+ public UserExamDTO userExamResultDetail(String userExamId) {
|
|
|
+ UserExamDTO userExamDTO = examDetail(userExamId, true, true, false, true);
|
|
|
//设置单选题/多选题/判断题的答案tag
|
|
|
setAnswerTag(userExamDTO);
|
|
|
return userExamDTO;
|
|
|
}
|
|
|
+// /**
|
|
|
+// * 用户考试成绩详情,包括答题卡,试题(包含正确答案和解析)
|
|
|
+// *
|
|
|
+// * @param userExamId
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @Override
|
|
|
+// public UserExamDTO userExamResultDetail(String userExamId,String paperId) {
|
|
|
+// UserExamDTO userExamDTO = userExamResultDetail(userExamId,paperId, true, true, false, true);
|
|
|
+// //设置单选题/多选题/判断题的答案tag
|
|
|
+// setAnswerTag(userExamDTO);
|
|
|
+// return userExamDTO;
|
|
|
+// }
|
|
|
/**
|
|
|
* 用户考试成绩详情,包括答题卡,试题(包含正确答案和解析)
|
|
|
*
|
|
@@ -1117,7 +1169,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
return userExamPapersLists.get(0).getPaperId();
|
|
|
}
|
|
|
}
|
|
|
- UserExam userExam = userExamService.listUserExam(dto.getUserExamId());
|
|
|
+ UserExam userExam = userExamService.listUserExamPapers(dto.getUserExamId());
|
|
|
if (Objects.isNull(userExam)) {
|
|
|
throw new JeecgBootException("考试记录不存在");
|
|
|
}
|
|
@@ -1163,59 +1215,58 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
return biaozhi;
|
|
|
}
|
|
|
/**
|
|
|
- * 单个试卷交卷
|
|
|
+ * 交卷
|
|
|
*
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void submitExam(ExamSubmitDTO dto) {
|
|
|
-// if (StringUtils.isEmpty(dto.getUserExamId())) {
|
|
|
-// throw new JeecgBootException("考试ID不能为空");
|
|
|
-// }
|
|
|
-// UserExam userExam = userExamService.listUserExam(dto.getUserExamId());
|
|
|
-// if (Objects.isNull(userExam)) {
|
|
|
-// throw new JeecgBootException("考试记录不存在");
|
|
|
-// }
|
|
|
-// if (PaperState.FINISHED.equals(userExam.getState()) || PaperState.WAIT_OPT.equals(userExam.getState())) {
|
|
|
-// throw new JeecgBootException("该考试已经交卷,不允许重复交卷");
|
|
|
-// }
|
|
|
-// List<UserExamQuestion> userExamQuestionList = userExam.getUserExamQuestionList();
|
|
|
-// if (CollectionUtils.isEmpty(userExamQuestionList)) {
|
|
|
-// throw new JeecgBootException("考题查询失败");
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<UserExamQuestion> rootQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && !r.getChild())
|
|
|
-// .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
-// List<UserExamQuestion> childQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && r.getChild())
|
|
|
-// .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
-// if (!CollectionUtils.isEmpty(rootQuestionList)) {
|
|
|
-// //组装题目、子题目和答案
|
|
|
-// assembleUserExamQuestion(dto.getUserExamId(), rootQuestionList, childQuestionList, true, false, true, false, false);
|
|
|
-// }
|
|
|
-// //如果没有作答
|
|
|
-// List<ExamAnswerDTO> examAnswers = dto.getExamAnswers();
|
|
|
-// if (CollectionUtils.isEmpty(examAnswers)) {
|
|
|
-// updateUserExamAndResult(0, userExam);
|
|
|
-// //没作答时需要更新客观题
|
|
|
-// updateObjectiveQuestion(userExamQuestionList);
|
|
|
-// } else {
|
|
|
-// //有作答
|
|
|
-// Map<Integer, UserExamQuestion> userExamQuestionMap = rootQuestionList.stream().collect(Collectors.toMap(UserExamQuestion::getQuestionIndex, a -> a, (k1, k2) -> k1));
|
|
|
-//
|
|
|
-// //计算客观题得分
|
|
|
-// double score = calcObjectiveScore(examAnswers, userExamQuestionMap, rootQuestionList);
|
|
|
-// //更新用户考试信息和成绩
|
|
|
-// updateUserExamAndResult(score, userExam);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //异步删除自动交卷任务,清除redis缓存
|
|
|
-// ThreadPoolUtil.getExecutor().execute(() -> {
|
|
|
-// this.deleteAutoCommitJob(dto.getUserExamId());
|
|
|
-// deleteCacheAnswer(dto.getUserExamId()+dto.getPaperId());
|
|
|
-// });
|
|
|
+ if (StringUtils.isEmpty(dto.getUserExamId())) {
|
|
|
+ throw new JeecgBootException("考试ID不能为空");
|
|
|
+ }
|
|
|
+ UserExam userExam = userExamService.listUserExam(dto.getUserExamId());
|
|
|
+ if (Objects.isNull(userExam)) {
|
|
|
+ throw new JeecgBootException("考试记录不存在");
|
|
|
+ }
|
|
|
+ if (PaperState.FINISHED.equals(userExam.getState()) || PaperState.WAIT_OPT.equals(userExam.getState())) {
|
|
|
+ throw new JeecgBootException("该考试已经交卷,不允许重复交卷");
|
|
|
+ }
|
|
|
+ List<UserExamQuestion> userExamQuestionList = userExam.getUserExamQuestionList();
|
|
|
+ if (CollectionUtils.isEmpty(userExamQuestionList)) {
|
|
|
+ throw new JeecgBootException("考题查询失败");
|
|
|
+ }
|
|
|
+ List<UserExamQuestion> rootQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && !r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ List<UserExamQuestion> childQuestionList = userExamQuestionList.stream().filter(r -> !Objects.isNull(r.getChild()) && r.getChild())
|
|
|
+ .sorted(Comparator.comparing(UserExamQuestion::getQuestionIndex)).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(rootQuestionList)) {
|
|
|
+ //组装题目、子题目和答案
|
|
|
+ assembleUserExamQuestion(dto.getUserExamId(), rootQuestionList, childQuestionList, true, false, true, false, false);
|
|
|
+ }
|
|
|
+ //如果没有作答
|
|
|
+ List<ExamAnswerDTO> examAnswers = dto.getExamAnswers();
|
|
|
+ if (CollectionUtils.isEmpty(examAnswers)) {
|
|
|
+ updateUserExamAndResult(0, userExam);
|
|
|
+ //没作答时需要更新客观题
|
|
|
+ updateObjectiveQuestion(userExamQuestionList);
|
|
|
+ } else {
|
|
|
+ //有作答
|
|
|
+ Map<Integer, UserExamQuestion> userExamQuestionMap = rootQuestionList.stream().collect(Collectors.toMap(UserExamQuestion::getQuestionIndex, a -> a, (k1, k2) -> k1));
|
|
|
+ //计算客观题得分
|
|
|
+ double score = calcObjectiveScore(examAnswers, userExamQuestionMap, rootQuestionList);
|
|
|
+ //更新用户考试信息和成绩
|
|
|
+ updateUserExamAndResult(score, userExam);
|
|
|
+ }
|
|
|
+
|
|
|
+ //异步删除自动交卷任务,清除redis缓存
|
|
|
+ ThreadPoolUtil.getExecutor().execute(() -> {
|
|
|
+ this.deleteAutoCommitJob(dto.getUserExamId());
|
|
|
+ deleteCacheAnswer(dto.getUserExamId());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 没作答时需要更新客观题
|
|
|
*
|
|
@@ -1355,7 +1406,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
*/
|
|
|
public double calcObjectiveScore(List<ExamAnswerDTO> examAnswers, Map<Integer, UserExamQuestion> userExamQuestionMap, List<UserExamQuestion> rootQuestionList) {
|
|
|
if (!CollectionUtils.isEmpty(examAnswers)) {
|
|
|
- System.out.println("---------------------------------------");
|
|
|
//对比/计算
|
|
|
for (ExamAnswerDTO o : examAnswers) {
|
|
|
//根据题型计算客观题得分
|