|
@@ -6,10 +6,12 @@ import cn.com.qmth.stmms.api.utils.AESUtil;
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
|
|
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
import cn.com.qmth.stmms.biz.mark.model.MarkLibrary;
|
|
import cn.com.qmth.stmms.biz.mark.model.MarkLibrary;
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkLibraryService;
|
|
import cn.com.qmth.stmms.biz.mark.service.MarkLibraryService;
|
|
@@ -19,10 +21,7 @@ import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
import cn.com.qmth.stmms.common.annotation.RoleRequire;
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
-import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
|
-import cn.com.qmth.stmms.common.enums.ExamType;
|
|
|
|
-import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
|
-import cn.com.qmth.stmms.common.enums.Role;
|
|
|
|
|
|
+import cn.com.qmth.stmms.common.enums.*;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
|
|
|
import com.google.common.base.Strings;
|
|
import com.google.common.base.Strings;
|
|
@@ -67,6 +66,8 @@ public class ExamStudentController extends BaseApiController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private FileService fileService;
|
|
private FileService fileService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamSubjectService examSubjectService;
|
|
|
|
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
@RequestMapping(value = "/student/check", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/student/check", method = RequestMethod.POST)
|
|
@@ -123,7 +124,8 @@ public class ExamStudentController extends BaseApiController {
|
|
@RequestParam(required = false) Boolean withScoreDetail,
|
|
@RequestParam(required = false) Boolean withScoreDetail,
|
|
@RequestParam(required = false) Boolean withMarkTrack,
|
|
@RequestParam(required = false) Boolean withMarkTrack,
|
|
@RequestParam(required = false) Boolean withGroupScoreTrack,
|
|
@RequestParam(required = false) Boolean withGroupScoreTrack,
|
|
- @RequestParam(required = false) Boolean withSheetUrl, @RequestParam(required = false) Boolean sliceConfigFix) {
|
|
|
|
|
|
+ @RequestParam(required = false) Boolean withSheetUrl,
|
|
|
|
+ @RequestParam(required = false) Boolean sliceConfigFix) {
|
|
ApiUser user = RequestUtils.getApiUser(request);
|
|
ApiUser user = RequestUtils.getApiUser(request);
|
|
JSONArray array = new JSONArray();
|
|
JSONArray array = new JSONArray();
|
|
if (query.getExamId() == null) {
|
|
if (query.getExamId() == null) {
|
|
@@ -228,21 +230,17 @@ public class ExamStudentController extends BaseApiController {
|
|
}
|
|
}
|
|
// 返回评卷标记
|
|
// 返回评卷标记
|
|
if (withMarkTrack != null && withMarkTrack.booleanValue()) {
|
|
if (withMarkTrack != null && withMarkTrack.booleanValue()) {
|
|
- obj.accumulate(
|
|
|
|
- "tags",
|
|
|
|
- studentService.buildSheetTags(student, withGroupScoreTrack != null
|
|
|
|
- && withGroupScoreTrack.booleanValue(),
|
|
|
|
|
|
+ obj.accumulate("tags",
|
|
|
|
+ studentService.buildSheetTags(student,
|
|
|
|
+ withGroupScoreTrack != null && withGroupScoreTrack.booleanValue(),
|
|
sliceConfigFix != null && sliceConfigFix.booleanValue()));
|
|
sliceConfigFix != null && sliceConfigFix.booleanValue()));
|
|
}
|
|
}
|
|
// 返回原图下载地址
|
|
// 返回原图下载地址
|
|
if (withSheetUrl != null && withSheetUrl.booleanValue()) {
|
|
if (withSheetUrl != null && withSheetUrl.booleanValue()) {
|
|
- obj.accumulate(
|
|
|
|
- "sheetUrls",
|
|
|
|
- fileService
|
|
|
|
- .getSheetUris(student.getExamId(), student.getExamNumber(), 1,
|
|
|
|
- student.getSheetCount()).stream()
|
|
|
|
- .map(uri -> fileService.getFileServer().concat(uri))
|
|
|
|
- .collect(Collectors.toList()));
|
|
|
|
|
|
+ obj.accumulate("sheetUrls", fileService
|
|
|
|
+ .getSheetUris(student.getExamId(), student.getExamNumber(), 1, student.getSheetCount())
|
|
|
|
+ .stream().map(uri -> fileService.getFileServer().concat(uri))
|
|
|
|
+ .collect(Collectors.toList()));
|
|
}
|
|
}
|
|
array.add(obj);
|
|
array.add(obj);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -294,12 +292,16 @@ public class ExamStudentController extends BaseApiController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String getScore(@PathVariable Integer schoolId, @RequestParam String studentCode,
|
|
public String getScore(@PathVariable Integer schoolId, @RequestParam String studentCode,
|
|
@RequestParam String subjectCode, @RequestParam(required = false, defaultValue = "true") boolean encrypt,
|
|
@RequestParam String subjectCode, @RequestParam(required = false, defaultValue = "true") boolean encrypt,
|
|
- @RequestParam(required = false) String examSeqCode) {
|
|
|
|
|
|
+ @RequestParam(required = false) String examSeqCode, @RequestParam(required = false) Integer examId,
|
|
|
|
+ @RequestParam(required = false, defaultValue = "false") boolean detail) {
|
|
JSONObject obj = new JSONObject();
|
|
JSONObject obj = new JSONObject();
|
|
ExamStudent student = null;
|
|
ExamStudent student = null;
|
|
try {
|
|
try {
|
|
if (Strings.isNullOrEmpty(examSeqCode)) {
|
|
if (Strings.isNullOrEmpty(examSeqCode)) {
|
|
student = studentService.findBySchoolIdAndSubjectCodeAndStudentCode(schoolId, subjectCode, studentCode);
|
|
student = studentService.findBySchoolIdAndSubjectCodeAndStudentCode(schoolId, subjectCode, studentCode);
|
|
|
|
+ } else if (examId != null) {
|
|
|
|
+ student = studentService.findByExamIdAndSchoolIdAndSubjectCodeAndStudentCode(examId, schoolId,
|
|
|
|
+ subjectCode, studentCode);
|
|
} else {
|
|
} else {
|
|
student = studentService.findBySchoolIdAndSubjectCodeAndStudentCodeAndRemark(schoolId, subjectCode,
|
|
student = studentService.findBySchoolIdAndSubjectCodeAndStudentCodeAndRemark(schoolId, subjectCode,
|
|
studentCode, examSeqCode);
|
|
studentCode, examSeqCode);
|
|
@@ -307,14 +309,33 @@ public class ExamStudentController extends BaseApiController {
|
|
if (student != null) {
|
|
if (student != null) {
|
|
DecimalFormat df = new DecimalFormat("####.###");
|
|
DecimalFormat df = new DecimalFormat("####.###");
|
|
obj.accumulate("exist", true);
|
|
obj.accumulate("exist", true);
|
|
- obj.accumulate("objectiveScore", df.format(student.getObjectiveScore()));
|
|
|
|
- obj.accumulate("subjectiveScore", df.format(student.getSubjectiveScore()));
|
|
|
|
- obj.accumulate("totalScore", df.format(student.getTotalScore()));
|
|
|
|
|
|
+ obj.accumulate("examId", String.valueOf(student.getExamId()));
|
|
|
|
+ obj.accumulate("upload", student.isUpload() && !student.isAbsent());
|
|
|
|
+ if (student.isUpload() && !student.isAbsent()) {// 缺考
|
|
|
|
+ ExamSubject examSubject = examSubjectService.find(student.getExamId(), student.getSubjectCode());
|
|
|
|
+ int objectiveStatus = getObjectiveStatus(examSubject, student);
|
|
|
|
+ obj.accumulate("objectiveStatus", objectiveStatus);
|
|
|
|
+ int subjectiveStatus = getSubjectiveStatus(examSubject, student);
|
|
|
|
+ obj.accumulate("subjectiveStatus", subjectiveStatus);
|
|
|
|
+ double objectiveScore = objectiveStatus == 2 ? student.getObjectiveScore() : 0;
|
|
|
|
+ obj.accumulate("objectiveScore", df.format(objectiveScore));
|
|
|
|
+ double subjectiveScore = subjectiveStatus == 2 ? student.getSubjectiveScore() : 0;
|
|
|
|
+ obj.accumulate("subjectiveScore", df.format(subjectiveScore));
|
|
|
|
+ obj.accumulate("totalScore", df.format(objectiveScore + subjectiveScore));
|
|
|
|
+ if (detail) {
|
|
|
|
+ obj.accumulate("subjectiveScoreList",
|
|
|
|
+ subjectiveStatus == 2 ? StringUtils.trimToEmpty(student.getSubjectiveScoreList()) : "");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ absentSetObj(detail, obj);
|
|
|
|
+ }
|
|
|
|
+ obj.accumulate("absent", student.isAbsent());
|
|
} else {
|
|
} else {
|
|
obj.accumulate("exist", false);
|
|
obj.accumulate("exist", false);
|
|
- obj.accumulate("objectiveScore", 0);
|
|
|
|
- obj.accumulate("subjectiveScore", 0);
|
|
|
|
- obj.accumulate("totalScore", 0);
|
|
|
|
|
|
+ obj.accumulate("examId", "");
|
|
|
|
+ obj.accumulate("upload", false);
|
|
|
|
+ obj.accumulate("absent", true);
|
|
|
|
+ absentSetObj(detail, obj);
|
|
}
|
|
}
|
|
if (!Strings.isNullOrEmpty(examSeqCode)) {
|
|
if (!Strings.isNullOrEmpty(examSeqCode)) {
|
|
obj.accumulate("examSeqCode", examSeqCode);
|
|
obj.accumulate("examSeqCode", examSeqCode);
|
|
@@ -329,6 +350,42 @@ public class ExamStudentController extends BaseApiController {
|
|
return encrypt ? AESUtil.encrypt(result) : result;
|
|
return encrypt ? AESUtil.encrypt(result) : result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private int getSubjectiveStatus(ExamSubject examSubject, ExamStudent student) {
|
|
|
|
+ if (examSubject.getSubjectiveScore() == null || examSubject.getSubjectiveScore() == 0) {
|
|
|
|
+ return 0;
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isNotEmpty(student.getSubjectiveScoreList())
|
|
|
|
+ && student.getSubjectiveStatus().equals(SubjectiveStatus.MARKED)) {
|
|
|
|
+ return 2;
|
|
|
|
+ } else {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int getObjectiveStatus(ExamSubject examSubject, ExamStudent student) {
|
|
|
|
+ if (examSubject.getObjectiveScore() == null || examSubject.getObjectiveScore() == 0) {
|
|
|
|
+ return 0;
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isEmpty(student.getObjectiveScoreList())) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else {
|
|
|
|
+ return 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void absentSetObj(boolean detail, JSONObject obj) {
|
|
|
|
+ obj.accumulate("objectiveStatus", "");
|
|
|
|
+ obj.accumulate("subjectiveStatus", "");
|
|
|
|
+ obj.accumulate("objectiveScore", "");
|
|
|
|
+ obj.accumulate("subjectiveScore", "");
|
|
|
|
+ obj.accumulate("totalScore", "");
|
|
|
|
+ if (detail) {
|
|
|
|
+ obj.accumulate("subjectiveScoreList", "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
@RoleRequire({ Role.SCHOOL_ADMIN, Role.SCANNER })
|
|
@RequestMapping("/exam/students/slice")
|
|
@RequestMapping("/exam/students/slice")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@@ -440,20 +497,16 @@ public class ExamStudentController extends BaseApiController {
|
|
}
|
|
}
|
|
// 返回评卷标记
|
|
// 返回评卷标记
|
|
if (withMarkTrack != null && withMarkTrack.booleanValue()) {
|
|
if (withMarkTrack != null && withMarkTrack.booleanValue()) {
|
|
- obj.accumulate(
|
|
|
|
- "tags",
|
|
|
|
- studentService.buildSliceTags(student, withGroupScoreTrack != null
|
|
|
|
- && withGroupScoreTrack.booleanValue()));
|
|
|
|
|
|
+ obj.accumulate("tags", studentService.buildSliceTags(student,
|
|
|
|
+ withGroupScoreTrack != null && withGroupScoreTrack.booleanValue()));
|
|
}
|
|
}
|
|
// 返回原图下载地址
|
|
// 返回原图下载地址
|
|
if (withSliceUrl != null && withSliceUrl.booleanValue()) {
|
|
if (withSliceUrl != null && withSliceUrl.booleanValue()) {
|
|
- obj.accumulate(
|
|
|
|
- "sliceUrls",
|
|
|
|
- fileService
|
|
|
|
- .getSliceUris(student.getExamId(), student.getSecretNumber(), 1,
|
|
|
|
- student.getSliceCount()).stream()
|
|
|
|
- .map(uri -> fileService.getFileServer().concat(uri))
|
|
|
|
- .collect(Collectors.toList()));
|
|
|
|
|
|
+ obj.accumulate("sliceUrls", fileService
|
|
|
|
+ .getSliceUris(student.getExamId(), student.getSecretNumber(), 1,
|
|
|
|
+ student.getSliceCount())
|
|
|
|
+ .stream().map(uri -> fileService.getFileServer().concat(uri))
|
|
|
|
+ .collect(Collectors.toList()));
|
|
}
|
|
}
|
|
array.add(obj);
|
|
array.add(obj);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -474,8 +527,8 @@ public class ExamStudentController extends BaseApiController {
|
|
Exam exam = examService.findById(examId);
|
|
Exam exam = examService.findById(examId);
|
|
JSONArray array = new JSONArray();
|
|
JSONArray array = new JSONArray();
|
|
// 判断上传权限
|
|
// 判断上传权限
|
|
- if (exam == null || !exam.getSchoolId().equals(user.getSchoolId())
|
|
|
|
- || !ExamStatus.START.equals(exam.getStatus()) || !ExamType.SCAN_IMAGE.equals(exam.getType())) {
|
|
|
|
|
|
+ if (exam == null || !exam.getSchoolId().equals(user.getSchoolId()) || !ExamStatus.START.equals(exam.getStatus())
|
|
|
|
+ || !ExamType.SCAN_IMAGE.equals(exam.getType())) {
|
|
throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
throw ApiException.EXAM_NOT_ACCESSIBLED;
|
|
}
|
|
}
|
|
studentService.clearManualAbsent(examId);
|
|
studentService.clearManualAbsent(examId);
|