Browse Source

fix: 修复判断达标的问题

gwd 1 week ago
parent
commit
633ca09a38

+ 6 - 5
app/Models/StudentKnowledgeMastery.php

@@ -118,7 +118,8 @@ class StudentKnowledgeMastery extends Model
             return false;
         }
 
-        $levels = self::query()
+        // 使用 DB::table 避免 Eloquent accessor 把数字转成文字标签
+        $levels = \Illuminate\Support\Facades\DB::table('student_knowledge_mastery')
             ->where('student_id', $studentId)
             ->whereIn('kp_code', $kpCodes)
             ->pluck('mastery_level', 'kp_code')
@@ -149,8 +150,8 @@ class StudentKnowledgeMastery extends Model
             return true; // 没有知识点,视为达标
         }
 
-        // 获取掌握度
-        $levels = self::query()
+        // 获取掌握度(使用 DB::table 避免 Eloquent accessor 把数字转成文字标签)
+        $levels = \Illuminate\Support\Facades\DB::table('student_knowledge_mastery')
             ->where('student_id', $studentId)
             ->whereIn('kp_code', $kpCodes)
             ->pluck('mastery_level', 'kp_code')
@@ -197,8 +198,8 @@ class StudentKnowledgeMastery extends Model
             return null;
         }
 
-        // 获取掌握度
-        $levels = self::query()
+        // 获取掌握度(使用 DB::table 避免 Eloquent accessor 把数字转成文字标签)
+        $levels = \Illuminate\Support\Facades\DB::table('student_knowledge_mastery')
             ->where('student_id', $studentId)
             ->whereIn('kp_code', $kpCodes)
             ->pluck('mastery_level', 'kp_code')

+ 2 - 2
app/Services/DiagnosticChapterService.php

@@ -502,8 +502,8 @@ class DiagnosticChapterService
             return [];
         }
 
-        // 获取掌握度
-        $levels = StudentKnowledgeMastery::query()
+        // 获取掌握度(使用 DB::table 避免 Eloquent accessor 把数字转成文字标签)
+        $levels = \Illuminate\Support\Facades\DB::table('student_knowledge_mastery')
             ->where('student_id', $studentId)
             ->whereIn('kp_code', $kpCodes)
             ->pluck('mastery_level', 'kp_code')