Browse Source

随机题目的简答题得分,优化

lizhen_gitee 7 months ago
parent
commit
ae2a2b86cf
1 changed files with 9 additions and 6 deletions
  1. 9 6
      addons/exam/library/ExamService.php

+ 9 - 6
addons/exam/library/ExamService.php

@@ -237,23 +237,25 @@ class ExamService
                     $right_score   = 0;
                     $answer_score  = [];
                     foreach ($answer_config['config'] as $answer_item) {
-                        if ($right_score < $score) {
+                        /*if ($right_score < $score) {*/
                             // 匹配答案关键词
                             if (strpos($user_answers, $answer_item['answer']) !== false) {
-                                $right_score += $answer_item['score'];
+//                                $right_score += $answer_item['score'];
                                 // 得分情况
                                 $answer_score[] = [
                                     'answer'        => $answer_item['answer'],
-                                    'score'         => min($score, $answer_item['score']),
+//                                    'score'         => min($score, $answer_item['score']), //这里不对
+                                    'score'         => $score,
                                     'keyword_score' => $answer_item['score'],
                                     'max_score'     => $score,
                                 ];
                             }
-                        }
+                        /*}*/
                     }
 
                     // 最高得分不能超过题目分数
-                    $right_score = min($right_score, $score);
+//                    $right_score = min($right_score, $score);//这里不对
+                    $right_score = $score;
 
                     // 有得分
                     if ($right_score > 0) {
@@ -281,7 +283,7 @@ class ExamService
         // 递增参与人次
         $paper->setInc('join_count');
 
-        return [
+        $result =  [
             'total_score'  => $paper['total_score'],                                                                        // 试卷总分
             'score'        => $total_score,                                                                                 // 考试分数
             'is_pass'      => $total_score >= $paper['pass_score'],                                                         // 是否及格
@@ -297,6 +299,7 @@ class ExamService
             'configs'      => json_encode($paper['configs']),                                                               // 试卷配置
             'mode'         => $paper['mode'],                                                                               // 试卷选题模式
         ];
+        return $result;
     }
 
     /**