Răsfoiți Sursa

calcExamScore fix NPE

deason 2 ani în urmă
părinte
comite
480538336e

+ 8 - 2
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java

@@ -406,7 +406,13 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
                         // && QuestionOptionHelper.isEqualAnswer(examQuestion.getCorrectAnswer(), examQuestion.getStudentAnswer())) {
                         && examQuestion.getStudentAnswer().equals(examQuestion.getCorrectAnswer())) {
 
-                    double questionScore = examQuestion.getQuestionScore();
+                    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));
 
@@ -428,7 +434,7 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
             resp.setTotalScore(objectiveScore);
 
             long cost = System.currentTimeMillis() - startTime;
-            log.warn("calcExamScore examRecordDataId:{}, totalQuestion:{}, totalObjective:{}, cost:{}ms",
+            log.warn("[calcExamScore] examRecordDataId:{}, totalQuestion:{}, totalObjective:{}, cost:{}ms",
                     req.getExamRecordDataId(), examQuestions.size(), totalObjective, cost);
             return resp;
         } catch (Exception e) {