|
@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.themis.business.bean.exam.ExamFileUploadBean;
|
|
import com.qmth.themis.business.bean.exam.ExamFileUploadBean;
|
|
import com.qmth.themis.business.bean.exam.ExamFinishBean;
|
|
import com.qmth.themis.business.bean.exam.ExamFinishBean;
|
|
import com.qmth.themis.business.bean.exam.ExamPrepareBean;
|
|
import com.qmth.themis.business.bean.exam.ExamPrepareBean;
|
|
|
|
+import com.qmth.themis.business.bean.exam.ExamResultBean;
|
|
import com.qmth.themis.business.bean.exam.ExamResumeBean;
|
|
import com.qmth.themis.business.bean.exam.ExamResumeBean;
|
|
import com.qmth.themis.business.bean.exam.ExamStartBean;
|
|
import com.qmth.themis.business.bean.exam.ExamStartBean;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
@@ -42,6 +43,7 @@ import com.qmth.themis.business.config.SystemConfig;
|
|
import com.qmth.themis.business.dao.TEExamMapper;
|
|
import com.qmth.themis.business.dao.TEExamMapper;
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
|
+import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamCourseService;
|
|
import com.qmth.themis.business.service.TEExamCourseService;
|
|
import com.qmth.themis.business.service.TEExamPaperService;
|
|
import com.qmth.themis.business.service.TEExamPaperService;
|
|
@@ -304,7 +306,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
ExamStudentPaperStructCacheBean struct = new ExamStudentPaperStructCacheBean();
|
|
ExamStudentPaperStructCacheBean struct = new ExamStudentPaperStructCacheBean();
|
|
struct.setContent(content);
|
|
struct.setContent(content);
|
|
@@ -331,7 +332,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
|
|
ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
|
|
RedisKeyHelper.examAnswerKey(recordId),
|
|
RedisKeyHelper.examAnswerKey(recordId),
|
|
@@ -352,16 +352,15 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
answerCache.setVersion(version);
|
|
answerCache.setVersion(version);
|
|
answerCache.setDuration(durationSeconds);
|
|
answerCache.setDuration(durationSeconds);
|
|
}
|
|
}
|
|
- //每次提交,清空得分
|
|
|
|
|
|
+ // 每次提交,清空得分
|
|
answerCache.setScore(null);
|
|
answerCache.setScore(null);
|
|
// 更新考生作答
|
|
// 更新考生作答
|
|
redisUtil.set(RedisKeyHelper.examAnswerKey(recordId),
|
|
redisUtil.set(RedisKeyHelper.examAnswerKey(recordId),
|
|
RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex), answerCache);
|
|
RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex), answerCache);
|
|
- //重置考试记录客观题得分
|
|
|
|
|
|
+ // 重置考试记录客观题得分
|
|
ExamRecordCacheUtil.setObjectiveScore(recordId, null);
|
|
ExamRecordCacheUtil.setObjectiveScore(recordId, null);
|
|
return version;
|
|
return version;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Integer audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count) {
|
|
public Integer audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count) {
|
|
@@ -379,7 +378,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
// 音频剩余播放次数缓存
|
|
// 音频剩余播放次数缓存
|
|
redisUtil.set(RedisKeyHelper.audioLeftPlayCountKey(recordId), key, count);
|
|
redisUtil.set(RedisKeyHelper.audioLeftPlayCountKey(recordId), key, count);
|
|
@@ -403,7 +401,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
String filePath = "upload/" + sdf.format(new Date()) + "/" + uuid() + ".json";
|
|
String filePath = "upload/" + sdf.format(new Date()) + "/" + uuid() + ".json";
|
|
InputStream in = null;
|
|
InputStream in = null;
|
|
@@ -452,7 +449,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
Long paperId = ExamRecordCacheUtil.getPaperId(recordId);
|
|
Long paperId = ExamRecordCacheUtil.getPaperId(recordId);
|
|
ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
|
|
ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(paperId);
|
|
@@ -539,20 +535,24 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (studentId.equals(es.getStudentId())) {
|
|
if (studentId.equals(es.getStudentId())) {
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
|
|
+ Date now = new Date();
|
|
ExamFinishBean ret = new ExamFinishBean();
|
|
ExamFinishBean ret = new ExamFinishBean();
|
|
- ret.setFinishTime(new Date().getTime());
|
|
|
|
|
|
+ ret.setFinishTime(now.getTime());
|
|
ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
|
|
ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
|
|
// TODO
|
|
// TODO
|
|
ret.setReviewResult("");
|
|
ret.setReviewResult("");
|
|
- return null;
|
|
|
|
|
|
+ ExamRecordCacheUtil.setFinishTime(recordId, now);
|
|
|
|
+ ExamRecordCacheUtil.setDurationSeconds(recordId, durationSeconds);
|
|
|
|
+ ExamRecordCacheUtil.setFinishType(recordId, FinishTypeEnum.valueOf(type.toLowerCase()));
|
|
|
|
+ ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.finished);
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Cacheable(value = "exam", key = "#examId", unless = "#result == null")
|
|
@Cacheable(value = "exam", key = "#examId", unless = "#result == null")
|
|
@Override
|
|
@Override
|
|
public ExamCacheBean getExamCacheBean(Long examId) {
|
|
public ExamCacheBean getExamCacheBean(Long examId) {
|
|
- ExamCacheBean ret=null;
|
|
|
|
|
|
+ ExamCacheBean ret = null;
|
|
TEExam exam = getById(examId);
|
|
TEExam exam = getById(examId);
|
|
if (exam == null) {
|
|
if (exam == null) {
|
|
return ret;
|
|
return ret;
|
|
@@ -561,4 +561,30 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
BeanUtils.copyProperties(exam, ret);
|
|
BeanUtils.copyProperties(exam, ret);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ExamResultBean result(Long studentId, Long recordId) {
|
|
|
|
+ // 校验当前登录用户和参数一致性
|
|
|
|
+ if (ExamRecordCacheUtil.getId(recordId) == null) {
|
|
|
|
+ throw new BusinessException("未找到考试记录");
|
|
|
|
+ }
|
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
|
|
|
|
+ .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
|
|
+ if (es == null) {
|
|
|
|
+ throw new BusinessException("未找到考生");
|
|
|
|
+ }
|
|
|
|
+ if (studentId.equals(es.getStudentId())) {
|
|
|
|
+ throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamResultBean ret=new ExamResultBean();
|
|
|
|
+ ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
|
|
|
|
+ ret.setFinishTime(ExamRecordCacheUtil.getFinishTime(recordId));
|
|
|
|
+ ret.setFinishType(ExamRecordCacheUtil.getFinishType(recordId));
|
|
|
|
+ ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
|
|
|
|
+ //TODO
|
|
|
|
+ ret.setReviewResult("");
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
}
|
|
}
|