Kaynağa Gözat

知识点讲解功能添加完成,但是知识点表(包括知识点讲解)使用的是knowledge_points_copy1;正式环境的时候需要切换。

yemeishu 2 hafta önce
ebeveyn
işleme
865ee0f65f

+ 1 - 2
app/Http/Controllers/Api/IntelligentExamController.php

@@ -186,7 +186,6 @@ class IntelligentExamController extends Controller
                     'total_questions' => $data['total_questions'],
                     // 【修复】教材组卷时不使用用户传入的kp_codes,只使用章节关联的知识点
                     'kp_codes' => $assembleType == 3 ? null : ($data['kp_codes'] ?? null),
-                    'kp_code_list' => $assembleType == 3 ? null : ($data['kp_code_list'] ?? $data['kp_codes'] ?? []),
                     'skills' => $data['skills'] ?? [],
                     'question_type_ratio' => $questionTypeRatio,
                     'difficulty_category' => $difficultyCategory, // 传递难度分类(数字)
@@ -196,7 +195,7 @@ class IntelligentExamController extends Controller
                     'textbook_id' => $data['textbook_id'] ?? null, // 摸底和智能组卷专用
                     'end_catalog_id' => $data['end_catalog_id'] ?? null, // 摸底专用:截止章节ID
                     'chapter_id_list' => $data['chapter_id_list'] ?? null, // 教材组卷专用
-                    'kp_code_list' => $assembleType == 3 ? null : ($data['kp_code_list'] ?? null), // 知识点组卷专用
+                    'kp_code_list' => $assembleType == 3 ? null : ($data['kp_code_list'] ?? $data['kp_codes'] ?? []), // 知识点组卷专用
                     'practice_options' => $data['practice_options'] ?? null, // 传递专项练习选项
                     'mistake_options' => $data['mistake_options'] ?? null, // 传递错题选项
                 ];

+ 1 - 1
app/Models/KnowledgePoint.php

@@ -9,7 +9,7 @@ class KnowledgePoint extends Model
 {
     use HasFactory;
 
-    protected $table = 'knowledge_points';
+    protected $table = 'knowledge_points_copy1'; // 正式环境回归:knowledge_points
 
     protected $fillable = [
         'kp_code',

+ 7 - 39
app/Services/ExamPdfExportService.php

@@ -2421,37 +2421,6 @@ class ExamPdfExportService
         ])->render();
     }
 
-    /**
-     * 获取知识点的讲解内容
-     *
-     * @param  string  $kpCode  知识点代码
-     * @param  string  $kpName  知识点名称
-     * @return string Markdown 格式的讲解内容
-     */
-    public function buildExplanation(string $kpCode, string $kpName): string
-    {
-        if ($this->shouldUseDefaultExplanations()) {
-            return $this->getDefaultExplanation($kpCode, $kpName);
-        }
-
-        try {
-            // 从数据库获取知识点讲解
-            $kp = \App\Models\KnowledgePoint::where('kp_code', $kpCode)->first();
-
-            if ($kp && ! empty($kp->explanation)) {
-                return $kp->explanation;
-            }
-        } catch (\Throwable $e) {
-            Log::warning('获取知识点讲解失败', [
-                'kp_code' => $kpCode,
-                'error' => $e->getMessage(),
-            ]);
-        }
-
-        // 如果数据库没有,返回默认讲解内容
-        return $this->getDefaultExplanation($kpCode, $kpName);
-    }
-
     /**
      * 批量获取知识点的讲解内容
      *
@@ -2466,23 +2435,22 @@ class ExamPdfExportService
             return $result;
         }
 
-        if ($this->shouldUseDefaultExplanations()) {
-            foreach ($kpCodes as $kpCode) {
-                $result[$kpCode] = $this->getDefaultExplanation($kpCode, $kpCode);
-            }
-            return $result;
-        }
+//        if ($this->shouldUseDefaultExplanations()) {
+//            foreach ($kpCodes as $kpCode) {
+//                $result[$kpCode] = $this->getDefaultExplanation($kpCode, $kpCode);
+//            }
+//            return $result;
+//        }
 
         try {
             // 批量获取知识点讲解
             $kps = \App\Models\KnowledgePoint::whereIn('kp_code', $kpCodes)->get()->keyBy('kp_code');
 
+            // 有多少算多少
             foreach ($kpCodes as $kpCode) {
                 $kp = $kps->get($kpCode);
                 if ($kp && ! empty($kp->explanation)) {
                     $result[$kpCode] = $kp->explanation;
-                } else {
-                    $result[$kpCode] = $this->getDefaultExplanation($kpCode, $kpCode);
                 }
             }
         } catch (\Throwable $e) {