|
@@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.validation.ValidationException;
|
|
import javax.validation.ValidationException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 考试服务
|
|
* 考试服务
|
|
@@ -42,6 +43,7 @@ public class ExamService {
|
|
|
private final ILearnPlanService learnPlanService;
|
|
private final ILearnPlanService learnPlanService;
|
|
|
private final LearnQuestionsMapper learnQuestionsMapper;
|
|
private final LearnQuestionsMapper learnQuestionsMapper;
|
|
|
private final IDzSubjectService dzSubjectService;
|
|
private final IDzSubjectService dzSubjectService;
|
|
|
|
|
+ private final LearnKnowledgeCourseMapper learnKnowledgeCourseMapper;
|
|
|
private Set<PaperType> paperTypeSet = Sets.newHashSet(PaperType.Real, PaperType.Custom, PaperType.Test);
|
|
private Set<PaperType> paperTypeSet = Sets.newHashSet(PaperType.Real, PaperType.Custom, PaperType.Test);
|
|
|
private final LearnPaperMapper paperMapper;
|
|
private final LearnPaperMapper paperMapper;
|
|
|
private final LearnKnowledgeTreeMapper knowledgeTreeMapper;
|
|
private final LearnKnowledgeTreeMapper knowledgeTreeMapper;
|
|
@@ -53,7 +55,7 @@ public class ExamService {
|
|
|
private final IAMarjorPlanService marjorPlanService;
|
|
private final IAMarjorPlanService marjorPlanService;
|
|
|
private final ISysUserService sysUserService;
|
|
private final ISysUserService sysUserService;
|
|
|
|
|
|
|
|
- public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService, LearnQuestionsMapper learnQuestionsMapper, IDzSubjectService dzSubjectService, LearnWrongBookMapper wrongBookMapper, LearnWrongDetailMapper wrongDetailMapper) {
|
|
|
|
|
|
|
+ public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService, LearnQuestionsMapper learnQuestionsMapper, IDzSubjectService dzSubjectService, LearnWrongBookMapper wrongBookMapper, LearnWrongDetailMapper wrongDetailMapper, LearnKnowledgeCourseMapper learnKnowledgeCourseMapper) {
|
|
|
this.paperMapper = paperMapper;
|
|
this.paperMapper = paperMapper;
|
|
|
this.knowledgeTreeMapper = knowledgeTreeMapper;
|
|
this.knowledgeTreeMapper = knowledgeTreeMapper;
|
|
|
this.examineeMapper = examineeMapper;
|
|
this.examineeMapper = examineeMapper;
|
|
@@ -69,6 +71,7 @@ public class ExamService {
|
|
|
this.dzSubjectService = dzSubjectService;
|
|
this.dzSubjectService = dzSubjectService;
|
|
|
this.wrongBookMapper = wrongBookMapper;
|
|
this.wrongBookMapper = wrongBookMapper;
|
|
|
this.wrongDetailMapper = wrongDetailMapper;
|
|
this.wrongDetailMapper = wrongDetailMapper;
|
|
|
|
|
+ this.learnKnowledgeCourseMapper = learnKnowledgeCourseMapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -87,7 +90,12 @@ public class ExamService {
|
|
|
if(UserTypeEnum.isCard(user.getUserType()) && !UserRegStatus.Student.equals(user.getRegStatus())) {
|
|
if(UserTypeEnum.isCard(user.getUserType()) && !UserRegStatus.Student.equals(user.getRegStatus())) {
|
|
|
throw new RuntimeException("VIP功能不可用");
|
|
throw new RuntimeException("VIP功能不可用");
|
|
|
}
|
|
}
|
|
|
- return openExaminee(relatedId, SecurityUtils.getUserId(), directed);
|
|
|
|
|
|
|
+ return openExamineeForPractice(relatedId, SecurityUtils.getUserId(), directed);
|
|
|
|
|
+ } 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)) {
|
|
} else if(PaperType.Simulated.equals(paperType)) {
|
|
|
SysUser exist = sysUserService.selectUserById(SecurityUtils.getUserId());
|
|
SysUser exist = sysUserService.selectUserById(SecurityUtils.getUserId());
|
|
|
LearnStudent ls = learnStudentMapper.selectLearnStudentByStudentId(exist.getUserId());
|
|
LearnStudent ls = learnStudentMapper.selectLearnStudentByStudentId(exist.getUserId());
|
|
@@ -242,6 +250,9 @@ public class ExamService {
|
|
|
if(PaperType.Practice.getVal().equals(exitExaminee.getPaperType())) {
|
|
if(PaperType.Practice.getVal().equals(exitExaminee.getPaperType())) {
|
|
|
learnPlanService.updateLearnPlan(exitExaminee.getStudentId());
|
|
learnPlanService.updateLearnPlan(exitExaminee.getStudentId());
|
|
|
calculateWrongAnswers(exitExaminee, questionMap, answersList, PaperType.Practice.name());
|
|
calculateWrongAnswers(exitExaminee, questionMap, answersList, PaperType.Practice.name());
|
|
|
|
|
+ } else if(PaperType.Course.getVal().equals(exitExaminee.getPaperType())) {
|
|
|
|
|
+ learnPlanService.updateLearnPlan(exitExaminee.getStudentId());
|
|
|
|
|
+ calculateWrongAnswers(exitExaminee, questionMap, answersList, PaperType.Course.name());
|
|
|
} else if(PaperType.Simulated.getVal().equals(exitExaminee.getPaperType())) {
|
|
} else if(PaperType.Simulated.getVal().equals(exitExaminee.getPaperType())) {
|
|
|
calculateWrongAnswers(exitExaminee, questionMap, answersList, PaperType.Simulated.name());
|
|
calculateWrongAnswers(exitExaminee, questionMap, answersList, PaperType.Simulated.name());
|
|
|
}
|
|
}
|
|
@@ -420,11 +431,17 @@ public class ExamService {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据知识点生成一次性练习卷并开始做题
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- private AnswerSheet openExaminee(Long knowledgeId, Long studentId, Boolean directed) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private AnswerSheet openExamineeForCourse(Long knowledgeId, Long studentId, Boolean directed) {
|
|
|
|
|
+ LearnKnowledgeCourse kc = learnKnowledgeCourseMapper.selectLearnKnowledgeCourseById(knowledgeId);
|
|
|
|
|
+ if(null == kc || StringUtils.isBlank(kc.getKnowledges())) {
|
|
|
|
|
+ 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, "") ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private AnswerSheet openExamineeForPractice(Long knowledgeId, Long studentId, Boolean directed) {
|
|
|
String directKey;
|
|
String directKey;
|
|
|
AMarjorPlan plan = null;
|
|
AMarjorPlan plan = null;
|
|
|
LearnStudent ls = null;
|
|
LearnStudent ls = null;
|
|
@@ -438,8 +455,18 @@ public class ExamService {
|
|
|
directKey = StringUtils.trimToEmpty(ls.getDirectKey());
|
|
directKey = StringUtils.trimToEmpty(ls.getDirectKey());
|
|
|
}
|
|
}
|
|
|
LearnKnowledgeTree knowledgeTree = knowledgeTreeMapper.selectLearnKnowledgeTreeById(knowledgeId);
|
|
LearnKnowledgeTree knowledgeTree = knowledgeTreeMapper.selectLearnKnowledgeTreeById(knowledgeId);
|
|
|
|
|
+ return openExaminee(PaperType.Practice, knowledgeId, Lists.newArrayList(knowledgeId), studentId, directed,
|
|
|
|
|
+ knowledgeTree.getSubjectId(), knowledgeTree.getName(), ls, plan, directKey) ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据知识点生成一次性练习卷并开始做题
|
|
|
|
|
+ * @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) {
|
|
|
LearnPaper paper = new LearnPaper();
|
|
LearnPaper paper = new LearnPaper();
|
|
|
- paper.setPaperType(PaperType.Practice.name());
|
|
|
|
|
|
|
+ paper.setPaperType(paperType.name());
|
|
|
paper.setRelateId(knowledgeId);
|
|
paper.setRelateId(knowledgeId);
|
|
|
paper.setYear(Calendar.getInstance().get(Calendar.YEAR));
|
|
paper.setYear(Calendar.getInstance().get(Calendar.YEAR));
|
|
|
paper.setStatus(PaperStatus.TmpValid.getVal());
|
|
paper.setStatus(PaperStatus.TmpValid.getVal());
|
|
@@ -450,7 +477,7 @@ public class ExamService {
|
|
|
LearnExaminee learnExaminee = new LearnExaminee();
|
|
LearnExaminee learnExaminee = new LearnExaminee();
|
|
|
learnExaminee.setStudentId(studentId);
|
|
learnExaminee.setStudentId(studentId);
|
|
|
learnExaminee.setPaperId(existPaper.getId());
|
|
learnExaminee.setPaperId(existPaper.getId());
|
|
|
- learnExaminee.setPaperType(PaperType.Practice.getVal());
|
|
|
|
|
|
|
+ learnExaminee.setPaperType(paperType.getVal());
|
|
|
learnExaminee.setState(ExamineeStatus.Exam.getVal());
|
|
learnExaminee.setState(ExamineeStatus.Exam.getVal());
|
|
|
List<LearnExaminee> examineeList = examineeMapper.selectLearnExamineeList(learnExaminee);
|
|
List<LearnExaminee> examineeList = examineeMapper.selectLearnExamineeList(learnExaminee);
|
|
|
if (CollectionUtils.isNotEmpty(examineeList) && ExamineeStatus.Exam.getVal().equals(examineeList.get(0).getState())) {
|
|
if (CollectionUtils.isNotEmpty(examineeList) && ExamineeStatus.Exam.getVal().equals(examineeList.get(0).getState())) {
|
|
@@ -470,20 +497,20 @@ public class ExamService {
|
|
|
up.setStatus(PaperStatus.Valid.getVal());
|
|
up.setStatus(PaperStatus.Valid.getVal());
|
|
|
paperMapper.updateLearnPaper(up);
|
|
paperMapper.updateLearnPaper(up);
|
|
|
}
|
|
}
|
|
|
- List<LearnPaperQuestion> pqList = paperService.getQuestionsByRandom(studentId, 15, knowledgeId, 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()));
|
|
|
if(CollectionUtils.isEmpty(pqList)) {
|
|
if(CollectionUtils.isEmpty(pqList)) {
|
|
|
throw new RuntimeException("本知识点题已做完");
|
|
throw new RuntimeException("本知识点题已做完");
|
|
|
}
|
|
}
|
|
|
paper.setPaperSource(0);
|
|
paper.setPaperSource(0);
|
|
|
paper.setFenshu(0);
|
|
paper.setFenshu(0);
|
|
|
- paper.setSubjectId(knowledgeTree.getSubjectId());
|
|
|
|
|
- paper.setPaperName(studentId + "-" + knowledgeTree.getName() + "-" + DateUtils.format(new Date(), "yyyyMMddHHmmss"));
|
|
|
|
|
|
|
+ paper.setSubjectId(subjectId);
|
|
|
|
|
+ paper.setPaperName(studentId + "-" + knowledName + "-" + DateUtils.format(new Date(), "yyyyMMddHHmmss"));
|
|
|
paper.setRelateId(knowledgeId);
|
|
paper.setRelateId(knowledgeId);
|
|
|
paperService.savePaper(paper, pqList);
|
|
paperService.savePaper(paper, pqList);
|
|
|
|
|
|
|
|
LearnExaminee learnExaminee = new LearnExaminee();
|
|
LearnExaminee learnExaminee = new LearnExaminee();
|
|
|
learnExaminee.setStudentId(studentId);
|
|
learnExaminee.setStudentId(studentId);
|
|
|
- learnExaminee.setPaperType(PaperType.Practice.getVal());
|
|
|
|
|
|
|
+ learnExaminee.setPaperType(paperType.getVal());
|
|
|
learnExaminee.setPaperId(paper.getId());
|
|
learnExaminee.setPaperId(paper.getId());
|
|
|
learnExaminee.setPaperKey(String.valueOf(knowledgeId));
|
|
learnExaminee.setPaperKey(String.valueOf(knowledgeId));
|
|
|
learnExaminee.setState(ExamineeStatus.Exam.getVal());
|
|
learnExaminee.setState(ExamineeStatus.Exam.getVal());
|