Browse Source

update 重算成绩

deason 7 months ago
parent
commit
45c3455b08

+ 12 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/examscore/ReFixScoreReq.java

@@ -28,6 +28,11 @@ public class ReFixScoreReq {
      */
     private Boolean updateSubjectiveScore;
 
+    /**
+     * 无论考生作答什么,直接给分的试题ID集合,多个英文逗号分隔
+     */
+    private String questionIds;
+
     public Long getExamId() {
         return examId;
     }
@@ -84,4 +89,11 @@ public class ReFixScoreReq {
         this.updateSubjectiveScore = updateSubjectiveScore;
     }
 
+    public String getQuestionIds() {
+        return questionIds;
+    }
+
+    public void setQuestionIds(String questionIds) {
+        this.questionIds = questionIds;
+    }
 }

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

@@ -18,6 +18,7 @@ import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.QuestionAnswerCacheBean;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -155,14 +156,14 @@ public class FixExamScoreServiceImpl implements FixExamScoreService {
         }
 
         // 计算成绩
-        this.calcExamScore(examRecordData.getId(), examQuestions);
+        this.calcExamScore(examRecordData.getId(), examQuestions, req.getQuestionIds());
 
         log.info("【重算成绩】结束!examRecordDataId:{} paperScore:{}", examRecordData.getId(),
                 examRecordData.getPaperScore());
         return true;
     }
 
-    private void calcExamScore(Long examRecordDataId, List<ExamQuestionEntity> examQuestions) {
+    private void calcExamScore(Long examRecordDataId, List<ExamQuestionEntity> examQuestions, String questionIds) {
         int totalObjective = 0; // 客观题总数
         int totalRightObjective = 0; // 客观题作答正确数
         double objectiveScore = 0d; // 客观题得分
@@ -174,17 +175,24 @@ public class FixExamScoreServiceImpl implements FixExamScoreService {
             }
 
             totalObjective++;
+            if (curQuestion.getQuestionScore() == null) {
+                curQuestion.setQuestionScore(0d);
+            }
 
-            // 计算得分
-            String correctAnswer = curQuestion.getCorrectAnswer();
-            String studentAnswer = curQuestion.getStudentAnswer();
-            if (QuestionOptionHelper.isEqualAnswer(correctAnswer, studentAnswer)) {
-                if (curQuestion.getQuestionScore() == null) {
-                    curQuestion.setQuestionScore(0d);
-                }
-
+            if (StringUtils.isNotBlank(questionIds) && questionIds.contains(curQuestion.getQuestionId())) {
+                // 无论考生作答什么,直接给分的试题ID集合,多个英文逗号分隔
                 objectiveScore += curQuestion.getQuestionScore();
                 totalRightObjective++;
+                log.warn("【重算成绩】questionId:{} 直接给分:{}", curQuestion.getQuestionId(),
+                        curQuestion.getQuestionScore());
+            } else {
+                // 匹配正确答案和考生作答,计算得分
+                String correctAnswer = curQuestion.getCorrectAnswer();
+                String studentAnswer = curQuestion.getStudentAnswer();
+                if (QuestionOptionHelper.isEqualAnswer(correctAnswer, studentAnswer)) {
+                    objectiveScore += curQuestion.getQuestionScore();
+                    totalRightObjective++;
+                }
             }
         }