Przeglądaj źródła

修复章节组卷逻辑

yemeishu 3 tygodni temu
rodzic
commit
e1ed0a0131

+ 6 - 11
app/Services/ExamTypeStrategy.php

@@ -1115,7 +1115,7 @@ class ExamTypeStrategy
     {
         try {
             // 如果章节数较少,使用原有逻辑
-            if (count($chapterIds) <= 5) {
+            if (count($chapterIds) <= 15) {
                 Log::info('ExamTypeStrategy: 章节数较少,使用原有逻辑', [
                     'chapter_count' => count($chapterIds)
                 ]);
@@ -1240,17 +1240,12 @@ class ExamTypeStrategy
     {
         try {
             // 修复方案1:使用GROUP BY替代DISTINCT,并选择需要的字段
-            $kpCodes = DB::table('textbook_chapter_knowledge_relation as tckr')
-                ->leftJoin('textbook_catalog_nodes as tcn', 'tckr.catalog_chapter_id', '=', 'tcn.id')
-                ->whereIn('tckr.catalog_chapter_id', $chapterIds)
-                ->select('tckr.kp_code', 'tcn.sort_order')
-                ->orderBy('tcn.sort_order', 'asc')
-                ->orderBy('tckr.kp_code', 'asc')
-                ->limit($limit)
-                ->groupBy('tckr.kp_code')
-                ->pluck('tckr.kp_code')
+            $kpCodes = DB::table('textbook_chapter_knowledge_relation')
+                ->whereIn('catalog_chapter_id', $chapterIds)
+                ->select('kp_code')
+                ->groupBy('kp_code')
+                ->pluck('kp_code')
                 ->toArray();
-
             Log::debug('ExamTypeStrategy: 查询章节知识点(原有逻辑)', [
                 'chapter_count' => count($chapterIds),
                 'found_kp_count' => count($kpCodes)

+ 4 - 4
app/Services/LearningAnalyticsService.php

@@ -1706,10 +1706,10 @@ class LearningAnalyticsService
             }
 
             // 【优化】按教材章节节点筛选(textbook_catalog_nodes_id)
-            if (!empty($textbookCatalogNodeIds)) {
-                $query->whereIn('textbook_catalog_nodes_id', $textbookCatalogNodeIds);
-                Log::info('应用教材章节节点筛选', ['textbook_catalog_nodes_ids' => $textbookCatalogNodeIds]);
-            }
+//            if (!empty($textbookCatalogNodeIds)) {
+//                $query->whereIn('textbook_catalog_nodes_id', $textbookCatalogNodeIds);
+//                Log::info('应用教材章节节点筛选', ['textbook_catalog_nodes_ids' => $textbookCatalogNodeIds]);
+//            }
 
             // 筛选有解题思路的题目
             $query->whereNotNull('solution')