|
|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
use App\Models\KnowledgeExplanation;
|
|
|
+use App\Models\Paper;
|
|
|
use App\Services\ExamPdfExportService;
|
|
|
use App\Services\TaskManager;
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
@@ -56,6 +57,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
'pdf_url' => $pdfUrl,
|
|
|
'generated_at' => now(),
|
|
|
]);
|
|
|
+ $this->syncPaperRecord($record, $pdfUrl);
|
|
|
|
|
|
$taskManager->markTaskCompleted($this->taskId, [
|
|
|
'paper_id' => $this->knowledgeId,
|
|
|
@@ -86,4 +88,40 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
->update(['status' => 'failed']);
|
|
|
app(TaskManager::class)->markTaskFailed($this->taskId, $exception->getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ private function syncPaperRecord(KnowledgeExplanation $record, string $pdfUrl): void
|
|
|
+ {
|
|
|
+ $paperId = (string) ($record->knowledge_id ?? '');
|
|
|
+ if ($paperId === '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $displayCode = (string) preg_replace('/^(paper_|knowledge_)/', '', $paperId);
|
|
|
+ if ($displayCode === '') {
|
|
|
+ $displayCode = $paperId;
|
|
|
+ }
|
|
|
+
|
|
|
+ Paper::query()->updateOrCreate(
|
|
|
+ ['paper_id' => $paperId],
|
|
|
+ [
|
|
|
+ 'student_id' => (string) ($record->student_id ?? ''),
|
|
|
+ 'teacher_id' => (string) ($record->teacher_id ?? ''),
|
|
|
+ 'params' => [
|
|
|
+ 'source' => 'knowledge_explanation',
|
|
|
+ 'knowledge_id' => $paperId,
|
|
|
+ 'kp_codes' => is_array($record->kp_codes) ? $record->kp_codes : [],
|
|
|
+ ],
|
|
|
+ 'paper_name' => '知识点讲解_' . $displayCode,
|
|
|
+ 'paper_type' => 22,
|
|
|
+ 'total_questions' => 0,
|
|
|
+ 'total_score' => 0,
|
|
|
+ 'status' => 'completed',
|
|
|
+ 'difficulty_category' => null,
|
|
|
+ 'exam_pdf_url' => $pdfUrl,
|
|
|
+ 'grading_pdf_url' => null,
|
|
|
+ 'all_pdf_url' => $pdfUrl,
|
|
|
+ 'completed_at' => now(),
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|