|
@@ -21,7 +21,6 @@ import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.enums.ExamProperties;
|
|
|
import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
-import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -186,16 +185,16 @@ public class ExamProcessController extends ControllerSupport {
|
|
|
|
|
|
Optional<ExamRecordDataEntity> optional = examRecordDataRepo.findById(examRecordDataId);
|
|
|
if (!optional.isPresent()) {
|
|
|
- throw new StatusException("000500", "考试记录不存在");
|
|
|
+ throw new StatusException("400403", "考试记录不存在");
|
|
|
}
|
|
|
|
|
|
ExamRecordDataEntity examRecordData = optional.get();
|
|
|
if (ExamType.OFFLINE != examRecordData.getExamType()) {
|
|
|
- throw new StatusException("000500", "非离线考试");
|
|
|
+ throw new StatusException("400403", "非离线考试");
|
|
|
}
|
|
|
|
|
|
if (!examStudentService.isEnableExamStudent(examRecordData.getExamStudentId())) {
|
|
|
- throw new StatusException("000500", "当前考生已禁用");
|
|
|
+ throw new StatusException("400403", "当前考生已禁用");
|
|
|
}
|
|
|
|
|
|
// 当前考试允许的附件类型,示例:["ZIP","PDF","IMAGE"]
|
|
@@ -203,10 +202,10 @@ public class ExamProcessController extends ControllerSupport {
|
|
|
examRecordData.getStudentId(), ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name());
|
|
|
String[] settingFileTypes = new JsonMapper().toArray(examProperty.getValue(), String.class);
|
|
|
if (ArrayUtils.isEmpty(settingFileTypes)) {
|
|
|
- throw new StatusException("000500", "当前考试设置不允许上传附件");
|
|
|
+ throw new StatusException("400403", "当前考试设置不允许上传附件");
|
|
|
}
|
|
|
if (!matchFileTypes(settingFileTypes, fileSuffix)) {
|
|
|
- throw new StatusException("000500", "当前考试允许上传文件格式为:" + examProperty.getValue());
|
|
|
+ throw new StatusException("400403", "当前考试允许上传文件格式为:" + examProperty.getValue());
|
|
|
}
|
|
|
|
|
|
// todo
|
|
@@ -223,7 +222,41 @@ public class ExamProcessController extends ControllerSupport {
|
|
|
@ApiParam(value = "考试记录id") @RequestParam Long examRecordDataId,
|
|
|
@ApiParam(value = "文件类型:ZIP/PDF/IMAGE") @RequestParam String fileType,
|
|
|
@ApiParam(value = "md5加密的文件摘要") @RequestParam String[] fileMd5Array) throws Exception {
|
|
|
+ Check.isNull(fileArray, "上传文件不能为空");
|
|
|
|
|
|
+ if (fileArray.length != fileMd5Array.length) {
|
|
|
+ throw new StatusException("400401", "文件数量和文件摘要信息不匹配");
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<ExamRecordDataEntity> optional = examRecordDataRepo.findById(examRecordDataId);
|
|
|
+ if (!optional.isPresent()) {
|
|
|
+ throw new StatusException("400403", "考试记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamRecordDataEntity examRecordData = optional.get();
|
|
|
+ if (ExamType.OFFLINE != examRecordData.getExamType()) {
|
|
|
+ throw new StatusException("400403", "非离线考试");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!examStudentService.isEnableExamStudent(examRecordData.getExamStudentId())) {
|
|
|
+ throw new StatusException("400403", "当前考生已禁用");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当前考试允许的附件类型,示例:["ZIP","PDF","IMAGE"]
|
|
|
+ ExamPropertyCacheBean examProperty = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(),
|
|
|
+ examRecordData.getStudentId(), ExamProperties.OFFLINE_UPLOAD_FILE_TYPE.name());
|
|
|
+ String[] settingFileTypes = new JsonMapper().toArray(examProperty.getValue(), String.class);
|
|
|
+ if (ArrayUtils.isEmpty(settingFileTypes)) {
|
|
|
+ throw new StatusException("400403", "当前考试设置不允许上传附件");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // todo
|
|
|
+ // offlineExamService.batchSubmitPaper(examRecordDataId, resultFiles, fileType);
|
|
|
+
|
|
|
+ User user = getAccessUser();
|
|
|
+ ReportsUtil.report(new AdminOperateReport(user.getRootOrgId(), user.getUserId(), "考试进度详情-上传作答",
|
|
|
+ "考试记录ID:" + examRecordDataId + " 考生ID:" + examRecordData.getExamStudentId()));
|
|
|
}
|
|
|
|
|
|
private boolean matchFileTypes(String[] settingFileTypes, String fileSuffix) {
|