Просмотр исходного кода

fix 查询是否存在考试记录

deason 1 год назад
Родитель
Сommit
829c80ccf1

+ 19 - 5
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/provider/ExamRecordDataCloudServiceProvider.java

@@ -10,10 +10,8 @@ import cn.com.qmth.examcloud.core.oe.student.api.request.*;
 import cn.com.qmth.examcloud.core.oe.student.api.response.*;
 import cn.com.qmth.examcloud.core.oe.student.dao.*;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.*;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordPaperStructService;
-import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
+import cn.com.qmth.examcloud.core.oe.student.service.*;
+import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -63,6 +61,9 @@ public class ExamRecordDataCloudServiceProvider extends ControllerSupport implem
     @Autowired
     private ExamControlService examControlService;
 
+    @Autowired
+    private ExamingSessionService examingSessionService;
+
     @Override
     @ApiOperation(value = "查询是否存在考试记录")
     @PostMapping("/existExamRecordData")
@@ -87,7 +88,20 @@ public class ExamRecordDataCloudServiceProvider extends ControllerSupport implem
         };
 
         long count = examRecordDataRepo.count(specification);
-        return new ExistExamRecordDataResp(count > 0);
+        if (count > 0) {
+            // 存在考试记录
+            return new ExistExamRecordDataResp(true);
+        }
+
+        if (req.getStudentId() != null) {
+            ExamingSession examingSession = examingSessionService.getExamingSession(req.getStudentId());
+            if (examingSession != null) {
+                // 存在考试会话
+                return new ExistExamRecordDataResp(true);
+            }
+        }
+
+        return new ExistExamRecordDataResp(false);
     }
 
     @Override