Sfoglia il codice sorgente

增加query 学生 id

yemeishu 1 mese fa
parent
commit
050607c717

+ 15 - 0
app/Filament/Pages/IntelligentExamGeneration.php

@@ -5,6 +5,7 @@ namespace App\Filament\Pages;
 use App\Services\KnowledgeGraphService;
 use App\Services\LearningAnalyticsService;
 use App\Services\QuestionBankService;
+use App\Models\Student;
 use BackedEnum;
 use Filament\Notifications\Notification;
 use Filament\Pages\Page;
@@ -60,6 +61,20 @@ class IntelligentExamGeneration extends Page
     public array $generatedQuestions = [];
     public ?string $generatedPaperId = null;
 
+    public function mount(): void
+    {
+        $this->selectedTeacherId = request()->query('teacher_id', $this->selectedTeacherId);
+        $this->selectedStudentId = request()->query('student_id', $this->selectedStudentId);
+
+        // 如果只传了 student_id,补全 teacher_id 以便学生下拉加载
+        if ($this->selectedStudentId && !$this->selectedTeacherId) {
+            $student = Student::find($this->selectedStudentId);
+            if ($student && $student->teacher_id) {
+                $this->selectedTeacherId = (string) $student->teacher_id;
+            }
+        }
+    }
+
     #[Computed(cache: false)]
     public function knowledgePoints(): array
     {

+ 13 - 0
app/Filament/Pages/StudentDashboard.php

@@ -17,6 +17,7 @@ use Livewire\Attributes\Layout;
 use Livewire\Attributes\Title;
 use Livewire\Attributes\On;
 use Livewire\Attributes\Computed;
+use App\Models\Student as StudentModel;
 
 class StudentDashboard extends Page
 {
@@ -53,6 +54,18 @@ class StudentDashboard extends Page
         $this->teacherId = $request->input('teacher_id', '');
         // 从请求中获取学生ID
         $this->studentId = $request->input('student_id', '');
+
+        if ($this->studentId && empty($this->teacherId)) {
+            $student = StudentModel::find($this->studentId);
+            if ($student && $student->teacher_id) {
+                $this->teacherId = (string) $student->teacher_id;
+            }
+        }
+
+        // 若已通过 URL 传入学生,自动加载仪表盘数据,减少手动刷新
+        if ($this->studentId && $this->teacherId) {
+            $this->loadDashboardData();
+        }
     }
 
     #[Computed]

+ 1 - 1
resources/views/filament/pages/intelligent-exam-generation-simple.blade.php

@@ -136,7 +136,7 @@
                                 @endif
                             </option>
                             @foreach($this->students as $student)
-                                <option value="{{ $student->student_id }}">
+                                <option value="{{ $student->student_id }}" @if(request('student_id') == $student->student_id) selected @endif>
                                     {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
                                 </option>
                             @endforeach

+ 28 - 0
resources/views/filament/pages/student-dashboard.blade.php

@@ -316,6 +316,34 @@
                     </div>
                 @endif
 
+                {{-- 专题测试 / 智能出卷入口 --}}
+                @if(!empty($studentId))
+                    <div class="bg-white overflow-hidden shadow-sm rounded-xl border border-gray-200 hover:shadow-md transition-shadow duration-200">
+                        <div class="p-6 flex items-center justify-between">
+                            <div class="flex items-center">
+                                <div class="flex-shrink-0">
+                                    <div class="w-12 h-12 bg-gradient-to-br from-indigo-500 to-indigo-600 rounded-xl flex items-center justify-center shadow-lg">
+                                        <svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.1 0-2 .9-2 2v8h4v-8c0-1.1-.9-2-2-2zm0 0V4m0 16h.01M6 12h.01M18 12h.01" />
+                                        </svg>
+                                    </div>
+                                </div>
+                                <div class="ml-4">
+                                    <p class="text-sm font-medium text-gray-600">专题测试</p>
+                                    <p class="text-lg font-semibold text-gray-900">智能出卷</p>
+                                    <p class="text-sm text-gray-500">携带学生ID直达出卷,题目偏向薄弱点</p>
+                                </div>
+                            </div>
+                            <a
+                                href="{{ url('/admin/intelligent-exam-generation') }}?student_id={{ $studentId }}"
+                                class="inline-flex items-center px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium hover:bg-indigo-700"
+                            >
+                                前往出卷
+                            </a>
+                        </div>
+                    </div>
+                @endif
+
                 {{-- 学习路径 --}}
                 @if (isset($dashboardData['learning_path']['analytics']))
                     <div class="bg-white overflow-hidden shadow-sm rounded-xl border border-gray-200 hover:shadow-md transition-shadow duration-200">