|
|
@@ -81,7 +81,7 @@ public class ExamService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public AnswerSheet openExaminee(boolean directed, PaperType paperType, Long relatedId, Long subjectId) {
|
|
|
+ public AnswerSheet openExaminee(boolean directed, PaperType paperType, Long relatedId, Long subjectId, Integer questionType) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
if(paperTypeSet.contains(paperType)) {
|
|
|
if(UserTypeEnum.isCard(user.getUserType()) && !UserRegStatus.Student.equals(user.getRegStatus())) {
|
|
|
@@ -92,19 +92,22 @@ public class ExamService {
|
|
|
if(UserTypeEnum.isCard(user.getUserType()) && !UserRegStatus.Student.equals(user.getRegStatus())) {
|
|
|
throw new RuntimeException("VIP功能不可用");
|
|
|
}
|
|
|
- return openExamineeForPractice(relatedId, SecurityUtils.getUserId(), directed);
|
|
|
+ return openExamineeForPractice(relatedId, SecurityUtils.getUserId(), directed, questionType);
|
|
|
} else if(PaperType.Course.equals(paperType)) {
|
|
|
if(UserTypeEnum.isCard(user.getUserType()) && !UserRegStatus.Student.equals(user.getRegStatus())) {
|
|
|
throw new RuntimeException("VIP功能不可用");
|
|
|
}
|
|
|
return openExamineeForCourse(relatedId, SecurityUtils.getUserId(), directed);
|
|
|
} else if(PaperType.Simulated.equals(paperType)) {
|
|
|
- SysUser exist = sysUserService.selectUserById(SecurityUtils.getUserId());
|
|
|
- LearnStudent ls = learnStudentMapper.selectLearnStudentByStudentId(exist.getUserId());
|
|
|
- if(null == ls) {
|
|
|
- throw new RuntimeException("请先定设置定向学习" + exist.getUserId());
|
|
|
+ if(null == relatedId) { // 直接打开Paper的模拟卷
|
|
|
+ SysUser exist = sysUserService.selectUserById(SecurityUtils.getUserId());
|
|
|
+ LearnStudent ls = learnStudentMapper.selectLearnStudentByStudentId(exist.getUserId());
|
|
|
+ if(null == ls) {
|
|
|
+ throw new RuntimeException("请先定设置专业学习" + exist.getUserId());
|
|
|
+ }
|
|
|
+ return openExaminee(ls, subjectId, exist);
|
|
|
}
|
|
|
- return openExaminee(ls, subjectId, exist);
|
|
|
+ return openExamineeByPaper(relatedId);
|
|
|
} else if(PaperType.Test.equals(paperType)) {
|
|
|
SysUser exist = sysUserService.selectUserById(SecurityUtils.getUserId());
|
|
|
LearnTestStudent ts = learnTestStudentMapper.selectLearnTestStudentById(relatedId);
|
|
|
@@ -442,9 +445,6 @@ public class ExamService {
|
|
|
existPaperIdSet.add(e.getPaperId());
|
|
|
}
|
|
|
LearnPaper paper = getBestPaper(sysUser.getExamType(), plan, subjectId, existPaperIdSet); // getAvailPaper(sysUser.getExamType(), ls, subjectId, existPaperIdSet)
|
|
|
- examinee.setPaperId(paper.getId());
|
|
|
- examinee.setState(ExamineeStatus.Sign.getVal());
|
|
|
- examinee.setDuration(0L);
|
|
|
|
|
|
JSONObject evalCountObj = JSONObject.parseObject(sysUser.getEvalCounts());
|
|
|
Integer evalCount = evalCountObj.getInteger(subjectId.toString());
|
|
|
@@ -458,13 +458,32 @@ public class ExamService {
|
|
|
sysUserService.updateUserProfile(upUser);
|
|
|
|
|
|
examinee.setPaperInfo(buildPaperInfo(ls, plan));
|
|
|
- examineeMapper.insertLearnExaminee(examinee);
|
|
|
- AnswerSheet answerSheet = buildAnswerSheet(paper, examinee);
|
|
|
-
|
|
|
+ AnswerSheet answerSheet = openExamineeByPaper(examinee, paper);
|
|
|
answerSheet.setCollegeId(ls.getUniversityId());
|
|
|
answerSheet.setCollegeName(plan.getUniversityName());
|
|
|
answerSheet.setMajorId(ls.getMajorPlanId());
|
|
|
answerSheet.setMajorName(plan.getMajorName());
|
|
|
+ return answerSheet;
|
|
|
+ }
|
|
|
+ private AnswerSheet openExamineeByPaper(Long paperId) {
|
|
|
+ LearnExaminee examinee = new LearnExaminee();
|
|
|
+ examinee.setStudentId(SecurityUtils.getLoginUser().getUser().getUserId());
|
|
|
+ examinee.setPaperType(PaperType.Simulated.getVal());
|
|
|
+ examinee.setPaperKey("P" + "_" + paperId);
|
|
|
+ examinee.setState(ExamineeStatus.Sign.getVal());
|
|
|
+ List<LearnExaminee> examineeList = examineeMapper.selectLearnExamineeList(examinee);
|
|
|
+ LearnPaper learnPaper = paperMapper.selectLearnPaperById(paperId);
|
|
|
+ if(CollectionUtils.isNotEmpty(examineeList)) {
|
|
|
+ return buildAnswerSheet(learnPaper, examineeList.get(0));
|
|
|
+ }
|
|
|
+ return openExamineeByPaper(examinee, learnPaper);
|
|
|
+ }
|
|
|
+ private AnswerSheet openExamineeByPaper(LearnExaminee examinee, LearnPaper paper) {
|
|
|
+ examinee.setPaperId(paper.getId());
|
|
|
+ examinee.setState(ExamineeStatus.Sign.getVal());
|
|
|
+ examinee.setDuration(0L);
|
|
|
+ examineeMapper.insertLearnExaminee(examinee);
|
|
|
+ AnswerSheet answerSheet = buildAnswerSheet(paper, examinee);
|
|
|
answerSheet.setSubjectId(paper.getSubjectId());
|
|
|
answerSheet.setSubjectName(dzSubjectService.selectDzSubjectBySubjectId(paper.getSubjectId()).getSubjectName());
|
|
|
return answerSheet;
|
|
|
@@ -486,10 +505,10 @@ public class ExamService {
|
|
|
throw new RuntimeException("无效同步知识点");
|
|
|
}
|
|
|
return openExaminee(PaperType.Course, knowledgeId, Stream.of(kc.getKnowledges().split(",")).map(Long::parseLong).collect(Collectors.toList()), studentId, false,
|
|
|
- 0L, kc.getName(), null, null, "") ;
|
|
|
+ 0L, kc.getName(), null, null, "", 0) ;
|
|
|
}
|
|
|
|
|
|
- private AnswerSheet openExamineeForPractice(Long knowledgeId, Long studentId, Boolean directed) {
|
|
|
+ private AnswerSheet openExamineeForPractice(Long knowledgeId, Long studentId, Boolean directed, Integer questionType) {
|
|
|
String directKey;
|
|
|
AMarjorPlan plan = null;
|
|
|
LearnStudent ls = null;
|
|
|
@@ -504,7 +523,7 @@ public class ExamService {
|
|
|
}
|
|
|
LearnKnowledgeTree knowledgeTree = knowledgeTreeMapper.selectLearnKnowledgeTreeById(knowledgeId);
|
|
|
return openExaminee(PaperType.Practice, knowledgeId, Lists.newArrayList(knowledgeId), studentId, directed,
|
|
|
- knowledgeTree.getSubjectId(), knowledgeTree.getName(), ls, plan, directKey) ;
|
|
|
+ knowledgeTree.getSubjectId(), knowledgeTree.getName(), ls, plan, directKey, questionType) ;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -512,13 +531,13 @@ public class ExamService {
|
|
|
* @return
|
|
|
*/
|
|
|
private AnswerSheet openExaminee(PaperType paperType, Long knowledgeId, List<Long> useKnowledgeIds, Long studentId, Boolean directed,
|
|
|
- Long subjectId, String knowledName, LearnStudent ls, AMarjorPlan plan, String directKey) {
|
|
|
+ Long subjectId, String knowledName, LearnStudent ls, AMarjorPlan plan, String directKey, Integer questionType) {
|
|
|
LearnPaper paper = new LearnPaper();
|
|
|
paper.setPaperType(paperType.name());
|
|
|
paper.setRelateId(knowledgeId);
|
|
|
paper.setYear(Calendar.getInstance().get(Calendar.YEAR));
|
|
|
paper.setStatus(PaperStatus.TmpValid.getVal());
|
|
|
- paper.setDirectKey(studentId + "_" + directKey);
|
|
|
+ paper.setDirectKey(studentId + "_" + directKey + "_" + (null == questionType ? "0" : questionType));
|
|
|
List<LearnPaper> paperList = paperMapper.selectLearnPaperList(paper);
|
|
|
if (CollectionUtils.isNotEmpty(paperList)) { // 有未做完的
|
|
|
LearnPaper existPaper = paperList.get(0);
|
|
|
@@ -545,7 +564,7 @@ public class ExamService {
|
|
|
up.setStatus(PaperStatus.Valid.getVal());
|
|
|
paperMapper.updateLearnPaper(up);
|
|
|
}
|
|
|
- List<LearnPaperQuestion> pqList = paperService.getQuestionsByRandom(studentId, 15, useKnowledgeIds, Arrays.stream(QuestionType.values()).map(QuestionType::getTitle).collect(Collectors.toList()));
|
|
|
+ List<LearnPaperQuestion> pqList = paperService.getQuestionsByRandom(studentId, 15, useKnowledgeIds, Arrays.stream(QuestionType.values()).map(QuestionType::getTitle).collect(Collectors.toList()), 0);
|
|
|
if(CollectionUtils.isEmpty(pqList)) {
|
|
|
throw new RuntimeException("本知识点题已做完");
|
|
|
}
|