Browse Source

学案生成优化

yemeishu 1 day ago
parent
commit
10a2a2402e

+ 0 - 1
app/Services/ExamPdfExportService.php

@@ -1068,7 +1068,6 @@ class ExamPdfExportService
             '--disable-backgrounding-occluded-windows',
             '--disable-renderer-backgrounding',
             '--disable-features=AudioServiceOutOfProcess',
-            '--single-process', // 【优化】单进程模式,减少资源占用
             '--disable-gpu-sandbox',
             '--disable-software-rasterizer',
             '--disable-background-mode',

+ 38 - 1
app/Services/ExamTypeStrategy.php

@@ -924,8 +924,45 @@ class ExamTypeStrategy
         $studentId = $params['student_id'] ?? null;
         $totalQuestions = $params['total_questions'] ?? 20;
 
+        // 【优化】如果用户没有指定章节,自动从教材所有有题目的章节中选择
+        if (empty($chapterIdList) && !empty($params['textbook_id'])) {
+            Log::info('ExamTypeStrategy: 用户未指定章节,自动从教材选择', [
+                'textbook_id' => $params['textbook_id']
+            ]);
+
+            // 【修复】先查询教材下的所有章节,再筛选有题目的章节
+            // 步骤1:根据textbook_id获取该教材下的所有章节ID
+            $allChapterIds = DB::table('textbook_catalog_nodes')
+                ->where('textbook_id', $params['textbook_id'])
+                ->where('node_type', 'section')
+                ->pluck('id')
+                ->toArray();
+
+            if (empty($allChapterIds)) {
+                Log::warning('ExamTypeStrategy: 教材下未找到章节', [
+                    'textbook_id' => $params['textbook_id']
+                ]);
+            } else {
+                // 步骤2:从这些章节中筛选出有题目的章节
+                $chapterIdList = DB::table('questions')
+                    ->whereIn('textbook_catalog_nodes_id', $allChapterIds)
+                    ->whereNotNull('textbook_catalog_nodes_id')
+                    ->where('textbook_catalog_nodes_id', '!=', '')
+                    ->distinct()
+                    ->pluck('textbook_catalog_nodes_id')
+                    ->toArray();
+
+                Log::info('ExamTypeStrategy: 自动选择的章节列表', [
+                    'textbook_id' => $params['textbook_id'],
+                    'total_chapters' => count($allChapterIds),
+                    'chapters_with_questions' => count($chapterIdList),
+                    'chapter_ids' => $chapterIdList
+                ]);
+            }
+        }
+
         if (empty($chapterIdList)) {
-            Log::warning('ExamTypeStrategy: 教材组卷需要 chapter_id_list 参数');
+            Log::warning('ExamTypeStrategy: 教材组卷需要 chapter_id_list 参数或有效的textbook_id');
             return $this->buildGeneralParams($params);
         }
 

+ 18 - 0
app/Services/LearningAnalyticsService.php

@@ -1318,6 +1318,15 @@ class LearningAnalyticsService
                         '最终kp_codes' => $kpCodes,
                     ]);
                 }
+
+                // 【修复】教材出卷(assemble_type=3)不使用薄弱点,只按章节筛选
+                if ($assembleType == 3) {
+                    $kpCodes = [];
+                    Log::info("LearningAnalyticsService: 教材出卷不使用薄弱点,清空知识点", [
+                        'assemble_type' => $assembleType,
+                        'chapter_ids' => $params['chapter_id_list'] ?? [],
+                    ]);
+                }
             }
 
             Log::info("准备调用 getQuestionsFromBank", [
@@ -1438,6 +1447,15 @@ class LearningAnalyticsService
 
             if (!$isMistakeBook && count($priorityQuestions) < $totalQuestions) {
                 try {
+                    // 【修复】教材出卷(assemble_type=3)只按章节筛选,不按知识点筛选
+                    if ($assembleType == 3) {
+                        $kpCodes = [];
+                        Log::info('LearningAnalyticsService: 教材出卷模式,清空知识点筛选', [
+                            'assemble_type' => $assembleType,
+                            'chapter_ids' => $params['chapter_id_list'] ?? [],
+                        ]);
+                    }
+
                     Log::info('开始调用 getQuestionsFromBank 补充题目', [
                         'kp_codes_count' => count($kpCodes),
                         'skills_count' => count($skills),