瀏覽代碼

update 离线考试记录

deason 2 年之前
父節點
當前提交
18a5af99b3

+ 8 - 9
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamRecordDataService.java

@@ -15,18 +15,17 @@ import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
  */
 public interface ExamRecordDataService {
 
-
     /**
      * 创建离线考试记录
-     *
-     * @param fullyObjective
-     * @return
      */
-    ExamRecordDataEntity createOfflineExamRecordData(ExamStudentBean bean,
-                                                     ExamSettingsCacheBean examBean,
-                                                     CourseCacheBean courseBean,
-                                                     String basePaperId,
-                                                     String paperStructId, Boolean fullyObjective);
+    ExamRecordDataEntity createOfflineExamRecordData(
+            ExamStudentBean bean,
+            ExamSettingsCacheBean examBean,
+            CourseCacheBean courseBean,
+            String basePaperId,
+            Boolean fullyObjective,
+            boolean randomPaper,
+            double paperScore);
 
     Long getGetAwaitingAuditCount(Long rootOrgId, Long examId);
 

+ 15 - 6
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordDataServiceImpl.java

@@ -32,11 +32,14 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     private ExamRecordDataRepo examRecordDataRepo;
 
     @Override
-    public ExamRecordDataEntity createOfflineExamRecordData(ExamStudentBean examStudent,
-                                                            ExamSettingsCacheBean examBean,
-                                                            CourseCacheBean courseBean,
-                                                            String basePaperId,
-                                                            String paperStructId, Boolean fullyObjective) {
+    public ExamRecordDataEntity createOfflineExamRecordData(
+            ExamStudentBean examStudent,
+            ExamSettingsCacheBean examBean,
+            CourseCacheBean courseBean,
+            String basePaperId,
+            Boolean fullyObjective,
+            boolean randomPaper,
+            double paperScore) {
         ExamRecordDataEntity examRecordDataEntity = new ExamRecordDataEntity();
         examRecordDataEntity.setExamId(examBean.getId());
         examRecordDataEntity.setExamType(ExamType.valueOf(examBean.getExamType()));
@@ -51,10 +54,16 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
 
         examRecordDataEntity.setCourseId(courseBean.getId());
         examRecordDataEntity.setCourseLevel(examStudent.getCourseLevel());
+
+        // 采用千人千卷规则时,ID实际为randomPaperId
         examRecordDataEntity.setBasePaperId(basePaperId);
+        // 是否采用千人千卷规则
+        examRecordDataEntity.setRandomPaper(randomPaper);
+        // 试卷总分
+        examRecordDataEntity.setPaperScore(paperScore);
 
         examRecordDataEntity.setPaperType(examStudent.getPaperType());
-        examRecordDataEntity.setPaperStructId(paperStructId);
+        // examRecordDataEntity.setPaperStructId(paperStructId);
 
         examRecordDataEntity.setInfoCollector(examStudent.getInfoCollector());
         examRecordDataEntity.setStartTime(new Date());

+ 31 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/OfflineExamServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.oe.admin.service.impl;
 
 import cn.com.qmth.examcloud.api.commons.enums.AdminOperateType;
+import cn.com.qmth.examcloud.api.commons.enums.CallType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
@@ -23,6 +24,8 @@ import cn.com.qmth.examcloud.core.oe.admin.service.bean.uploadfile.FileInfo;
 import cn.com.qmth.examcloud.core.questions.api.ExtractConfigCloudService;
 import cn.com.qmth.examcloud.core.questions.api.request.GetPaperReq;
 import cn.com.qmth.examcloud.core.questions.api.response.GetPaperResp;
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionGroup;
 import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
 import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
@@ -174,6 +177,16 @@ public class OfflineExamServiceImpl implements OfflineExamService {
         return resultList;
     }
 
+    private double parsePaperScore(DefaultPaper defaultPaper) {
+        double paperScore = 0d;
+        if (org.apache.commons.collections.CollectionUtils.isNotEmpty(defaultPaper.getQuestionGroupList())) {
+            for (DefaultQuestionGroup group : defaultPaper.getQuestionGroupList()) {
+                paperScore += group.getGroupScore();
+            }
+        }
+        return paperScore;
+    }
+
     @Override
     public void startOfflineExam(Long examStudentId) {
         Check.isNull(examStudentId, "examStudentId不能为空");
@@ -188,33 +201,47 @@ public class OfflineExamServiceImpl implements OfflineExamService {
         if (stuClientLoginLimit.getHasValue()) {
             stuClientLoginLimitBoolean = Boolean.parseBoolean(stuClientLoginLimit.getValue().toString());
         }
+
         if (stuClientLoginLimitBoolean) {
             throw new StatusException("1001", "系统维护中... ...");
         }
+
         List<ExamRecordDataEntity> examRecordList = examRecordDataRepo.findByExamStudentId(examStudentId);
         if (examRecordList != null && examRecordList.size() > 0) {
             throw new StatusException("1002", "已经存在examStudentId=" + examStudentId + "的离线考试记录");
         }
+
         //获取考生信息
         ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
         ExamStudentBean bean = of(examStudentEntity);
+
         //检查并获取课程信息
         CourseCacheBean courseBean = checkCourse(bean);
+
         //检查并获取考试信息
         ExamSettingsCacheBean examBean = checkExam(bean);
-        //获取题库试卷结构(由于存在随机抽卷,所以不能缓存 )
+
+        //获取题库试卷结构
         GetPaperReq getPaperReq = new GetPaperReq();
         getPaperReq.setExamId(examStudentEntity.getExamId());
         getPaperReq.setCourseCode(courseBean.getCode());
         getPaperReq.setGroupCode(examStudentEntity.getPaperType());
         GetPaperResp getPaperResp = extractConfigCloudService.getPaper(getPaperReq);
 
+        // 是否采用千人千卷规则
+        boolean randomPaper = CallType.RANDOM_PAPER.name().equals(examBean.getCallType());
+
+        DefaultPaper defaultPaper = getPaperResp.getDefaultPaper();
+        double paperScore = this.parsePaperScore(defaultPaper);
+
         //生成考试记录
-        ExamRecordDataEntity examRecordData = examRecordDataService.createOfflineExamRecordData(bean,
-                examBean, courseBean, getPaperResp.getPaperId(),
-                null, getPaperResp.getDefaultPaper().getFullyObjective());
+        ExamRecordDataEntity examRecordData = examRecordDataService.createOfflineExamRecordData(
+                bean, examBean, courseBean, getPaperResp.getPaperId(), defaultPaper.getFullyObjective(),
+                randomPaper, paperScore);
+
         //生成分数
         examScoreService.createExamScoreWithOffline(examRecordData.getId());
+
         //更新考生
         examStudentRepo.updateExamStudentFinished(examStudentId);
     }