|
@@ -45,6 +45,7 @@ class QuestionPdfController extends Controller
|
|
|
'teacher_name' => 'nullable|string|max:50',
|
|
'teacher_name' => 'nullable|string|max:50',
|
|
|
'paper_name' => 'nullable|string|max:100',
|
|
'paper_name' => 'nullable|string|max:100',
|
|
|
'include_grading' => 'nullable|boolean',
|
|
'include_grading' => 'nullable|boolean',
|
|
|
|
|
+ 'source' => 'nullable|string|in:default,ai', // 题库来源:default=默认表(questions_tem),ai=ai表(questions_ai)
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
@@ -62,17 +63,21 @@ class QuestionPdfController extends Controller
|
|
|
$teacherName = $request->input('teacher_name', '');
|
|
$teacherName = $request->input('teacher_name', '');
|
|
|
$paperName = $request->input('paper_name', '专项练习');
|
|
$paperName = $request->input('paper_name', '专项练习');
|
|
|
$includeGrading = $request->input('include_grading', false);
|
|
$includeGrading = $request->input('include_grading', false);
|
|
|
|
|
+ $source = $request->input('source', 'default'); // 题库来源:default=questions_tem, ai=questions_ai
|
|
|
|
|
|
|
|
Log::info('生成指定题目PDF', [
|
|
Log::info('生成指定题目PDF', [
|
|
|
'question_ids' => $questionIds,
|
|
'question_ids' => $questionIds,
|
|
|
'student_id' => $studentId,
|
|
'student_id' => $studentId,
|
|
|
'count' => count($questionIds),
|
|
'count' => count($questionIds),
|
|
|
|
|
+ 'source' => $source,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- // 1. Fetch questions from database (使用 questions_temp 临时表)
|
|
|
|
|
|
|
+ // 1. Fetch questions from database
|
|
|
|
|
+ $tableName = $source === 'ai' ? 'questions_ai' : 'questions_tem';
|
|
|
|
|
+
|
|
|
$questions = DB::connection('remote_mysql')
|
|
$questions = DB::connection('remote_mysql')
|
|
|
- ->table('questions_tem')
|
|
|
|
|
|
|
+ ->table($tableName)
|
|
|
->whereIn('id', $questionIds)
|
|
->whereIn('id', $questionIds)
|
|
|
->get();
|
|
->get();
|
|
|
|
|
|