Explorar o código

fix checkExamIsStarted 含未交卷情况

deason %!s(int64=3) %!d(string=hai) anos
pai
achega
1b8da1eb54

+ 16 - 2
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/ExamRecordCloudServiceProvider.java

@@ -11,6 +11,9 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.*;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordQuestionsService;
+import cn.com.qmth.examcloud.core.oe.student.api.ExamRecordDataCloudService;
+import cn.com.qmth.examcloud.core.oe.student.api.request.ExistExamRecordDataReq;
+import cn.com.qmth.examcloud.core.oe.student.api.response.ExistExamRecordDataResp;
 import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
 import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionStructure;
 import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
@@ -80,6 +83,8 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
     @Autowired
     private ExamRecordDataService examRecordDataService;
 
+    @Autowired
+    private ExamRecordDataCloudService examRecordDataCloudService;
 
     @Override
     @ApiOperation(value = "查询是否已经开考")
@@ -102,10 +107,19 @@ public class ExamRecordCloudServiceProvider extends ControllerSupport implements
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 
-        long count = examRecordDataRepo.count(specification);
+        Boolean existed = examRecordDataRepo.count(specification) > 0;
+        if (!existed) {
+            // 若不存在考试记录,则再去“考试记录临时表”中查询确认一次(未交卷情况)
+            ExistExamRecordDataReq existReq = new ExistExamRecordDataReq();
+            existReq.setExamId(req.getExamId());
+            existReq.setCourseId(req.getCourseId());
+            existReq.setStudentId(req.getStudentId());
+            ExistExamRecordDataResp resp = examRecordDataCloudService.existExamRecordData(existReq);
+            existed = resp.getExisted();
+        }
 
         CheckExamIsStartedResp resp = new CheckExamIsStartedResp();
-        resp.setIsStarted(count > 0);
+        resp.setIsStarted(existed);
         return resp;
     }