소스 검색

no change

deason 2 년 전
부모
커밋
645b757d1f

+ 1 - 1
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/ExamControlController.java

@@ -137,7 +137,7 @@ public class ExamControlController extends ControllerSupport {
         String referer = request.getHeader("REFERER");
         String agent = request.getHeader("USER-AGENT");
         String timestampStr = request.getHeader(CryptoConstant.TIMESTAMP);
-        examRecordQuestionsService.submitQuestionAnswerWithCrypto(data, user, referer, agent, timestampStr);
+        examRecordQuestionsService.submitQuestionAnswerWithCrypto(data, user, referer, agent, timestampStr, getIp(request));
     }
 
     /**

+ 1 - 1
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/ExamQuestionController.java

@@ -75,7 +75,7 @@ public class ExamQuestionController extends ControllerSupport {
 
         String referer = request.getHeader("REFERER");
         String agent = request.getHeader("USER-AGENT");
-        examRecordQuestionsService.submitQuestionAnswer(user.getUserId(), examQuestionInfos, referer, agent);
+        examRecordQuestionsService.submitQuestionAnswer(user.getUserId(), examQuestionInfos, referer, agent, getIp(request));
     }
 
 }

+ 1 - 1
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/client/ExamProcessController.java

@@ -143,7 +143,7 @@ public class ExamProcessController extends ControllerSupport {
         User user = getAccessUser();
         String referer = request.getHeader("REFERER");
         String agent = request.getHeader("USER-AGENT") + "client-" + Constants.ELECTRON_EXAM_SHELL;
-        examRecordQuestionsService.submitQuestionAnswer(user.getUserId(), examQuestionInfos, referer, agent);
+        examRecordQuestionsService.submitQuestionAnswer(user.getUserId(), examQuestionInfos, referer, agent, getIp(request));
     }
 
     @ApiOperation(value = "获取课程信息")

+ 2 - 0
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamControlService.java

@@ -65,6 +65,8 @@ public interface ExamControlService {
      */
     long examHeartbeat(User user, String ip);
 
+    void setAndSaveActiveTime(Long examRecordDataId, String ip);
+
     /**
      * 获取考试结束后的相关信息
      *

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

@@ -41,13 +41,13 @@ public interface ExamRecordQuestionsService {
 
     String getQuestionContentForClient(Long studentId, String questionId);
 
-    void submitQuestionAnswer(Long studentId, List<ExamStudentQuestionInfo> examQuestionInfos, String referer, String agent);
+    void submitQuestionAnswer(Long studentId, List<ExamStudentQuestionInfo> examQuestionInfos, String referer, String agent, String ip);
 
     /**
      * 考生作答(新)
      * 注:需要加、解密
      */
-    void submitQuestionAnswerWithCrypto(ExamStudentQuestionAnswerInfo data, User user, String referer, String agent, String timestampStr);
+    void submitQuestionAnswerWithCrypto(ExamStudentQuestionAnswerInfo data, User user, String referer, String agent, String timestampStr, String ip);
 
     GetExamRecordQuestionsResp getExamRecordQuestions(GetExamRecordQuestionsReq req);
 

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

@@ -511,8 +511,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             return 0;
         }
 
-        boolean isContinued =
-                (examRecordDataCache.getIsContinued() != null && examRecordDataCache.getIsContinued()) ? true : false;
+        boolean isContinued = examRecordDataCache.getIsContinued() != null && examRecordDataCache.getIsContinued();
 
         Date now = new Date();
         long usedExamSeconds = 0;
@@ -1925,8 +1924,7 @@ public class ExamControlServiceImpl implements ExamControlService {
             throw new StatusException("101003", "考试会话已过期,请重新开考");
         }
 
-        boolean isContinued =
-                (examRecordDataCache.getIsContinued() != null && examRecordDataCache.getIsContinued()) ? true : false;
+        boolean isContinued = examRecordDataCache.getIsContinued() != null && examRecordDataCache.getIsContinued();
 
         //如果有断点续考,需要校验是否先调用作答接口
         if (isContinued) {
@@ -1973,7 +1971,8 @@ public class ExamControlServiceImpl implements ExamControlService {
      *
      * @param examRecordDataId 考试记录id
      */
-    private void setAndSaveActiveTime(Long examRecordDataId, String ip) {
+    @Override
+    public void setAndSaveActiveTime(Long examRecordDataId, String ip) {
         String examingActiveTimeKey = RedisKeyHelper.getBuilder()
                 .examingActiveTimeKey(examRecordDataId);
         ExamingActivityTime examingActiveTime = redisClient.get(examingActiveTimeKey, ExamingActivityTime.class);

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

@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.oe.student.bean.ExamStudentQuestionAnswerInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.ExamStudentQuestionInfo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamRecordQuestionTempRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamQuestionTempEntity;
+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.ExamRecordQuestionsService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
@@ -79,6 +80,9 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
     @Autowired
     private ExamRecordDataService examRecordDataService;
 
+    @Autowired
+    private ExamControlService examControlService;
+
     @Autowired
     private CryptoFactory cryptoFactory;
 
@@ -294,7 +298,7 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
     }
 
     @Override
-    public void submitQuestionAnswer(Long studentId, List<ExamStudentQuestionInfo> examQuestionInfos, String referer, String agent) {
+    public void submitQuestionAnswer(Long studentId, List<ExamStudentQuestionInfo> examQuestionInfos, String referer, String agent, String ip) {
         if (CollectionUtils.isEmpty(examQuestionInfos)) {
             log.warn("submitQuestionAnswer is empty. studentId = {} ", studentId);
             return;
@@ -346,7 +350,7 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
     }
 
     @Override
-    public void submitQuestionAnswerWithCrypto(ExamStudentQuestionAnswerInfo data, User user, String referer, String agent, String timestampStr) {
+    public void submitQuestionAnswerWithCrypto(ExamStudentQuestionAnswerInfo data, User user, String referer, String agent, String timestampStr, String ip) {
         long timestamp;
         try {
             timestamp = CryptoHelper.parseTimestamp(timestampStr);
@@ -373,7 +377,7 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
 
         List<ExamStudentQuestionInfo> answers = new JsonMapper().toList(data.getAnswers(), ExamStudentQuestionInfo.class);
 
-        this.submitQuestionAnswer(user.getUserId(), answers, referer, agent);
+        this.submitQuestionAnswer(user.getUserId(), answers, referer, agent, ip);
     }
 
     @Override