|
@@ -4,7 +4,10 @@ import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.base.utils.QuestionTypeUtil;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.enums.ExamRecordStatus;
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.repository.*;
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordQuestionsRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamScoreRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.repository.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.service.GainBaseDataService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.PaperStructInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.PracticeCourseInfo;
|
|
@@ -27,241 +30,235 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @author chenken
|
|
|
- * @date 2018年9月7日 上午11:05:18
|
|
|
- * @company QMTH
|
|
|
+ * @author chenken
|
|
|
+ * @date 2018年9月7日 上午11:05:18
|
|
|
+ * @company QMTH
|
|
|
* @description PracticeServiceImpl.java
|
|
|
*/
|
|
|
@Service("practiceService")
|
|
|
public class PracticeServiceImpl implements PracticeService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ExamStudentRepo examStudentRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordRepo examRecordRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordDataRepo examRecordDataRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamScoreRepo examScoreRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamRecordPaperStructService examRecordPaperStructService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentRepo examStudentRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordDataRepo examRecordDataRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamScoreRepo examScoreRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordPaperStructService examRecordPaperStructService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private GainBaseDataService gainBaseDataService;
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<PracticeCourseInfo> queryPracticeCourseList(Long examId,Long studentId) {
|
|
|
- if(examId == null || studentId == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- List<ExamStudentEntity> examStudentList = examStudentRepo.findByExamIdAndStudentId(examId, studentId);
|
|
|
- if(examStudentList == null || examStudentList.size() == 0){
|
|
|
- return null;
|
|
|
- }
|
|
|
- List<PracticeCourseInfo> practiceCourseInfos = new ArrayList<PracticeCourseInfo>();
|
|
|
- ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId,examStudentList.get(0).getOrgId());
|
|
|
- for(ExamStudentEntity examStudent:examStudentList){
|
|
|
- practiceCourseInfos.add(buildPracticeCourseInfo(examStudent,examBean));
|
|
|
- }
|
|
|
- return practiceCourseInfos;
|
|
|
- }
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PracticeCourseInfo> queryPracticeCourseList(Long examId, Long studentId) {
|
|
|
+ if (examId == null || studentId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<ExamStudentEntity> examStudentList = examStudentRepo.findByExamIdAndStudentId(examId, studentId);
|
|
|
+ if (examStudentList == null || examStudentList.size() == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<PracticeCourseInfo> practiceCourseInfos = new ArrayList<PracticeCourseInfo>();
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId, examStudentList.get(0).getOrgId());
|
|
|
+ for (ExamStudentEntity examStudent : examStudentList) {
|
|
|
+ practiceCourseInfos.add(buildPracticeCourseInfo(examStudent, examBean));
|
|
|
+ }
|
|
|
+ return practiceCourseInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private PracticeCourseInfo buildPracticeCourseInfo(ExamStudentEntity examStudent, ExamBean examBean) {
|
|
|
+ PracticeCourseInfo practiceCourseInfo = new PracticeCourseInfo();
|
|
|
+ practiceCourseInfo.setExamStudentId(examStudent.getExamStudentId());
|
|
|
+ practiceCourseInfo.setCourseCode(examStudent.getCourseCode());
|
|
|
+
|
|
|
+ CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
+ practiceCourseInfo.setCourseName(courseBean.getName());
|
|
|
+ practiceCourseInfo.setStudentCode(examStudent.getStudentCode());
|
|
|
+ practiceCourseInfo.setStudentName(examStudent.getStudentName());
|
|
|
+
|
|
|
+ practiceCourseInfo.setExamId(examBean.getId());
|
|
|
+ practiceCourseInfo.setExamName(examBean.getName());
|
|
|
+ practiceCourseInfo.setExamType(examBean.getExamType());
|
|
|
+ practiceCourseInfo.setStartTime(examBean.getBeginTime());
|
|
|
+ practiceCourseInfo.setEndTime(examBean.getEndTime());
|
|
|
+
|
|
|
+ List<ExamRecordDataEntity> examRecordEntities = examRecordDataRepo.findByExamStudentId(examStudent.getExamStudentId());
|
|
|
|
|
|
- private PracticeCourseInfo buildPracticeCourseInfo(ExamStudentEntity examStudent,ExamBean examBean) {
|
|
|
- PracticeCourseInfo practiceCourseInfo = new PracticeCourseInfo();
|
|
|
- practiceCourseInfo.setExamStudentId(examStudent.getExamStudentId());
|
|
|
- practiceCourseInfo.setCourseCode(examStudent.getCourseCode());
|
|
|
-
|
|
|
- CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
- practiceCourseInfo.setCourseName(courseBean.getName());
|
|
|
- practiceCourseInfo.setStudentCode(examStudent.getStudentCode());
|
|
|
- practiceCourseInfo.setStudentName(examStudent.getStudentName());
|
|
|
-
|
|
|
- practiceCourseInfo.setExamId(examBean.getId());
|
|
|
- practiceCourseInfo.setExamName(examBean.getName());
|
|
|
- practiceCourseInfo.setExamType(examBean.getExamType());
|
|
|
- practiceCourseInfo.setStartTime(examBean.getBeginTime());
|
|
|
- practiceCourseInfo.setEndTime(examBean.getEndTime());
|
|
|
-
|
|
|
- List<ExamRecordEntity> examRecordEntities = examRecordRepo.findByExamStudentId(examStudent.getExamStudentId());
|
|
|
-
|
|
|
- int allExamRecordNums = 0;
|
|
|
- List<ExamScoreEntity> examScoreEntities = new ArrayList<ExamScoreEntity>();
|
|
|
- for(ExamRecordEntity examRecord:examRecordEntities){
|
|
|
- ExamRecordDataEntity examRecordData = examRecordDataRepo.findByExamRecordId(examRecord.getId());
|
|
|
- if(examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING){
|
|
|
- allExamRecordNums++;
|
|
|
- ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
- examScoreEntities.add(examScore);
|
|
|
- }
|
|
|
- }
|
|
|
- double allObjectiveAccuracy = 0;//总正确率
|
|
|
+ int allExamRecordNums = 0;
|
|
|
+ List<ExamScoreEntity> examScoreEntities = new ArrayList<ExamScoreEntity>();
|
|
|
+ for (ExamRecordDataEntity examRecordData : examRecordEntities) {
|
|
|
+ if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
|
|
|
+ allExamRecordNums++;
|
|
|
+ ExamScoreEntity examScore = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
+ examScoreEntities.add(examScore);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double allObjectiveAccuracy = 0;//总正确率
|
|
|
double maxObjectiveAccuracy = 0;//最高客观题正确率
|
|
|
long recentObjectiveAccuracyId = 0;//最近ID
|
|
|
double recentObjectiveAccuracy = 0;//最近客观题正确率
|
|
|
-
|
|
|
- for(ExamScoreEntity examScore:examScoreEntities){
|
|
|
- if(examScore != null){
|
|
|
- if (examScore.getObjectiveAccuracy() > maxObjectiveAccuracy) {
|
|
|
+
|
|
|
+ for (ExamScoreEntity examScore : examScoreEntities) {
|
|
|
+ if (examScore != null) {
|
|
|
+ if (examScore.getObjectiveAccuracy() > maxObjectiveAccuracy) {
|
|
|
maxObjectiveAccuracy = examScore.getObjectiveAccuracy();
|
|
|
}
|
|
|
- if (examScore.getId() > recentObjectiveAccuracyId) {//判断是否为最近的
|
|
|
+ if (examScore.getId() > recentObjectiveAccuracyId) {//判断是否为最近的
|
|
|
recentObjectiveAccuracyId = examScore.getId();
|
|
|
recentObjectiveAccuracy = examScore.getObjectiveAccuracy();
|
|
|
}
|
|
|
- allObjectiveAccuracy = allObjectiveAccuracy + examScore.getObjectiveAccuracy();
|
|
|
- }
|
|
|
+ allObjectiveAccuracy = allObjectiveAccuracy + examScore.getObjectiveAccuracy();
|
|
|
+ }
|
|
|
}
|
|
|
//平均正确率
|
|
|
double aveObjectiveAccuracy = 0D;
|
|
|
- if(allExamRecordNums>0){
|
|
|
- aveObjectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(allObjectiveAccuracy / allExamRecordNums));
|
|
|
+ if (allExamRecordNums > 0) {
|
|
|
+ aveObjectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(allObjectiveAccuracy / allExamRecordNums));
|
|
|
}
|
|
|
practiceCourseInfo.setAveObjectiveAccuracy(aveObjectiveAccuracy);
|
|
|
practiceCourseInfo.setMaxObjectiveAccuracy(maxObjectiveAccuracy);
|
|
|
practiceCourseInfo.setRecentObjectiveAccuracy(recentObjectiveAccuracy);
|
|
|
practiceCourseInfo.setPracticeCount(allExamRecordNums);//练习总次数
|
|
|
- return practiceCourseInfo;
|
|
|
- }
|
|
|
+ return practiceCourseInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PracticeRecordInfo> queryPracticeRecordList(Long examStudentId) {
|
|
|
+ if (examStudentId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<ExamRecordDataEntity> examRecordDataList = examRecordDataRepo.findByExamStudentId(examStudentId);
|
|
|
+ List<PracticeRecordInfo> practiceRecords = new ArrayList<PracticeRecordInfo>();
|
|
|
+ ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
+ CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
+ for (ExamRecordDataEntity examRecordData : examRecordDataList) {
|
|
|
+ if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
|
|
|
+ practiceRecords.add(buildPracticeRecord(examRecordData, courseBean));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return practiceRecords;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public List<PracticeRecordInfo> queryPracticeRecordList(Long examStudentId) {
|
|
|
- if(examStudentId == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- List<ExamRecordEntity> examRecordList = examRecordRepo.findByExamStudentId(examStudentId);
|
|
|
- List<PracticeRecordInfo> practiceRecords = new ArrayList<PracticeRecordInfo>();
|
|
|
- ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
- CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudent.getCourseId());
|
|
|
- for(ExamRecordEntity examRecord:examRecordList){
|
|
|
- ExamRecordDataEntity examRecordData = examRecordDataRepo.findByExamRecordId(examRecord.getId());
|
|
|
- if(examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING){
|
|
|
- practiceRecords.add(buildPracticeRecord(examRecordData,courseBean));
|
|
|
- }
|
|
|
- }
|
|
|
- return practiceRecords;
|
|
|
- }
|
|
|
+ private PracticeRecordInfo buildPracticeRecord(ExamRecordDataEntity examRecordData, CourseBean courseBean) {
|
|
|
+ PracticeRecordInfo practiceRecordInfo = new PracticeRecordInfo();
|
|
|
|
|
|
- private PracticeRecordInfo buildPracticeRecord(ExamRecordDataEntity examRecordData,CourseBean courseBean) {
|
|
|
- PracticeRecordInfo practiceRecordInfo = new PracticeRecordInfo();
|
|
|
-
|
|
|
- practiceRecordInfo.setId(examRecordData.getId());
|
|
|
- practiceRecordInfo.setCourseCode(courseBean.getCode());
|
|
|
- practiceRecordInfo.setCourseName(courseBean.getName());
|
|
|
- practiceRecordInfo.setStartTime(examRecordData.getStartTime());
|
|
|
- practiceRecordInfo.setEndTime(examRecordData.getEndTime());
|
|
|
- practiceRecordInfo.setUsedExamTime(examRecordData.getUsedExamTime());
|
|
|
-
|
|
|
- ExamScoreEntity examScoreEntity = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
- practiceRecordInfo.setObjectiveAccuracy(examScoreEntity.getObjectiveAccuracy());//客观题答对的比率
|
|
|
- ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
- List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
|
|
|
- practiceRecordInfo = calculationExamQuestionSituationInfo(practiceRecordInfo,examQuestionEntities);
|
|
|
-
|
|
|
- return practiceRecordInfo;
|
|
|
- }
|
|
|
+ practiceRecordInfo.setId(examRecordData.getId());
|
|
|
+ practiceRecordInfo.setCourseCode(courseBean.getCode());
|
|
|
+ practiceRecordInfo.setCourseName(courseBean.getName());
|
|
|
+ practiceRecordInfo.setStartTime(examRecordData.getStartTime());
|
|
|
+ practiceRecordInfo.setEndTime(examRecordData.getEndTime());
|
|
|
+ practiceRecordInfo.setUsedExamTime(examRecordData.getUsedExamTime());
|
|
|
|
|
|
- /**
|
|
|
- * 计算答题情况
|
|
|
- * @param practiceRecordInfo
|
|
|
- * @param examQuestionEntities
|
|
|
- * @return
|
|
|
- */
|
|
|
- private PracticeRecordInfo calculationExamQuestionSituationInfo(PracticeRecordInfo practiceRecordInfo,List<ExamQuestionEntity> examQuestionEntities){
|
|
|
- if(practiceRecordInfo == null){
|
|
|
- practiceRecordInfo = new PracticeRecordInfo();
|
|
|
- }
|
|
|
- int succQuestionNum = 0;//正确答题数
|
|
|
- int failQuestionNum = 0;//错误答题数
|
|
|
- int notAnsweredCount = 0;//未作答题数
|
|
|
- for(ExamQuestionEntity examQuestionEntity:examQuestionEntities){
|
|
|
- if(examQuestionEntity.getIsAnswer() == null || !examQuestionEntity.getIsAnswer()){
|
|
|
- notAnsweredCount++;
|
|
|
- }else{
|
|
|
- //客观题判断正确错误
|
|
|
- if(QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())){
|
|
|
- if(examQuestionEntity.getCorrectAnswer() !=null
|
|
|
- && examQuestionEntity.getStudentAnswer() != null
|
|
|
- && examQuestionEntity.getCorrectAnswer().equals(examQuestionEntity.getStudentAnswer())){
|
|
|
- succQuestionNum++;
|
|
|
- }else{
|
|
|
- failQuestionNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- int objectiveQuestionsNum = 0;//客观题总数
|
|
|
- for(ExamQuestionEntity examQuestionEntity:examQuestionEntities){
|
|
|
- if(QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())){
|
|
|
- objectiveQuestionsNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- practiceRecordInfo.setObjectiveNum(objectiveQuestionsNum);
|
|
|
- practiceRecordInfo.setSuccQuestionNum(succQuestionNum);
|
|
|
- practiceRecordInfo.setFailQuestionNum(failQuestionNum);
|
|
|
- practiceRecordInfo.setNotAnsweredCount(notAnsweredCount);
|
|
|
- practiceRecordInfo.setTotalQuestionCount(examQuestionEntities.size());
|
|
|
- return practiceRecordInfo;
|
|
|
- }
|
|
|
+ ExamScoreEntity examScoreEntity = examScoreRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
+ practiceRecordInfo.setObjectiveAccuracy(examScoreEntity.getObjectiveAccuracy());//客观题答对的比率
|
|
|
+ ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordData.getId());
|
|
|
+ List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
|
|
|
+ practiceRecordInfo = calculationExamQuestionSituationInfo(practiceRecordInfo, examQuestionEntities);
|
|
|
|
|
|
- @Override
|
|
|
- public PracticeDetailInfo getPracticeDetailInfo(Long examRecordDataId) {
|
|
|
- if(examRecordDataId == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- PracticeDetailInfo practiceDetailInfo = new PracticeDetailInfo();
|
|
|
- //取出试卷结构
|
|
|
- ExamRecordPaperStructEntity examRecordPaperStruct = examRecordPaperStructService.getExamRecordPaperStruct(examRecordDataId);
|
|
|
- DefaultPaper defaultPaper = examRecordPaperStruct.getDefaultPaper();
|
|
|
- List<PaperStructInfo> paperStructInfos = new ArrayList<PaperStructInfo>();
|
|
|
- List<DefaultQuestionGroup> questionGroupList = defaultPaper.getQuestionGroupList();
|
|
|
- //取出作答记录
|
|
|
- ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
- List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
|
|
|
- //遍历大题
|
|
|
- int objectiveNum = 0;//各个大题中的客观题总数
|
|
|
- int objectSuccessNum = 0;//各个大题中的客观题答对的总数量
|
|
|
- for(int i = 0;i<questionGroupList.size();i++){
|
|
|
- DefaultQuestionGroup defaultQuestionGroup = questionGroupList.get(i);
|
|
|
- PaperStructInfo paperStructInfo = new PaperStructInfo();
|
|
|
- paperStructInfo.setTitle(defaultQuestionGroup.getGroupName());//大题名称
|
|
|
- paperStructInfo.setIndex(i+1);//大题号
|
|
|
- //使用大题号过滤
|
|
|
- List<ExamQuestionEntity> examQuestionEntitiesOfMainQuestion = examQuestionEntities.stream().filter(o1->o1.getMainNumber().intValue() == paperStructInfo.getIndex()).collect(Collectors.toList());
|
|
|
- //计算出作答情况
|
|
|
- PracticeRecordInfo practiceRecordInfo = calculationExamQuestionSituationInfo(null,examQuestionEntitiesOfMainQuestion);
|
|
|
-
|
|
|
- objectiveNum += practiceRecordInfo.getObjectiveNum();
|
|
|
- objectSuccessNum += practiceRecordInfo.getSuccQuestionNum();
|
|
|
-
|
|
|
- paperStructInfo.setQuestionCount(practiceRecordInfo.getTotalQuestionCount());
|
|
|
- paperStructInfo.setSuccQuestionNum(practiceRecordInfo.getSuccQuestionNum());
|
|
|
- paperStructInfo.setFailQuestionNum(practiceRecordInfo.getFailQuestionNum());
|
|
|
- paperStructInfo.setNotAnsweredCount(practiceRecordInfo.getNotAnsweredCount());
|
|
|
- paperStructInfos.add(paperStructInfo);
|
|
|
- }
|
|
|
- practiceDetailInfo.setPaperStructInfos(paperStructInfos);
|
|
|
- ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
|
|
|
- ExamRecordEntity examRecord =GlobalHelper.getEntity(examRecordRepo,examRecordData.getExamRecordId(),ExamRecordEntity.class);
|
|
|
- CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examRecord.getCourseId());
|
|
|
- practiceDetailInfo.setCourseCode(courseBean.getCode());
|
|
|
- practiceDetailInfo.setCourseName(courseBean.getName());
|
|
|
- practiceDetailInfo.setId(examRecordDataId);
|
|
|
-
|
|
|
- double objectiveAccuracy = 0;//客观题答题正确率
|
|
|
- if (objectiveNum > 0) {
|
|
|
+ return practiceRecordInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算答题情况
|
|
|
+ *
|
|
|
+ * @param practiceRecordInfo
|
|
|
+ * @param examQuestionEntities
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private PracticeRecordInfo calculationExamQuestionSituationInfo(PracticeRecordInfo practiceRecordInfo, List<ExamQuestionEntity> examQuestionEntities) {
|
|
|
+ if (practiceRecordInfo == null) {
|
|
|
+ practiceRecordInfo = new PracticeRecordInfo();
|
|
|
+ }
|
|
|
+ int succQuestionNum = 0;//正确答题数
|
|
|
+ int failQuestionNum = 0;//错误答题数
|
|
|
+ int notAnsweredCount = 0;//未作答题数
|
|
|
+ for (ExamQuestionEntity examQuestionEntity : examQuestionEntities) {
|
|
|
+ if (examQuestionEntity.getIsAnswer() == null || !examQuestionEntity.getIsAnswer()) {
|
|
|
+ notAnsweredCount++;
|
|
|
+ } else {
|
|
|
+ //客观题判断正确错误
|
|
|
+ if (QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())) {
|
|
|
+ if (examQuestionEntity.getCorrectAnswer() != null
|
|
|
+ && examQuestionEntity.getStudentAnswer() != null
|
|
|
+ && examQuestionEntity.getCorrectAnswer().equals(examQuestionEntity.getStudentAnswer())) {
|
|
|
+ succQuestionNum++;
|
|
|
+ } else {
|
|
|
+ failQuestionNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int objectiveQuestionsNum = 0;//客观题总数
|
|
|
+ for (ExamQuestionEntity examQuestionEntity : examQuestionEntities) {
|
|
|
+ if (QuestionTypeUtil.isObjectiveQuestion(examQuestionEntity.getQuestionType())) {
|
|
|
+ objectiveQuestionsNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ practiceRecordInfo.setObjectiveNum(objectiveQuestionsNum);
|
|
|
+ practiceRecordInfo.setSuccQuestionNum(succQuestionNum);
|
|
|
+ practiceRecordInfo.setFailQuestionNum(failQuestionNum);
|
|
|
+ practiceRecordInfo.setNotAnsweredCount(notAnsweredCount);
|
|
|
+ practiceRecordInfo.setTotalQuestionCount(examQuestionEntities.size());
|
|
|
+ return practiceRecordInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PracticeDetailInfo getPracticeDetailInfo(Long examRecordDataId) {
|
|
|
+ if (examRecordDataId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ PracticeDetailInfo practiceDetailInfo = new PracticeDetailInfo();
|
|
|
+ //取出试卷结构
|
|
|
+ ExamRecordPaperStructEntity examRecordPaperStruct = examRecordPaperStructService.getExamRecordPaperStruct(examRecordDataId);
|
|
|
+ DefaultPaper defaultPaper = examRecordPaperStruct.getDefaultPaper();
|
|
|
+ List<PaperStructInfo> paperStructInfos = new ArrayList<PaperStructInfo>();
|
|
|
+ List<DefaultQuestionGroup> questionGroupList = defaultPaper.getQuestionGroupList();
|
|
|
+ //取出作答记录
|
|
|
+ ExamRecordQuestionsEntity examRecordQuestions = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
+ List<ExamQuestionEntity> examQuestionEntities = examRecordQuestions.getExamQuestionEntities();
|
|
|
+ //遍历大题
|
|
|
+ int objectiveNum = 0;//各个大题中的客观题总数
|
|
|
+ int objectSuccessNum = 0;//各个大题中的客观题答对的总数量
|
|
|
+ for (int i = 0; i < questionGroupList.size(); i++) {
|
|
|
+ DefaultQuestionGroup defaultQuestionGroup = questionGroupList.get(i);
|
|
|
+ PaperStructInfo paperStructInfo = new PaperStructInfo();
|
|
|
+ paperStructInfo.setTitle(defaultQuestionGroup.getGroupName());//大题名称
|
|
|
+ paperStructInfo.setIndex(i + 1);//大题号
|
|
|
+ //使用大题号过滤
|
|
|
+ List<ExamQuestionEntity> examQuestionEntitiesOfMainQuestion = examQuestionEntities.stream().filter(o1 -> o1.getMainNumber().intValue() == paperStructInfo.getIndex()).collect(Collectors.toList());
|
|
|
+ //计算出作答情况
|
|
|
+ PracticeRecordInfo practiceRecordInfo = calculationExamQuestionSituationInfo(null, examQuestionEntitiesOfMainQuestion);
|
|
|
+
|
|
|
+ objectiveNum += practiceRecordInfo.getObjectiveNum();
|
|
|
+ objectSuccessNum += practiceRecordInfo.getSuccQuestionNum();
|
|
|
+
|
|
|
+ paperStructInfo.setQuestionCount(practiceRecordInfo.getTotalQuestionCount());
|
|
|
+ paperStructInfo.setSuccQuestionNum(practiceRecordInfo.getSuccQuestionNum());
|
|
|
+ paperStructInfo.setFailQuestionNum(practiceRecordInfo.getFailQuestionNum());
|
|
|
+ paperStructInfo.setNotAnsweredCount(practiceRecordInfo.getNotAnsweredCount());
|
|
|
+ paperStructInfos.add(paperStructInfo);
|
|
|
+ }
|
|
|
+ practiceDetailInfo.setPaperStructInfos(paperStructInfos);
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
+ CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examRecordData.getCourseId());
|
|
|
+ practiceDetailInfo.setCourseCode(courseBean.getCode());
|
|
|
+ practiceDetailInfo.setCourseName(courseBean.getName());
|
|
|
+ practiceDetailInfo.setId(examRecordDataId);
|
|
|
+
|
|
|
+ double objectiveAccuracy = 0;//客观题答题正确率
|
|
|
+ if (objectiveNum > 0) {
|
|
|
objectiveAccuracy = Double.valueOf(new DecimalFormat("#.00").format(objectSuccessNum * 100D / objectiveNum));
|
|
|
}
|
|
|
- practiceDetailInfo.setObjectiveAccuracy(objectiveAccuracy);
|
|
|
- return practiceDetailInfo;
|
|
|
- }
|
|
|
-
|
|
|
+ practiceDetailInfo.setObjectiveAccuracy(objectiveAccuracy);
|
|
|
+ return practiceDetailInfo;
|
|
|
+ }
|
|
|
+
|
|
|
}
|