|
@@ -1,7 +1,5 @@
|
|
|
package cn.com.qmth.stmms.admin.thread;
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
@@ -12,6 +10,7 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import cn.com.qmth.stmms.admin.utils.StudentJsonUtils;
|
|
|
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.ExamStudent;
|
|
@@ -19,10 +18,12 @@ 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.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.lock.LockService;
|
|
|
import cn.com.qmth.stmms.biz.utils.ScoreCalculateUtil;
|
|
|
import cn.com.qmth.stmms.biz.utils.ScoreInfo;
|
|
|
import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.ExamType;
|
|
|
import cn.com.qmth.stmms.common.enums.LockType;
|
|
|
import cn.com.qmth.stmms.common.enums.ObjectiveStatus;
|
|
|
|
|
@@ -54,17 +55,20 @@ public class ScoreCalculateThread implements Runnable {
|
|
|
|
|
|
private ExamService examService;
|
|
|
|
|
|
+ private FileService fileService;
|
|
|
+
|
|
|
private boolean examLock;
|
|
|
|
|
|
public ScoreCalculateThread(int examId, Set<String> subjectCodeSet, LockService lockService,
|
|
|
ExamStudentService studentService, ExamQuestionService questionService, ExamService examService,
|
|
|
- ExamSubjectService subjectService, boolean examLock) {
|
|
|
+ ExamSubjectService subjectService, FileService fileService, boolean examLock) {
|
|
|
this.examId = examId;
|
|
|
this.subjectCodeSet = subjectCodeSet != null ? subjectCodeSet : new HashSet<>();
|
|
|
this.lockService = lockService;
|
|
|
this.studentService = studentService;
|
|
|
this.questionService = questionService;
|
|
|
this.examService = examService;
|
|
|
+ this.fileService = fileService;
|
|
|
this.examLock = examLock;
|
|
|
this.objectiveMap = new HashMap<>();
|
|
|
this.subjectiveMap = new HashMap<>();
|
|
@@ -97,7 +101,7 @@ public class ScoreCalculateThread implements Runnable {
|
|
|
pageSize);
|
|
|
while (list != null && list.size() > 0) {
|
|
|
for (ExamStudent student : list) {
|
|
|
- calculate(student);
|
|
|
+ calculate(student, exam.getType());
|
|
|
}
|
|
|
pageNumber++;
|
|
|
list = studentService.findByExamIdAndSubjectCode(examId, subjectCode, pageNumber, pageSize);
|
|
@@ -115,15 +119,22 @@ public class ScoreCalculateThread implements Runnable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void calculate(ExamStudent student) {
|
|
|
+ private void calculate(ExamStudent student, ExamType examType) {
|
|
|
// 未上传、缺考、违纪的考生不统分
|
|
|
if (!student.isUpload() || student.isAbsent() || student.isBreach()) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
+ List<ExamQuestion> oList = findQuestionList(student.getSubjectCode(), student.getPaperType(), true);
|
|
|
+ if (ExamType.MULTI_MEDIA.equals(examType) && oList.size() > 0) {
|
|
|
+ byte[] s = fileService.downloadJson(student.getExamId(), student.getSecretNumber());
|
|
|
+ String studentJson = new String(s, "UTF-8");
|
|
|
+ String answers = StudentJsonUtils.toAnswers(studentJson);
|
|
|
+ student.setAnswers(answers.toUpperCase());
|
|
|
+ studentService.save(student);
|
|
|
+ }
|
|
|
ScoreCalculateUtil util = ScoreCalculateUtil.instance(student);
|
|
|
- ScoreInfo info = util.calculate(findQuestionList(student.getSubjectCode(), student.getPaperType(), true),
|
|
|
- null);
|
|
|
+ ScoreInfo info = util.calculate(oList, null);
|
|
|
|
|
|
student.setObjectiveScore(info.getObjectiveScore());
|
|
|
student.setScoreList(info.getScoreList(), true);
|