Răsfoiți Sursa

fix startAnswer api

deason 2 ani în urmă
părinte
comite
cae03b54d2

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

@@ -404,7 +404,7 @@ public class ExamControlServiceImpl implements ExamControlService {
         }
 
         ExamingSession examingSession = examingSessionService.getExamingSession(examRecordData.getStudentId());
-        if (null == examingSession) {
+        if (examingSession == null || ExamingStatus.INFORMAL.equals(examingSession.getExamingStatus())) {
             throw new StatusException("100002", "无效的会话,请离开考试");
         }
 
@@ -415,7 +415,6 @@ public class ExamControlServiceImpl implements ExamControlService {
         if (null == examRecordData.getIsContinued() || !examRecordData.getIsContinued()) {
             //如果已经调用过开始作答接口,则不做任何处理
             if (null != examRecordData.getStartTime()) {
-                examingSession = examingSessionService.getExamingSession(examRecordData.getStudentId());
                 resultInfo.setDuration(examingSession.getExamDuration());//直接返回考试会话中的考试时长
                 resultInfo.setUsedExamSeconds(calcUsedExamSeconds(examRecordData.getStudentId()));
                 return resultInfo;
@@ -427,12 +426,12 @@ public class ExamControlServiceImpl implements ExamControlService {
             examRecordDataService.saveExamRecordDataCache(examRecordDataId, examRecordData);
 
             //更新考试会话中的作答时间,实际考试总时长
-            examingSession = examingSessionService.getExamingSession(examRecordData.getStudentId());
             examingSession.setStartTime(now.getTime());
             long actualExamTotalMilliSeconds = calcExamTotalMilliSeconds(examRecordDataId);
             actualExamTotalMilliSeconds = actualExamTotalMilliSeconds < 0 ? 0 : actualExamTotalMilliSeconds;
             examingSession.setExamDuration(actualExamTotalMilliSeconds);
             examingSessionService.saveExamingSession(examRecordData.getStudentId(), examingSession);
+
             resultInfo.setUsedExamSeconds(calcUsedExamSeconds(examRecordData.getStudentId()));
             resultInfo.setDuration(actualExamTotalMilliSeconds);