|
@@ -29,6 +29,7 @@ import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStageCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.ModifyExamStageStartExamStatusReq;
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
|
|
@@ -53,7 +54,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
@@ -374,49 +374,42 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
|
|
|
public CalcExamScoreResp calcExamScore(CalcExamScoreReq req) {
|
|
|
try {
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- ExamRecordQuestions examRecordQuestions = examRecordQuestionsService.getExamRecordQuestions(req.getExamRecordDataId());
|
|
|
|
|
|
// 考生作答记录明细
|
|
|
- List<ExamQuestion> examQuestions = examRecordQuestions.getExamQuestions();
|
|
|
-
|
|
|
- for (ExamQuestion examQuestion : examQuestions) {
|
|
|
- if (QuestionTypeUtil.isObjectiveQuestion(examQuestion.getQuestionType())) {
|
|
|
- // 如果客观题的标准答案为空,则更新标准答案
|
|
|
- if (StringUtils.isEmpty(examQuestion.getCorrectAnswer())) {
|
|
|
- this.updateCorrectAnswer(req.getExamRecordDataId(), examQuestions, examQuestion);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ ExamRecordQuestions examRecordQuestions = examRecordQuestionsService.getExamRecordQuestions(req.getExamRecordDataId());
|
|
|
|
|
|
- double objectiveScore = 0d;//客观题总分
|
|
|
- int totalObjective = 0;//客观题总数
|
|
|
- int totalRightObjective = 0;//答题正确数
|
|
|
+ double objectiveScore = 0d; // 客观题得分
|
|
|
+ int totalObjective = 0; // 客观题总数
|
|
|
+ int totalRightObjective = 0; // 客观题作答正确数
|
|
|
|
|
|
- for (int i = 0; i < examQuestions.size(); i++) {
|
|
|
- ExamQuestion examQuestion = examQuestions.get(i);
|
|
|
- if (!QuestionTypeUtil.isObjectiveQuestion(examQuestion.getQuestionType())) {
|
|
|
+ List<ExamQuestion> examQuestions = examRecordQuestions.getExamQuestions();
|
|
|
+ for (ExamQuestion examQuestion : examQuestions) {
|
|
|
+ if (!QuestionType.isObjective(examQuestion.getQuestionType())) {
|
|
|
// 跳过主观题
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
totalObjective++;
|
|
|
|
|
|
- // 如果学生作答正确,则客观分累加,答题数累加
|
|
|
- if (examQuestion.getStudentAnswer() != null && examQuestion.getCorrectAnswer() != null
|
|
|
- // && QuestionOptionHelper.isEqualAnswer(examQuestion.getCorrectAnswer(), examQuestion.getStudentAnswer())) {
|
|
|
- && examQuestion.getStudentAnswer().equals(examQuestion.getCorrectAnswer())) {
|
|
|
+ String correctAnswer = examQuestion.getCorrectAnswer();
|
|
|
+ String studentAnswer = examQuestion.getStudentAnswer();
|
|
|
+
|
|
|
+ // 如果客观题的标准答案为空,则更新标准答案
|
|
|
+ if (StringUtils.isEmpty(correctAnswer)) {
|
|
|
+ //todo
|
|
|
+ // this.updateCorrectAnswer(req.getExamRecordDataId(), examQuestions, examQuestion);
|
|
|
+ }
|
|
|
|
|
|
+ // 如果学生作答正确,则客观分累加,答题数累加
|
|
|
+ // if (StringUtils.isNotEmpty(studentAnswer) && QuestionOptionHelper.isEqualAnswer(correctAnswer, studentAnswer)) {
|
|
|
+ if (StringUtils.isNotEmpty(studentAnswer) && studentAnswer.equals(correctAnswer)) {
|
|
|
Double questionScore = examQuestion.getQuestionScore();
|
|
|
if (questionScore == null) {
|
|
|
log.warn("[calcExamScore] questionScore is null, examRecordDataId:{} questionId:{}",
|
|
|
req.getExamRecordDataId(), examQuestion.getQuestionId());
|
|
|
questionScore = 0d;
|
|
|
}
|
|
|
-
|
|
|
- BigDecimal bigObjectiveScore = new BigDecimal(Double.toString(objectiveScore));
|
|
|
- BigDecimal bigQuestionScore = new BigDecimal(Double.toString(questionScore));
|
|
|
-
|
|
|
- objectiveScore = bigQuestionScore.add(bigObjectiveScore).doubleValue();
|
|
|
+ objectiveScore += questionScore;
|
|
|
totalRightObjective++;
|
|
|
}
|
|
|
}
|
|
@@ -430,7 +423,7 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
|
|
|
CalcExamScoreResp resp = new CalcExamScoreResp();
|
|
|
resp.setObjectiveScore(objectiveScore);
|
|
|
resp.setObjectiveAccuracy(objectiveAccuracy);
|
|
|
- //交卷时,总分=客观分得分
|
|
|
+ //交卷时,总分 = 客观分得分 (主观分需要阅卷后才有分)
|
|
|
resp.setTotalScore(objectiveScore);
|
|
|
|
|
|
long cost = System.currentTimeMillis() - startTime;
|