|
@@ -219,7 +219,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
ExamStudentCacheBean examStudent = CacheHelper.getExamStudent(examStudentId);
|
|
|
ExamRecordData examRecordData = examRecordDataService.createExamRecordData(examingSession, examBean, courseBean,
|
|
|
paperId, extractConfigPaper.getDefaultPaper().getFullyObjective(),
|
|
|
- examStudent.getStudentId(), examStudent.getExamStageOrder());
|
|
|
+ examStudent.getExamStageId(), examStudent.getExamStageOrder());
|
|
|
|
|
|
// 如果开启人脸比对,将同步人脸比对结果存储到抓后结果表中
|
|
|
Long rootOrgId = examRecordData.getRootOrgId();
|
|
@@ -338,6 +338,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
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);
|
|
|
|
|
@@ -375,7 +376,6 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
resultInfo.setDuration(examingSession.getExamDuration());
|
|
|
return resultInfo;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -392,7 +392,19 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
Long examId = examRecordData.getExamId();
|
|
|
Long studentId = examRecordData.getStudentId();
|
|
|
Long examStageId = examRecordData.getExamStageId();
|
|
|
+ return this.calcExamTotalMilliSeconds(examId, studentId, examStageId, examRecordData.getStartTime());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算单次考试总时长(毫秒)
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param studentId
|
|
|
+ * @param examStageId
|
|
|
+ * @param startAnswerTime 开始答题时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private long calcExamTotalMilliSeconds(Long examId, Long studentId, Long examStageId, Date startAnswerTime) {
|
|
|
ExamSettingsCacheBean cachedExam = ExamCacheTransferHelper.getCachedExam(examId, studentId, examStageId);
|
|
|
//如果未启用特殊设置,直接返回考试设置的默认考试时长
|
|
|
if (!cachedExam.getSpecialSettingsEnabled()) {
|
|
@@ -412,16 +424,14 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
return originalExamTotalSeconds;
|
|
|
}
|
|
|
|
|
|
- if (SubmitType.NORMAL.name() == examStage.getSubmitType()) {
|
|
|
+ if (SubmitType.NORMAL.name().equals(examStage.getSubmitType())) {
|
|
|
return originalExamTotalSeconds;
|
|
|
}
|
|
|
|
|
|
//如果是定点交卷需要特殊处理,否则直接返回考试中定义的考试时长
|
|
|
- if (examStage.getSpecialSetting() && SubmitType.TIMING_END.name() == examStage.getSubmitType()) {
|
|
|
+ if (examStage.getSpecialSetting() && SubmitType.TIMING_END.name().equals(examStage.getSubmitType())) {
|
|
|
//定点交卷时间 = 开始进入考试的起始值 + 定点交卷时长
|
|
|
Date fixedSubmitTime = DateUtils.addMinutes(examStage.getStartTime(), examStage.getSubmitDuration());
|
|
|
- //实际开始答题时间
|
|
|
- Date startAnswerTime = examRecordData.getStartTime();
|
|
|
//理论上考试时长 = (定点交卷时间 - 实际开始答题时间)
|
|
|
long tempTotalSeconds = fixedSubmitTime.getTime() - startAnswerTime.getTime();
|
|
|
|
|
@@ -582,6 +592,14 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
if (null == freezeTime || !freezeTime.getHasValue()) {
|
|
|
throw new StatusException("100023", "交卷冻结时间未配置");
|
|
|
}
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ long totalMilliSeconds = calcExamTotalMilliSeconds(examStudent.getExamId(),
|
|
|
+ examStudent.getStudentId(), examStudent.getExamStageId(), now);
|
|
|
+ if (totalMilliSeconds <= 0) {
|
|
|
+ throw new StatusException("100024", "已超过定点交卷时间,不允许开考");
|
|
|
+ }
|
|
|
+
|
|
|
examingSession.setFreezeTime(StringUtil.toInteger(freezeTime.getValue()));
|
|
|
examingSession.setOrgId(studentCacheBean.getOrgId());
|
|
|
examingSession.setPaperType(examStudent.getPaperType());
|
|
@@ -1662,7 +1680,8 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
examSessionInfo.getExamId(), examSessionInfo.getExamStudentId()));
|
|
|
|
|
|
// 返回考试剩余时间
|
|
|
- return examSessionInfo.getExamDuration() - (examingHeartbeat.getCost() * 1000);
|
|
|
+ long leftTime = examSessionInfo.getExamDuration() - (examingHeartbeat.getCost() * 1000);
|
|
|
+ return leftTime < 0 ? 0 : leftTime;
|
|
|
}
|
|
|
|
|
|
/**
|