Преглед изворни кода

fix:无序情况下正确答案、作答答案的判断一致问题

deason пре 1 година
родитељ
комит
aaea97a92c

+ 2 - 8
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamRecordQuestionsController.java

@@ -1,8 +1,8 @@
 package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
+import cn.com.qmth.examcloud.commons.helpers.QuestionOptionHelper;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
-import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordQuestionsRepo;
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamQuestionEntity;
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordQuestionsEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordDataSyncService;
@@ -34,7 +34,6 @@ import java.util.stream.Collectors;
  * @author chenken
  * @date 2018年10月12日 上午9:48:47
  * @company QMTH
- * @description ExamRecordQuestionsController.java
  */
 @Api(tags = "考试结束后-作答记录接口")
 @RestController
@@ -43,9 +42,6 @@ public class ExamRecordQuestionsController extends ControllerSupport {
 
     private static final Logger log = LoggerFactory.getLogger(ExamRecordQuestionsController.class);
 
-    @Autowired
-    private ExamRecordQuestionsRepo examRecordQuestionsRepo;
-
     @Autowired
     private ExamRecordQuestionsService examRecordQuestionsService;
 
@@ -80,9 +76,7 @@ public class ExamRecordQuestionsController extends ControllerSupport {
             for (ExamQuestionEntity examQuestion : examQuestions) {
                 if (QuestionType.isObjective(examQuestion.getQuestionType())) {
                     // 客观题得分
-                    if (examQuestion.getStudentAnswer() != null && examQuestion.getCorrectAnswer() != null
-                            // && QuestionOptionHelper.isEqualAnswer(examQuestion.getCorrectAnswer(), examQuestion.getStudentAnswer())) {
-                            && examQuestion.getStudentAnswer().equals(examQuestion.getCorrectAnswer())) {
+                    if (QuestionOptionHelper.isEqualAnswer(examQuestion.getCorrectAnswer(), examQuestion.getStudentAnswer())) {
                         examQuestion.setStudentScore(examQuestion.getQuestionScore());
                     } else {
                         examQuestion.setStudentScore(0d);

+ 4 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/FixExamScoreServiceImpl.java

@@ -318,12 +318,12 @@ public class FixExamScoreServiceImpl implements FixExamScoreService {
         log.warn("【修改试题分值】考生试卷结构-已更新! examRecordDataId:{} paperStructId:{}", examRecordData.getId(),
                 examRecordPaperStruct.getId());
 
-        if (paperScore != examRecordData.getPaperScore()) {
+        if (Double.compare(paperScore, examRecordData.getPaperScore()) != 0) {
             // 更新考试记录的试卷总分
-            examRecordData.setPaperScore(paperScore);
             examRecordDataRepo.updateExamRecordPaperScoreById(examRecordData.getId(), paperScore);
-            log.warn("【修改试题分值】考试记录的试卷总分-已更新! examRecordDataId:{} paperScore:{}",
-                    examRecordData.getId(), paperScore);
+            log.warn("【修改试题分值】考试记录的试卷总分-已更新! examRecordDataId:{} oldPaperScore:{} newPaperScore:{}",
+                    examRecordData.getId(), examRecordData.getPaperScore(), paperScore);
+            examRecordData.setPaperScore(paperScore);
         }
     }