ocr-paper-grading.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <x-filament-panels::page>
  2. @push('styles')
  3. <style>
  4. .status-pending { color: #6b7280; }
  5. .status-processing { color: #3b82f6; }
  6. .status-completed { color: #10b981; }
  7. .status-failed { color: #ef4444; }
  8. </style>
  9. @endpush
  10. <div class="space-y-6">
  11. <!-- 上传区域 -->
  12. <div class="bg-white p-6 rounded-lg shadow">
  13. <div class="flex items-center gap-3 mb-6">
  14. <div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
  15. <x-heroicon-o-document-plus class="w-6 h-6 text-blue-600" />
  16. </div>
  17. <div>
  18. <h2 class="text-xl font-bold text-gray-900">上传试卷进行OCR识别</h2>
  19. <p class="text-sm text-gray-500">支持JPG、PNG格式图片</p>
  20. </div>
  21. </div>
  22. <div class="space-y-4">
  23. {{-- 选择老师和学生 --}}
  24. <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
  25. {{-- 选择老师 --}}
  26. <div class="form-control w-full">
  27. <label class="block text-sm font-medium text-gray-700 mb-2">
  28. 选择老师 <span class="text-red-500">*</span>
  29. @if($isTeacher ?? false)
  30. <span class="text-green-600 text-xs ml-2">(当前登录)</span>
  31. @endif
  32. </label>
  33. <select
  34. wire:model.live="teacherId"
  35. @if($isTeacher ?? false) disabled @endif
  36. class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 @if($isTeacher ?? false) bg-gray-100 @endif"
  37. >
  38. <option value="">请选择老师...</option>
  39. @foreach($this->teachers as $teacher)
  40. <option value="{{ $teacher->teacher_id }}">
  41. {{ trim($teacher->name ?? $teacher->teacher_id) . ($teacher->subject ? " ({$teacher->subject})" : '') }}
  42. </option>
  43. @endforeach
  44. </select>
  45. </div>
  46. {{-- 选择学生 --}}
  47. <div class="form-control w-full">
  48. <label class="block text-sm font-medium text-gray-700 mb-2">选择学生 <span class="text-red-500">*</span></label>
  49. <select
  50. wire:model.live="studentId"
  51. wire:loading.attr="disabled"
  52. @if(empty($teacherId)) disabled @endif
  53. class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 @if(empty($teacherId)) bg-gray-100 @endif"
  54. >
  55. <option value="">
  56. @if(empty($teacherId))
  57. 请先选择老师
  58. @else
  59. 请选择学生...
  60. @endif
  61. </option>
  62. @foreach($this->students as $student)
  63. <option value="{{ $student->student_id }}">
  64. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  65. </option>
  66. @endforeach
  67. </select>
  68. </div>
  69. </div>
  70. {{-- 选择试卷 --}}
  71. @if(!empty($studentId))
  72. <div class="form-control w-full">
  73. <label class="block text-sm font-medium text-gray-700 mb-2">选择试卷 <span class="text-red-500">*</span></label>
  74. <select
  75. wire:model.live="selectedPaperId"
  76. class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
  77. >
  78. <option value="">请选择试卷...</option>
  79. @foreach($this->studentPapers as $paper)
  80. <option value="{{ $paper['paper_id'] }}">
  81. {{ $paper['paper_name'] }} ({{ $paper['total_questions'] }}题 / {{ $paper['total_score'] }}分) - {{ $paper['created_at'] }}
  82. </option>
  83. @endforeach
  84. </select>
  85. </div>
  86. @endif
  87. {{-- 显示选中的试卷题目 --}}
  88. @if(!empty($selectedPaperId) && count($this->selectedPaperQuestions) > 0)
  89. <div class="p-4 bg-blue-50 border border-blue-200 rounded-lg">
  90. <h3 class="text-sm font-medium text-blue-900 mb-2">选中的试卷题目(共{{ count($this->selectedPaperQuestions) }}题)</h3>
  91. <div class="space-y-2 max-h-40 overflow-y-auto">
  92. @foreach($this->selectedPaperQuestions as $index => $question)
  93. <div class="text-xs text-blue-800">
  94. <span class="font-medium">第{{ $question['question_number'] ?? ($index + 1) }}题:</span>
  95. {{ Str::limit(strip_tags($question['content'] ?? $question['stem'] ?? ''), 80) }}
  96. </div>
  97. @endforeach
  98. </div>
  99. </div>
  100. @endif
  101. {{-- 图片上传组件 --}}
  102. @if(!empty($selectedPaperId))
  103. @livewire(\App\Livewire\UploadExam\UploadForm::class, [
  104. 'teacherId' => $teacherId,
  105. 'studentId' => $studentId,
  106. 'selectedPaperId' => $selectedPaperId
  107. ], key('upload-form-' . $selectedPaperId))
  108. @endif
  109. </div>
  110. </div>
  111. <!-- 当前处理状态 -->
  112. @if($selectedRecord)
  113. <div class="bg-white p-6 rounded-lg shadow">
  114. <div class="flex items-center gap-3 mb-6">
  115. <div class="w-12 h-12 bg-yellow-100 rounded-xl flex items-center justify-center">
  116. <x-heroicon-o-clock class="w-6 h-6 text-yellow-600" />
  117. </div>
  118. <div>
  119. <h2 class="text-xl font-bold text-gray-900">处理进度</h2>
  120. <p class="text-sm text-gray-500">{{ $selectedRecord->paper_title }}</p>
  121. </div>
  122. </div>
  123. <div class="space-y-4">
  124. <!-- 处理步骤指示器 -->
  125. <div class="flex justify-between items-center">
  126. <div class="flex items-center gap-4">
  127. <div class="flex flex-col items-center">
  128. <div class="w-10 h-10 rounded-full {{ $selectedRecord->status === 'pending' ? 'bg-blue-600' : 'bg-green-500' }} flex items-center justify-center">
  129. <x-heroicon-o-check class="w-5 h-5 text-white" />
  130. </div>
  131. <span class="text-xs mt-1">上传</span>
  132. </div>
  133. <div class="flex flex-col items-center">
  134. <div class="w-10 h-10 rounded-full {{ $selectedRecord->status === 'processing' ? 'bg-blue-600 animate-pulse' : ($selectedRecord->status === 'completed' ? 'bg-green-500' : 'bg-gray-200') }} flex items-center justify-center">
  135. <x-heroicon-o-cpu-chip class="w-5 h-5 {{ in_array($selectedRecord->status, ['processing', 'completed']) ? 'text-white' : 'text-gray-600' }}" />
  136. </div>
  137. <span class="text-xs mt-1">OCR识别</span>
  138. </div>
  139. <div class="flex flex-col items-center">
  140. <div class="w-10 h-10 rounded-full {{ $selectedRecord->status === 'completed' ? 'bg-green-500' : 'bg-gray-200' }} flex items-center justify-center">
  141. <x-heroicon-o-academic-cap class="w-5 h-5 {{ $selectedRecord->status === 'completed' ? 'text-white' : 'text-gray-600' }}" />
  142. </div>
  143. <span class="text-xs mt-1">AI判分</span>
  144. </div>
  145. </div>
  146. <div class="text-right">
  147. <span class="text-sm text-gray-500">状态:</span>
  148. <span class="font-semibold status-{{ $selectedRecord->status }}">
  149. @switch($selectedRecord->status)
  150. @case('pending') 待处理 @break
  151. @case('processing') 处理中 @break
  152. @case('completed') 已完成 @break
  153. @case('failed') 失败 @break
  154. @default 未知
  155. @endswitch
  156. </span>
  157. </div>
  158. </div>
  159. <!-- 处理结果 -->
  160. @if($selectedRecord->status === 'completed' && $selectedRecord->questions->count() > 0)
  161. <div class="mt-6 border-t pt-6">
  162. <h3 class="font-semibold text-gray-900 mb-4">识别结果预览</h3>
  163. <div class="space-y-3">
  164. @foreach($selectedRecord->questions->take(5) as $question)
  165. <div class="flex items-center justify-between p-3 bg-gray-50 rounded">
  166. <div>
  167. <span class="font-medium">第{{ $question->question_number }}题</span>
  168. <span class="text-sm text-gray-600 ml-2">{{ $question->question_type }}</span>
  169. </div>
  170. <div class="text-sm">
  171. <span class="text-gray-600">答案:</span>
  172. <span class="font-medium">{{ $question->student_answer }}</span>
  173. </div>
  174. </div>
  175. @endforeach
  176. @if($selectedRecord->questions->count() > 5)
  177. <p class="text-sm text-gray-500 text-center">...还有 {{ $selectedRecord->questions->count() - 5 }} 道题</p>
  178. @endif
  179. </div>
  180. </div>
  181. <div class="flex justify-end gap-3 mt-6">
  182. <button
  183. wire:click="regrade({{ $selectedRecord->id }})"
  184. class="px-4 py-2 text-blue-600 border border-blue-600 rounded-lg hover:bg-blue-50"
  185. >
  186. 重新判分
  187. </button>
  188. <a
  189. href="/admin/ocr-analysis-view/{{ $selectedRecord->id }}"
  190. class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700"
  191. >
  192. 查看详细分析
  193. </a>
  194. </div>
  195. @endif
  196. @if($selectedRecord->status === 'failed')
  197. <div class="mt-4 p-4 bg-red-50 rounded-lg">
  198. <p class="text-red-800 text-sm">{{ $selectedRecord->error_message ?? '处理失败,请重试' }}</p>
  199. </div>
  200. @endif
  201. </div>
  202. </div>
  203. @endif
  204. <!-- 最近记录 -->
  205. <div class="bg-white p-6 rounded-lg shadow">
  206. <h2 class="text-xl font-bold text-gray-900 mb-6">最近处理记录</h2>
  207. <div class="overflow-x-auto">
  208. <table class="w-full">
  209. <thead>
  210. <tr class="border-b border-gray-200">
  211. <th class="text-left py-3 text-sm font-semibold text-gray-600">试卷标题</th>
  212. <th class="text-left py-3 text-sm font-semibold text-gray-600">学生ID</th>
  213. <th class="text-left py-3 text-sm font-semibold text-gray-600">题数</th>
  214. <th class="text-left py-3 text-sm font-semibold text-gray-600">状态</th>
  215. <th class="text-left py-3 text-sm font-semibold text-gray-600">提交时间</th>
  216. <th class="text-left py-3 text-sm font-semibold text-gray-600">操作</th>
  217. </tr>
  218. </thead>
  219. <tbody>
  220. @foreach($this->getRecentRecords() as $record)
  221. <tr class="border-b border-gray-100 hover:bg-gray-50">
  222. <td class="py-3 text-sm text-gray-900">{{ $record->paper_title }}</td>
  223. <td class="py-3 text-sm text-gray-600">{{ $record->user_id }}</td>
  224. <td class="py-3 text-sm text-gray-600">{{ $record->questions->count() }}</td>
  225. <td class="py-3 text-sm">
  226. <span class="px-2 py-1 rounded-full text-xs status-{{ $record->status }}">
  227. @switch($record->status)
  228. @case('pending') 待处理 @break
  229. @case('processing') 处理中 @break
  230. @case('completed') 已完成 @break
  231. @case('failed') 失败 @break
  232. @default 未知
  233. @endswitch
  234. </span>
  235. </td>
  236. <td class="py-3 text-sm text-gray-600">{{ $record->created_at->diffForHumans() }}</td>
  237. <td class="py-3">
  238. <button
  239. wire:click="viewRecord({{ $record->id }})"
  240. class="text-sm text-blue-600 hover:text-blue-700"
  241. >
  242. 查看
  243. </button>
  244. </td>
  245. </tr>
  246. @endforeach
  247. </tbody>
  248. </table>
  249. </div>
  250. </div>
  251. </div>
  252. </x-filament-panels::page>