|
@@ -363,7 +363,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
* 根据设定几率取出一套试卷
|
|
* 根据设定几率取出一套试卷
|
|
*/
|
|
*/
|
|
private int getPaperByWeight(List<Double> paperWeight) {
|
|
private int getPaperByWeight(List<Double> paperWeight) {
|
|
- BigDecimal r = new BigDecimal(new Random().nextInt(101));
|
|
|
|
|
|
+ BigDecimal r = new BigDecimal(new Random().nextInt(101));
|
|
for (int i = 0; i < paperWeight.size(); i++) {
|
|
for (int i = 0; i < paperWeight.size(); i++) {
|
|
r = r.subtract(new BigDecimal(paperWeight.get(i)));
|
|
r = r.subtract(new BigDecimal(paperWeight.get(i)));
|
|
if (r.doubleValue() <= 0.0d) {
|
|
if (r.doubleValue() <= 0.0d) {
|
|
@@ -386,6 +386,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
|
|
throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD);
|
|
}
|
|
}
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
|
|
ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
|
|
.get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
.get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
if (es == null) {
|
|
if (es == null) {
|
|
@@ -398,6 +399,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (es.getEnable().intValue() == 0) {
|
|
if (es.getEnable().intValue() == 0) {
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_ENABLE);
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_ENABLE);
|
|
}
|
|
}
|
|
|
|
+ Boolean finished = toeExamRecordService.sendExamBreakMsg(recordId, false);
|
|
|
|
+ if (finished) {
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
ExamCacheBean exam = getExamCacheBeanNative(es.getExamId());
|
|
ExamCacheBean exam = getExamCacheBeanNative(es.getExamId());
|
|
Long activityId = es.getExamActivityId();
|
|
Long activityId = es.getExamActivityId();
|
|
ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(activityId);
|
|
ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(activityId);
|
|
@@ -470,25 +475,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
- Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ? 0 : ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
|
- //获取断点时间
|
|
|
|
- Long lastBreakTime = ExamRecordCacheUtil.getLastBreakTime(recordId);
|
|
|
|
- //获取剩余断点次数
|
|
|
|
- Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ? 0 : ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
|
|
|
|
- Integer leftBreakResumeCount = exam.getBreakResumeCount() - alreadyBreakCount;
|
|
|
|
- Integer breakExpireSeconds = Objects.isNull(exam.getBreakExpireSeconds()) ? 0 : exam.getBreakExpireSeconds();
|
|
|
|
- //如果断点时间大于整体断点时间,则强制交卷
|
|
|
|
- if (Objects.nonNull(lastBreakTime) && (System.currentTimeMillis() - lastBreakTime) / 1000 > breakExpireSeconds) {
|
|
|
|
- finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
- } else {
|
|
|
|
- //如果断点次数小于0,也强制交卷
|
|
|
|
- if (leftBreakResumeCount <= 0) {
|
|
|
|
- finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
ret = new ExamStartBean();
|
|
ret = new ExamStartBean();
|
|
ret.setPaperDecryptSecret(ep.getDecryptSecret());
|
|
ret.setPaperDecryptSecret(ep.getDecryptSecret());
|
|
ret.setPaperDecryptVector(ep.getDecryptVector());
|
|
ret.setPaperDecryptVector(ep.getDecryptVector());
|
|
@@ -526,6 +512,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
calendar.add(Calendar.SECOND, finalMaxDurationSeconds.intValue());
|
|
calendar.add(Calendar.SECOND, finalMaxDurationSeconds.intValue());
|
|
}
|
|
}
|
|
Integer breakResumeCount = exam.getBreakResumeCount();
|
|
Integer breakResumeCount = exam.getBreakResumeCount();
|
|
|
|
+ Integer breakExpireSeconds = Objects.isNull(exam.getBreakExpireSeconds()) ? 0 : exam.getBreakExpireSeconds();
|
|
Long finalFinishTime = (calendar.getTime().getTime() / 1000 + (breakResumeCount * breakExpireSeconds) + (breakResumeCount * 180)) * 1000;
|
|
Long finalFinishTime = (calendar.getTime().getTime() / 1000 + (breakResumeCount * breakExpireSeconds) + (breakResumeCount * 180)) * 1000;
|
|
ExamRecordCacheUtil.setExamFinalFinishTime(recordId, finalFinishTime);
|
|
ExamRecordCacheUtil.setExamFinalFinishTime(recordId, finalFinishTime);
|
|
//新增quartz任务,发送mq消息start
|
|
//新增quartz任务,发送mq消息start
|
|
@@ -789,25 +776,13 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
|
|
if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
|
|
throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
|
|
throw new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_STUDENT);
|
|
}
|
|
}
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
- Integer durationSeconds = Objects.isNull(ExamRecordCacheUtil.getDurationSeconds(recordId)) ? 0 : ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
|
- //获取断点时间
|
|
|
|
- Long lastBreakTime = ExamRecordCacheUtil.getLastBreakTime(recordId);
|
|
|
|
- //获取剩余断点次数
|
|
|
|
- Integer alreadyBreakCount = Objects.isNull(ExamRecordCacheUtil.getAlreadyBreakCount(recordId)) ? 0 : ExamRecordCacheUtil.getAlreadyBreakCount(recordId);
|
|
|
|
- Integer leftBreakResumeCount = ec.getBreakResumeCount() - alreadyBreakCount;
|
|
|
|
- Integer breakExpireSeconds = Objects.isNull(ec.getBreakExpireSeconds()) ? 0 : ec.getBreakExpireSeconds();
|
|
|
|
- //如果断点时间大于整体断点时间,则强制交卷
|
|
|
|
- if (Objects.nonNull(lastBreakTime) && (System.currentTimeMillis() - lastBreakTime) / 1000 > breakExpireSeconds) {
|
|
|
|
- finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
- } else {
|
|
|
|
- //如果断点次数小于0,也强制交卷
|
|
|
|
- if (leftBreakResumeCount <= 0) {
|
|
|
|
- finish(examStudentCacheBean.getStudentId(), recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- ExamResumeBean ret = new ExamResumeBean();
|
|
|
|
|
|
+ ExamResumeBean ret = null;
|
|
|
|
+ Boolean finished = toeExamRecordService.sendExamBreakMsg(recordId, false);
|
|
|
|
+ if (finished) {
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ ret = new ExamResumeBean();
|
|
ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
|
|
ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
|
|
ret.setPaperUrl(OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getPaperPath()));
|
|
ret.setPaperUrl(OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getPaperPath()));
|
|
ret.setStructUrl(OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getStructPath()));
|
|
ret.setStructUrl(OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getStructPath()));
|
|
@@ -1246,7 +1221,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
toeExamRecordService.calculateScore(rc.getId());
|
|
toeExamRecordService.calculateScore(rc.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Double progress=getPercentage(index, total);
|
|
|
|
|
|
+ Double progress = getPercentage(index, total);
|
|
task.setProgress(progress);
|
|
task.setProgress(progress);
|
|
teExamMapper.updateScoreProgress(progress, examId);
|
|
teExamMapper.updateScoreProgress(progress, examId);
|
|
tbTaskHistoryService.saveOrUpdate(task);
|
|
tbTaskHistoryService.saveOrUpdate(task);
|
|
@@ -1287,7 +1262,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
if (b == 0) {
|
|
if (b == 0) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- Double da = Double.valueOf(a*100);
|
|
|
|
|
|
+ Double da = Double.valueOf(a * 100);
|
|
Double db = Double.valueOf(b);
|
|
Double db = Double.valueOf(b);
|
|
BigDecimal bd = new BigDecimal(da / db);
|
|
BigDecimal bd = new BigDecimal(da / db);
|
|
Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
Double tem = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|