|
@@ -1,14 +1,9 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.student.api.controller;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.ExamStudentQuestionInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
|
|
|
-import cn.com.qmth.examcloud.support.examing.*;
|
|
|
-import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
|
|
|
-import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamQuestion;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -32,12 +27,6 @@ public class ExamQuestionController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
private ExamRecordQuestionsService examRecordQuestionsService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ExamingSessionService examingSessionService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RedisClient redisClient;
|
|
|
-
|
|
|
/**
|
|
|
* 将mongodb中的答过的题和redis中的题目列表合并返回给前端
|
|
|
* 返回给前端时注意将正确答案和得分置成null
|
|
@@ -48,27 +37,7 @@ public class ExamQuestionController extends ControllerSupport {
|
|
|
@GetMapping("/findExamQuestionList")
|
|
|
public List<ExamQuestion> findExamQuestionList() {
|
|
|
User user = getAccessUser();
|
|
|
- ExamingSession examSessionInfo = examingSessionService.getExamingSession(user.getUserId());
|
|
|
- if (examSessionInfo == null
|
|
|
- || examSessionInfo.getExamingStatus().equals(ExamingStatus.INFORMAL)) {
|
|
|
- throw new StatusException("1001", "考试会话已过期,请重新开考");
|
|
|
- }
|
|
|
-
|
|
|
- String examingHeartbeatKey = RedisKeyHelper.getBuilder().examingHeartbeatKey(examSessionInfo.getExamRecordDataId());
|
|
|
- ExamingHeartbeat examingHeartbeat = redisClient.get(examingHeartbeatKey, ExamingHeartbeat.class);
|
|
|
-
|
|
|
- if (null != examingHeartbeat
|
|
|
- && examingHeartbeat.getCost() >= examSessionInfo.getExamDuration()) {
|
|
|
- throw new StatusException("1001", "考试会话已过期,请重新开考");
|
|
|
- }
|
|
|
-
|
|
|
- ExamRecordQuestions qers = examRecordQuestionsService.getExamRecordQuestions(examSessionInfo.getExamRecordDataId());
|
|
|
- List<ExamQuestion> examQuestionList = qers.getExamQuestions();
|
|
|
- for (ExamQuestion examQuestion : examQuestionList) {
|
|
|
- examQuestion.setCorrectAnswer(null);
|
|
|
- examQuestion.setStudentScore(null);
|
|
|
- }
|
|
|
- return examQuestionList;
|
|
|
+ return examRecordQuestionsService.findExamQuestionList(user.getUserId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -81,7 +50,6 @@ public class ExamQuestionController extends ControllerSupport {
|
|
|
@GetMapping("/getQuestionContent")
|
|
|
public String getQuestionContent(@RequestParam String questionId) {
|
|
|
User user = getAccessUser();
|
|
|
- Check.isBlank(questionId, "questionId不能为空");
|
|
|
return examRecordQuestionsService.getQuestionContent(user.getUserId(), questionId);
|
|
|
}
|
|
|
|