|
@@ -779,7 +779,63 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
dto.setExamPapersList(examPapersList);
|
|
|
return dto;
|
|
|
}
|
|
|
+ public UserExamDTO userExamResultDetail(String userExamId,String paperId, boolean needAnswerFlag, boolean needAnalysis, boolean needClearBlankContent, boolean needRenderBlank) {
|
|
|
+ UserExamDTO dto = new UserExamDTO();
|
|
|
+ UserExam userExam = userExamService.listUserExamYueJuan(userExamId,paperId);
|
|
|
+ //显示试卷详情
|
|
|
+ if (Objects.isNull(userExam)) {
|
|
|
+ throw new JeecgBootException("考试不存在!");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(userExam, dto);
|
|
|
+ List<UserExamQuestion> userExamQuestionList = dto.getUserExamQuestionList();
|
|
|
+ List<Map<String, AnswerCardDTO>> answerCardList = new ArrayList<>();
|
|
|
+ List< AnswerCardDTO> answerCardList2 = 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);
|
|
|
+ setAnswerCard2(rootQuestionList, answerCardList2);
|
|
|
+ dto.setUserExamQuestionList(rootQuestionList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setAnswerCardList(answerCardList);
|
|
|
+ dto.setAnswerCardList2(answerCardList2);
|
|
|
+// //获取有没有正在考试的试卷信息
|
|
|
+// LambdaQueryWrapper<UserExamPapers> wrapperpaper = new LambdaQueryWrapper<UserExamPapers>();
|
|
|
+// wrapperpaper.eq(UserExamPapers::getUserExamId, userExam.getId())
|
|
|
+// .eq(UserExamPapers::getState, PaperState.ING);
|
|
|
+// List<UserExamPapers> userExamPapersList=BeanContext.getApplicationContext().getBean(IUserExamPapersService.class).list(wrapperpaper);
|
|
|
+// //获取本地当前时间
|
|
|
+// userExamPapersList.get(0).setSystemTime(new Date());
|
|
|
+// //在返回值中添加考试试卷信息
|
|
|
+// dto.setUserExamPapersList(userExamPapersList);
|
|
|
+ //添加当前考试的所有试卷信息
|
|
|
+ List<ExamPapers> examPapersList=iExamPapersService.getExamIdPaper(userExam.getExamId());
|
|
|
+ List<UserExamPapers> userExamPapersList1=new ArrayList<UserExamPapers>();
|
|
|
+ for (ExamPapers examPapers : examPapersList) {
|
|
|
+ //获取是否考试状态并赋值
|
|
|
+ userExamPapersList1 = iUserExamPapersService.UserExamPapersList(userExamId, examPapers.getPaperId());
|
|
|
+ if (userExamPapersList1.size() == 0) {
|
|
|
+ examPapers.setState(9);
|
|
|
+ } else {
|
|
|
+ examPapers.setState(userExamPapersList1.get(0).getState());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ dto.setExamPapersList(examPapersList);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
/**
|
|
|
* 用户考试成绩详情,包括答题卡,试题(包含正确答案和解析)
|
|
|
*
|
|
@@ -787,8 +843,8 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public UserExamDTO userExamResultDetail(String userExamId) {
|
|
|
- UserExamDTO userExamDTO = examDetail(userExamId, true, true, false, true);
|
|
|
+ public UserExamDTO userExamResultDetail(String userExamId,String paperId) {
|
|
|
+ UserExamDTO userExamDTO = userExamResultDetail(userExamId,paperId, true, true, false, true);
|
|
|
//设置单选题/多选题/判断题的答案tag
|
|
|
setAnswerTag(userExamDTO);
|
|
|
return userExamDTO;
|
|
@@ -958,7 +1014,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
@Override
|
|
|
public String submitExamPaper(ExamSubmitDTO dto) {
|
|
|
String biaozhi="";
|
|
|
- System.out.println("yyz进行交卷");
|
|
|
+// System.out.println("yyz进行交卷");
|
|
|
if (StringUtils.isEmpty(dto.getUserExamId())) {
|
|
|
throw new JeecgBootException("考试ID不能为空");
|
|
|
}
|
|
@@ -980,7 +1036,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
throw new JeecgBootException("该试卷已经交卷,不允许重复交卷,当前试卷为最后一套试卷,本次考试结束。");
|
|
|
}else if(userExamPapersLists.size()==1){
|
|
|
// throw new JeecgBootException("该试卷已经交卷,不允许重复交卷,即将进入下一套试卷。",Integer.parseInt(userExamPapersLists.get(0).getPaperId()));
|
|
|
- System.out.println("yyz显示:"+userExamPapersLists.get(0).getPaperId());
|
|
|
+// System.out.println("yyz显示:"+userExamPapersLists.get(0).getPaperId());
|
|
|
return userExamPapersLists.get(0).getPaperId();
|
|
|
}
|
|
|
}
|
|
@@ -1013,9 +1069,9 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
//没作答时需要更新客观题
|
|
|
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);
|
|
|
//更新用户考试信息和成绩
|
|
@@ -1030,57 +1086,57 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
return biaozhi;
|
|
|
}
|
|
|
/**
|
|
|
- * yyz单个试卷交卷
|
|
|
+ * 单个试卷交卷
|
|
|
*
|
|
|
* @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()+dto.getPaperId());
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1222,6 +1278,7 @@ 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) {
|
|
|
//根据题型计算客观题得分
|
|
@@ -1291,48 +1348,48 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
* @param userExamQuestionMap
|
|
|
*/
|
|
|
public void calcQuestionScoreByType(ExamAnswerDTO o, Map<Integer, UserExamQuestion> userExamQuestionMap) {
|
|
|
- //根据题目序号中获取考题
|
|
|
- UserExamQuestion userExamQuestion = getUserExamQuestionByIndex(o.getIndex(), userExamQuestionMap);
|
|
|
- if (Objects.isNull(userExamQuestion)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- userExamQuestion.setAnswered(true);//已答
|
|
|
- //主观题(简答题)
|
|
|
- if (userExamQuestion.getQuestionType().equals(QuestionType.SIMPLE.getCode())) {
|
|
|
- userExamQuestion.setAnswer(o.getSubjectiveAnswer());//答案内容
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //单选,多选,判断题获取并设置答案
|
|
|
- String[] answers = o.getAnswers();
|
|
|
- if (!userExamQuestion.getQuestionType().equals(QuestionType.BLANK.getCode())) {
|
|
|
- if (!Objects.isNull(answers) && answers.length > 0) {
|
|
|
- userExamQuestion.setAnswer(String.join(",", answers));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //填空题获取答案
|
|
|
- String blankAnswer = o.getBlankAnswer();
|
|
|
-
|
|
|
- //提交的答案和题目答案对比
|
|
|
- Question question = userExamQuestion.getQuestion();
|
|
|
- switch (QuestionType.getByCode(question.getType())) {
|
|
|
- //单选题和判断题直接答案完全匹配
|
|
|
- case RADIO:
|
|
|
- case JUDGE:
|
|
|
- compareToScore(userExamQuestion, answers, question);
|
|
|
- break;
|
|
|
- case MULTI: //多选题
|
|
|
- if (!Objects.isNull(userExamQuestion.getCanMissOption()) && userExamQuestion.getCanMissOption()) {
|
|
|
- compareMultiToScore(userExamQuestion, answers, question);//漏选给分
|
|
|
- } else {
|
|
|
- compareToScore(userExamQuestion, answers, question);
|
|
|
- }
|
|
|
- break;
|
|
|
- case BLANK: //填空题
|
|
|
- compareBlankToScore(userExamQuestion, blankAnswer, question, userExamQuestion.getCanBlankOption());
|
|
|
- break;
|
|
|
- }
|
|
|
+// //根据题目序号中获取考题
|
|
|
+// UserExamQuestion userExamQuestion = getUserExamQuestionByIndex(o.getIndex(), userExamQuestionMap);
|
|
|
+// if (Objects.isNull(userExamQuestion)) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// userExamQuestion.setAnswered(true);//已答
|
|
|
+// //主观题(简答题)
|
|
|
+// if (userExamQuestion.getQuestionType().equals(QuestionType.SIMPLE.getCode())) {
|
|
|
+// userExamQuestion.setAnswer(o.getSubjectiveAnswer());//答案内容
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// //单选,多选,判断题获取并设置答案
|
|
|
+// String[] answers = o.getAnswers();
|
|
|
+// if (!userExamQuestion.getQuestionType().equals(QuestionType.BLANK.getCode())) {
|
|
|
+// if (!Objects.isNull(answers) && answers.length > 0) {
|
|
|
+// userExamQuestion.setAnswer(String.join(",", answers));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //填空题获取答案
|
|
|
+// String blankAnswer = o.getBlankAnswer();
|
|
|
+//
|
|
|
+// //提交的答案和题目答案对比
|
|
|
+// Question question = userExamQuestion.getQuestion();
|
|
|
+// switch (QuestionType.getByCode(question.getType())) {
|
|
|
+// //单选题和判断题直接答案完全匹配
|
|
|
+// case RADIO:
|
|
|
+// case JUDGE:
|
|
|
+// compareToScore(userExamQuestion, answers, question);
|
|
|
+// break;
|
|
|
+// case MULTI: //多选题
|
|
|
+// if (!Objects.isNull(userExamQuestion.getCanMissOption()) && userExamQuestion.getCanMissOption()) {
|
|
|
+// compareMultiToScore(userExamQuestion, answers, question);//漏选给分
|
|
|
+// } else {
|
|
|
+// compareToScore(userExamQuestion, answers, question);
|
|
|
+// }
|
|
|
+// break;
|
|
|
+// case BLANK: //填空题
|
|
|
+// compareBlankToScore(userExamQuestion, blankAnswer, question, userExamQuestion.getCanBlankOption());
|
|
|
+// break;
|
|
|
+// }
|
|
|
}
|
|
|
/**
|
|
|
* 根据题型计算客观题得分(包括连线题和拖拽题)
|
|
@@ -1373,7 +1430,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
|
|
|
//填空题获取答案
|
|
|
String blankAnswer = o.getBlankAnswer();
|
|
|
-
|
|
|
//提交的答案和题目答案对比
|
|
|
Question question = userExamQuestion.getQuestion();
|
|
|
//switch (QuestionType.getByCode(question.getType()))
|
|
@@ -1449,6 +1505,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
compareByNoOrder(answerList, userAnswer, dtoList);
|
|
|
}
|
|
|
});
|
|
|
+ System.out.println(dtoList.size());
|
|
|
if (!CollectionUtils.isEmpty(dtoList)) {
|
|
|
userExamQuestion.setAnswer(JSONArray.toJSONString(dtoList));//设置填空题答案
|
|
|
if (dtoList.size() != deepList.size()) { //用户只作答了题目部分空,没答的空自然就是错的了(有错误答案)
|
|
@@ -1533,6 +1590,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
* @param dtoList
|
|
|
*/
|
|
|
public void compareByOrder(List<QuestionAnswer> answerList, QuestionAnswer userAnswer, List<BlankAnswerResultDTO> dtoList) {
|
|
|
+ System.out.println("yyz显示userAnswer.getTag():"+userAnswer.getTag());
|
|
|
QuestionAnswer qa = answerList.stream().filter(a -> a.getTag().equals(userAnswer.getTag())).findFirst().orElse(null);
|
|
|
if (!Objects.isNull(qa)) {
|
|
|
String[] answerArray = qa.getContent().trim().split("\\|\\|");
|
|
@@ -1865,9 +1923,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
long expireMins = DateUtil.between(new Date(), dto.getLimitTime(), DateUnit.MINUTE) + 60 * 24 * 3;
|
|
|
long expireSec = expireMins * 60;
|
|
|
String idkey=dto.getUserExamId()+dto.getPaperId();
|
|
|
- System.out.println("-----------------------------");
|
|
|
- System.out.println(JSON.toJSONString(dto));
|
|
|
- System.out.println("-----------------------------");
|
|
|
redisUtil.set(idkey, JSON.toJSONString(dto), expireSec);
|
|
|
}
|
|
|
}
|