소스 검색

离线考试也需要校验考试是否特殊设置
在线考试考试校验bug修复,组织机构用学生的

lideyin 5 년 전
부모
커밋
bb8f5e061c

+ 8 - 7
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamControlServiceImpl.java

@@ -285,7 +285,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         Long examId = examRecordData.getExamId();
         Long orgId = examRecordData.getOrgId();
 
-        if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId,  studentId)) {
+        if (FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId)) {
             SaveExamCaptureSyncCompareResultReq req = new SaveExamCaptureSyncCompareResultReq();
             req.setExamRecordDataId(examRecordData.getId());
             req.setStudentId(user.getUserId());
@@ -410,10 +410,10 @@ public class ExamControlServiceImpl implements ExamControlService {
      */
     private Integer getFaceVerifyMinute(Long rootOrgId, Long examId, Long orgId, Long studentId) {
         // 如果开启了活体检测
-        if (FaceBiopsyHelper.isFaceVerify(rootOrgId, examId,  studentId)) {
+        if (FaceBiopsyHelper.isFaceVerify(rootOrgId, examId, studentId)) {
             // 开始分钟数
             String startMinuteStr = ExamCacheTransferHelper
-                    .getCachedExamProperty(examId,  studentId, ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
+                    .getCachedExamProperty(examId, studentId, ExamProperties.FACE_VERIFY_START_MINUTE.name()).getValue();
             if (CommonUtil.isBlank(startMinuteStr)) {
                 throw new StatusException("ExamControlServiceImpl-getFaceVerifyMinute-001",
                         ExamProperties.FACE_VERIFY_START_MINUTE.getDesc() + "未设置");
@@ -450,11 +450,10 @@ public class ExamControlServiceImpl implements ExamControlService {
      */
     private ExamBean checkExam(ExamStudentEntity examStudentEntity) {
         Long examId = examStudentEntity.getExamId();
-        Long orgId = examStudentEntity.getOrgId();
         Long studentId = examStudentEntity.getStudentId();
 
         // 学习中心特殊考试配置(是否禁考,开考时间可以特殊设置)
-        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId,  studentId);
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId, studentId);
 
         //如果启用了了特殊设置,并且无特殊设置时结束考试 配置 设置为true..且实际未设置特殊设置则不允许考试
         ExamPropertyCacheBean limitedIfNoSpecialSettings = ExamCacheTransferHelper.getDefaultCachedExamProperty(examId,
@@ -472,6 +471,8 @@ public class ExamControlServiceImpl implements ExamControlService {
 
             //机构特殊设置开启未配置,不允许考试
             if (examBean.getSpecialSettingsType() == ExamSpecialSettingsType.ORG_BASED) {
+                //需求调整,所有的组织机构取学生表所关联的orgId
+                Long orgId = CacheHelper.getStudent(studentId).getOrgId();
                 ExamOrgSettingsCacheBean specialSettings = CacheHelper.getExamOrgSettings(examId, orgId);
                 if (!specialSettings.getHasValue()) {
                     throw new StatusException("100015", "考试配置未完成,不允许考试");
@@ -520,7 +521,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         examSessionInfo.setPaperType(examStudent.getPaperType());
         // EXAM_RECONNECT_TIME:断点续考时间
         String examReconnectTimeStr = ExamCacheTransferHelper
-                .getCachedExamProperty(examBean.getId(),  examStudent.getStudentId(),
+                .getCachedExamProperty(examBean.getId(), examStudent.getStudentId(),
                         ExamProperties.EXAM_RECONNECT_TIME.name()).getValue();
         log.debug("11.2 断点时间:" + examReconnectTimeStr);
         if (CommonUtil.isBlank(examReconnectTimeStr)) {
@@ -530,7 +531,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         examSessionInfo.setExamReconnectTime(Integer.valueOf(examReconnectTimeStr));
         // FREEZE_TIME:冻结时间
         String freezeTimeStr = ExamCacheTransferHelper
-                .getCachedExamProperty(examBean.getId(),  examStudent.getStudentId(),
+                .getCachedExamProperty(examBean.getId(), examStudent.getStudentId(),
                         ExamProperties.FREEZE_TIME.name()).getValue();
         log.debug("11.3 冻结时间:" + freezeTimeStr);
         if (CommonUtil.isBlank(freezeTimeStr)) {

+ 33 - 6
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/OfflineExamServiceImpl.java

@@ -1,8 +1,10 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.HttpClientUtil;
 import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.oe.common.enums.ExamProperties;
 import cn.com.qmth.examcloud.core.oe.common.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordForMarkingEntity;
@@ -25,8 +27,7 @@ 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.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
-import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
-import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
+import cn.com.qmth.examcloud.support.cache.bean.*;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import main.java.com.UpYun;
 import org.apache.commons.io.FileUtils;
@@ -100,7 +101,7 @@ public class OfflineExamServiceImpl implements OfflineExamService {
         List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentId(studentId);
         List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<OfflineExamCourseInfo>();
         for (ExamStudentEntity examStudent : examStudents) {
-            ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),studentId);
+            ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(), studentId);
             if (!ExamType.OFFLINE.name().equals(examBean.getExamType())) {
                 continue;
             }
@@ -202,8 +203,34 @@ public class OfflineExamServiceImpl implements OfflineExamService {
     }
 
     private ExamBean checkExam(ExamStudentEntity examStudentEntity) {
-        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
-                examStudentEntity.getStudentId());
+        Long examId = examStudentEntity.getExamId();
+        Long studentId = examStudentEntity.getStudentId();
+        ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examId, studentId);
+
+        //如果启用了了特殊设置,并且无特殊设置时结束考试 配置 设置为true..且实际未设置特殊设置则不允许考试
+        ExamPropertyCacheBean limitedIfNoSpecialSettings = ExamCacheTransferHelper.getDefaultCachedExamProperty(examId,
+                ExamProperties.LIMITED_IF_NO_SPECIAL_SETTINGS.toString());
+        if (examBean.getSpecialSettingsEnabled() &&
+                (limitedIfNoSpecialSettings.getHasValue() && Boolean.valueOf(limitedIfNoSpecialSettings.getValue()))) {
+
+            //学生特殊设置开启未配置,不允许考试
+            if (examBean.getSpecialSettingsType() == ExamSpecialSettingsType.STUDENT_BASED) {
+                ExamStudentSettingsCacheBean specialSettings = CacheHelper.getExamStudentSettings(examId, studentId);
+                if (!specialSettings.getHasValue()) {
+                    throw new StatusException("100014", "考试配置未完成,不允许考试");
+                }
+            }
+
+            //机构特殊设置开启未配置,不允许考试
+            if (examBean.getSpecialSettingsType() == ExamSpecialSettingsType.ORG_BASED) {
+                //需求调整,所有的组织机构取学生表所关联的orgId
+                Long orgId = CacheHelper.getStudent(studentId).getOrgId();
+                ExamOrgSettingsCacheBean specialSettings = CacheHelper.getExamOrgSettings(examId, orgId);
+                if (!specialSettings.getHasValue()) {
+                    throw new StatusException("100015", "考试配置未完成,不允许考试");
+                }
+            }
+        }
 
         if (!examBean.getEnable() || (examBean.getExamLimit() != null && examBean.getExamLimit())) {
             throw new StatusException("ExamControlServiceImpl-checkExam-exception-01", "暂无考试资格,请与学校老师联系");
@@ -265,7 +292,7 @@ public class OfflineExamServiceImpl implements OfflineExamService {
             byte[] bs;
             try {
                 bs = HttpClientUtil.get(fileUrl);
-            }catch (Exception e){
+            } catch (Exception e) {
                 System.err.println((i + 1) + "文件:" + fileEntity.getFileUrl() + "下载失败,继续下一个文件...");
                 e.printStackTrace();
                 continue;