mistake-book.blade.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <div class="min-h-screen bg-gray-50 p-8">
  2. {{-- 页面标题区域 --}}
  3. <div class="mb-8">
  4. <div class="bg-white rounded-xl shadow-sm p-6 border border-gray-200">
  5. <div class="flex items-center justify-between mb-6">
  6. <div>
  7. <h1 class="text-3xl font-bold text-gray-900 flex items-center">
  8. <svg class="w-8 h-8 mr-3 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  9. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"></path>
  10. </svg>
  11. 错题本
  12. </h1>
  13. <p class="mt-2 text-sm text-gray-600 ml-11">查看学生错题记录与AI分析,生成针对性练习</p>
  14. </div>
  15. </div>
  16. {{-- 选择器区域 --}}
  17. <div class="bg-gray-50 rounded-lg p-4 border border-gray-200">
  18. <div class="flex flex-col gap-3 lg:flex-row lg:items-center">
  19. @if(!$this->isTeacher)
  20. <div class="form-control w-full lg:flex-1">
  21. <label class="label"><span class="label-text font-medium">选择老师</span></label>
  22. <select wire:model.live="teacherId" class="select select-bordered w-full h-11">
  23. <option value="">请选择老师...</option>
  24. @foreach($this->teachers as $teacher)
  25. <option value="{{ $teacher->teacher_id }}">
  26. {{ trim($teacher->name ?? $teacher->teacher_id) . ($teacher->subject ? " ({$teacher->subject})" : '') }}
  27. </option>
  28. @endforeach
  29. </select>
  30. </div>
  31. @endif
  32. <div class="form-control w-full lg:flex-1">
  33. <label class="label"><span class="label-text font-medium">选择学生</span></label>
  34. <select wire:model.live="studentId" class="select select-bordered w-full h-11" @if(empty($teacherId)) disabled @endif>
  35. <option value="">{{ empty($teacherId) ? '请先选择老师' : '请选择学生...' }}</option>
  36. @foreach($this->students as $student)
  37. <option value="{{ $student->student_id }}">
  38. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  39. </option>
  40. @endforeach
  41. </select>
  42. </div>
  43. <div class="w-full lg:w-auto flex items-center lg:pt-6">
  44. <button wire:click="loadMistakeData" wire:loading.attr="disabled"
  45. class="inline-flex items-center justify-center w-full h-11 px-6 border border-transparent text-sm font-medium rounded-lg shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200">
  46. <svg wire:loading class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" fill="none" viewBox="0 0 24 24">
  47. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  48. <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
  49. </svg>
  50. 刷新数据
  51. </button>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. {{-- 错误提示 --}}
  58. @if ($errorMessage)
  59. <div class="mb-8">
  60. <div class="bg-red-50 border border-red-200 rounded-xl p-4">
  61. <div class="flex items-start">
  62. <svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
  63. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
  64. </svg>
  65. <div class="ml-3">
  66. <h3 class="text-sm font-medium text-red-800">加载错误</h3>
  67. <p class="mt-1 text-sm text-red-700">{{ $errorMessage }}</p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. @endif
  73. @if ($actionMessage)
  74. <div class="mb-8">
  75. <div class="bg-green-50 border border-green-200 rounded-xl p-4">
  76. <p class="text-sm text-green-700">{{ $actionMessage }}</p>
  77. </div>
  78. </div>
  79. @endif
  80. {{-- 错题分析 Widgets --}}
  81. @if($studentId)
  82. <div class="mb-8 space-y-6">
  83. {{-- 统计概览 --}}
  84. <div>
  85. @livewire(\App\Livewire\MistakeBook\MistakeStatsOverview::class, ['studentId' => $studentId])
  86. </div>
  87. {{-- 错题趋势图表 --}}
  88. <div>
  89. @livewire(\App\Livewire\MistakeBook\MistakeTrendsChart::class, ['studentId' => $studentId])
  90. </div>
  91. {{-- 错误类型分布和知识点薄弱环节 --}}
  92. <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
  93. <div>
  94. @livewire(\App\Livewire\MistakeBook\ErrorTypeDistributionChart::class, ['studentId' => $studentId])
  95. </div>
  96. <div>
  97. @livewire(\App\Livewire\MistakeBook\WeakKnowledgePointsChart::class, ['studentId' => $studentId])
  98. </div>
  99. </div>
  100. </div>
  101. @endif
  102. {{-- 加载状态 --}}
  103. @if ($isLoading)
  104. <div class="mb-8">
  105. <div class="bg-white rounded-xl shadow-sm p-12 border border-gray-200">
  106. <div class="flex flex-col items-center justify-center">
  107. <svg class="animate-spin h-12 w-12 text-indigo-600" fill="none" viewBox="0 0 24 24">
  108. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  109. <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
  110. </svg>
  111. <p class="mt-4 text-sm text-gray-600">正在加载数据,请稍候...</p>
  112. </div>
  113. </div>
  114. </div>
  115. @else
  116. {{-- 学习状态概览 --}}
  117. <div class="mb-8">
  118. <div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
  119. {{-- 今日必复习 --}}
  120. <div class="lg:col-span-2 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl shadow-sm p-6 text-white">
  121. <div class="flex items-center justify-between mb-4">
  122. <h3 class="text-lg font-semibold">今日必复习</h3>
  123. <span class="bg-white/20 px-3 py-1 rounded-full text-sm">
  124. {{ count($mistakes) }} 道错题
  125. </span>
  126. </div>
  127. <div class="space-y-3">
  128. @php
  129. $urgentMistakes = collect($mistakes)->take(3);
  130. @endphp
  131. @if($urgentMistakes->isNotEmpty())
  132. @foreach($urgentMistakes as $mistake)
  133. @php
  134. $tags = [];
  135. if (!empty($mistake['question']['question_number'])) {
  136. $tags[] = '第' . $mistake['question']['question_number'] . '题';
  137. }
  138. if (!empty($mistake['question']['kp_code'])) {
  139. $kpName = $knowledgePointOptions[$mistake['question']['kp_code']] ?? $mistake['question']['kp_code'];
  140. if ($kpName && $kpName !== $mistake['question']['kp_code']) {
  141. $tags[] = $kpName;
  142. }
  143. }
  144. if (!empty($mistake['error_type'])) {
  145. $tags[] = $mistake['error_type'];
  146. }
  147. @endphp
  148. <div class="bg-white/10 backdrop-blur rounded-lg p-4 hover:bg-white/20 transition-colors cursor-pointer">
  149. @if(!empty($tags))
  150. <div class="flex flex-wrap gap-1.5 mb-2">
  151. @foreach($tags as $tag)
  152. <span class="text-xs bg-white/20 px-2 py-0.5 rounded">{{ $tag }}</span>
  153. @endforeach
  154. </div>
  155. @endif
  156. <div class="mb-3">
  157. <p class="text-sm leading-relaxed">
  158. {{ $mistake['question']['stem'] ?? '暂无题干' }}
  159. </p>
  160. </div>
  161. <div class="flex justify-end">
  162. <a href="{{ url('/admin/question-detail') }}?mistake_id={{ $mistake['id'] ?? '' }}&student_id={{ $studentId }}"
  163. class="text-xs bg-white/20 hover:bg-white/30 px-3 py-1 rounded transition-colors inline-block">
  164. 查看详情
  165. </a>
  166. </div>
  167. </div>
  168. @endforeach
  169. @else
  170. <div class="text-center py-8 text-white/80">
  171. <svg class="w-16 h-16 mx-auto mb-4 text-white/50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  172. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  173. </svg>
  174. <p class="text-sm">暂无错题数据</p>
  175. <p class="text-xs mt-1 text-white/60">请先选择学生并刷新数据</p>
  176. </div>
  177. @endif
  178. </div>
  179. @if($urgentMistakes->isNotEmpty())
  180. <div class="mt-4 pt-4 border-t border-white/20">
  181. <button wire:click="startQuickReview"
  182. class="w-full bg-white text-indigo-600 px-4 py-2 rounded-lg text-sm font-medium hover:bg-gray-50 transition-colors">
  183. 开始快速复习 (前5题)
  184. </button>
  185. </div>
  186. @endif
  187. </div>
  188. {{-- 学习进度 --}}
  189. <div class="bg-white rounded-xl shadow-sm p-6 border border-gray-200">
  190. <h3 class="text-lg font-semibold text-gray-900 mb-4">学习进度</h3>
  191. <!-- 掌握度显示 -->
  192. <div class="mb-6">
  193. <div class="flex items-center justify-between mb-2">
  194. <span class="text-sm text-gray-600">整体掌握度</span>
  195. <span class="text-xs text-gray-500">基于所有知识点平均</span>
  196. </div>
  197. <div class="relative">
  198. <div class="w-full bg-gray-200 rounded-full h-3">
  199. @php
  200. $masteryRate = $summary['mastery_rate'] ?? 0;
  201. $masteryPercentage = $masteryRate * 100;
  202. @endphp
  203. <div class="bg-indigo-600 h-3 rounded-full transition-all duration-500"
  204. style="width: {{ $masteryPercentage }}%"></div>
  205. </div>
  206. </div>
  207. <p class="text-2xl font-bold text-indigo-600 mt-2 text-center">
  208. {{ number_format($masteryPercentage, 0) }}%
  209. </p>
  210. </div>
  211. <!-- 统计信息 -->
  212. <div class="space-y-3">
  213. <div class="flex items-center justify-between p-3 bg-orange-50 rounded-lg">
  214. <span class="text-sm text-gray-600">待复习知识点</span>
  215. <span class="text-xl font-bold text-orange-600">{{ $summary['pending_review'] ?? 0 }}</span>
  216. </div>
  217. <div class="flex items-center justify-between p-3 bg-red-50 rounded-lg">
  218. <span class="text-sm text-gray-600">总错题数</span>
  219. <span class="text-xl font-bold text-red-600">{{ $summary['total'] ?? 0 }}</span>
  220. </div>
  221. <div class="flex items-center justify-between p-3 bg-blue-50 rounded-lg">
  222. <span class="text-sm text-gray-600">本周新增</span>
  223. <span class="text-xl font-bold text-blue-600">{{ $summary['this_week'] ?? 0 }}</span>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. {{-- 主内容区域 --}}
  230. <div class="grid grid-cols-1 gap-6 xl:grid-cols-4">
  231. {{-- 左侧筛选 --}}
  232. <div class="xl:col-span-1">
  233. <div class="bg-white shadow-sm rounded-xl border border-gray-200 sticky top-4">
  234. <div class="px-6 py-5 border-b border-gray-100">
  235. <h3 class="text-lg font-semibold text-gray-900">筛选条件</h3>
  236. </div>
  237. <div class="p-6 space-y-6">
  238. {{-- 时间范围 --}}
  239. <div>
  240. <label class="text-sm font-medium text-gray-700 mb-3 block">时间范围</label>
  241. <div class="flex gap-2">
  242. <button wire:click="$set('filters.time_range', 'last_7')"
  243. class="flex-1 px-4 py-2 text-sm font-medium rounded-lg transition-colors {{ $filters['time_range'] === 'last_7' ? 'bg-indigo-600 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }}">
  244. 7天
  245. </button>
  246. <button wire:click="$set('filters.time_range', 'last_30')"
  247. class="flex-1 px-4 py-2 text-sm font-medium rounded-lg transition-colors {{ $filters['time_range'] === 'last_30' ? 'bg-indigo-600 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }}">
  248. 30天
  249. </button>
  250. </div>
  251. </div>
  252. {{-- 错误类型 --}}
  253. <div>
  254. <label class="text-sm font-medium text-gray-700 mb-3 block">错误类型</label>
  255. <div class="space-y-2">
  256. @foreach(['计算错误', '概念错误', '方法错误', '审题错误'] as $type)
  257. <label class="flex items-center gap-3 cursor-pointer p-2 rounded-lg hover:bg-gray-50">
  258. <input type="checkbox" value="{{ $type }}" wire:model="filters.error_types"
  259. class="w-4 h-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
  260. <span class="text-sm text-gray-700">{{ $type }}</span>
  261. </label>
  262. @endforeach
  263. </div>
  264. </div>
  265. <button wire:click="applyFilters"
  266. class="w-full px-4 py-2.5 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition-colors">
  267. 应用筛选
  268. </button>
  269. </div>
  270. </div>
  271. </div>
  272. {{-- 右侧错题列表 --}}
  273. <div class="xl:col-span-3 space-y-6">
  274. {{-- 错题列表 --}}
  275. <div class="bg-white shadow-sm rounded-xl border border-gray-200">
  276. <div class="px-6 py-5 border-b border-gray-100 flex items-center justify-between">
  277. <h3 class="text-lg font-semibold text-gray-900 flex items-center">
  278. <svg class="w-5 h-5 mr-2 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  279. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"></path>
  280. </svg>
  281. 错题列表 ({{ $total }})
  282. </h3>
  283. <div class="flex items-center gap-3">
  284. @if(!empty($selectedMistakeIds))
  285. <button wire:click="generatePracticeFromSelection"
  286. class="inline-flex items-center px-4 py-2 bg-green-600 text-white text-sm font-medium rounded-lg hover:bg-green-700 transition-colors">
  287. 生成练习 ({{ count($selectedMistakeIds) }})
  288. </button>
  289. @endif
  290. </div>
  291. </div>
  292. <div class="p-6">
  293. @if(empty($mistakes))
  294. <div class="text-center py-12">
  295. <svg class="w-16 h-16 mx-auto text-gray-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  296. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  297. </svg>
  298. <p class="text-sm font-medium text-gray-900 mb-1">暂无错题数据</p>
  299. <p class="text-xs text-gray-500">请先选择学生后刷新数据</p>
  300. </div>
  301. @else
  302. <div class="space-y-4">
  303. @foreach($mistakes as $mistake)
  304. <div class="border border-gray-200 rounded-xl p-5 hover:border-gray-300 transition-colors" wire:key="m-{{ $mistake['id'] ?? $loop->index }}">
  305. {{-- 头部 --}}
  306. <div class="flex items-start gap-4">
  307. <input type="checkbox"
  308. wire:click="toggleSelection('{{ $mistake['id'] ?? '' }}')"
  309. @checked(in_array($mistake['id'] ?? '', $selectedMistakeIds, true))
  310. class="mt-1 w-5 h-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
  311. <div class="flex-1 min-w-0">
  312. {{-- 标签行 --}}
  313. <div class="flex flex-wrap items-center gap-2 mb-4">
  314. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
  315. #{{ $mistake['id'] ?? '' }}
  316. </span>
  317. @if(!empty($mistake['question']['question_number']))
  318. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
  319. 第{{ $mistake['question']['question_number'] }}题
  320. </span>
  321. @endif
  322. <span class="text-xs text-gray-500">
  323. @php
  324. $createdAt = $mistake['created_at'] ?? null;
  325. if ($createdAt) {
  326. try {
  327. $date = \Carbon\Carbon::parse($createdAt);
  328. echo $date->format('Y-m-d H:i');
  329. } catch (\Exception $e) {
  330. echo $createdAt;
  331. }
  332. }
  333. @endphp
  334. </span>
  335. @if(!empty($mistake['error_type']))
  336. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
  337. {{ $mistake['error_type'] }}
  338. </span>
  339. @endif
  340. @if(!empty($mistake['mistake_category']))
  341. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-orange-100 text-orange-800">
  342. {{ $mistake['mistake_category'] }}
  343. </span>
  344. @endif
  345. </div>
  346. {{-- 题干 --}}
  347. @if(!empty($mistake['question']['stem']))
  348. <div class="bg-gray-50 rounded-lg p-4 mb-4 border border-gray-100">
  349. <p class="text-xs font-medium text-gray-500 mb-2">题干</p>
  350. <div class="prose prose-sm max-w-none text-gray-900">
  351. <x-math-render :content="$mistake['question']['stem']" />
  352. </div>
  353. </div>
  354. @endif
  355. {{-- 判卷结果 + 知识点 --}}
  356. <div class="flex flex-wrap items-center gap-3 mb-4">
  357. @if(!empty($mistake['mark_detected']))
  358. <span class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium {{ $mistake['mark_detected'] === '✓' || $mistake['mark_detected'] === '√' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' }}">
  359. 老师判卷: {{ $mistake['mark_detected'] }}
  360. </span>
  361. @endif
  362. @if(isset($mistake['score']) && isset($mistake['full_score']))
  363. @php
  364. $score = floatval($mistake['score'] ?? 0);
  365. $fullScore = floatval($mistake['full_score'] ?? 0);
  366. $isFullScore = $fullScore > 0 && $score >= $fullScore;
  367. @endphp
  368. <span class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium {{ $isFullScore ? 'bg-green-100 text-green-800' : 'bg-blue-100 text-blue-800' }}">
  369. 得分: {{ $mistake['score'] }}/{{ $mistake['full_score'] }}
  370. @if($isFullScore)
  371. @endif
  372. </span>
  373. @endif
  374. @if(!empty($mistake['question']['kp_code']))
  375. <a href="{{ url('/admin/knowledge-point-detail') }}?kp_code={{ urlencode($mistake['question']['kp_code']) }}"
  376. class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium bg-indigo-100 text-indigo-800 hover:bg-indigo-200 transition-colors">
  377. 知识点: {{ $mistake['question']['kp_code'] }}
  378. </a>
  379. @endif
  380. @if(!empty($mistake['skill_ids']))
  381. @foreach($mistake['skill_ids'] as $skillId)
  382. <span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-teal-100 text-teal-800">
  383. {{ $skillId }}
  384. </span>
  385. @endforeach
  386. @endif
  387. </div>
  388. {{-- 作答对比与解题步骤 --}}
  389. <div class="grid grid-cols-1 lg:grid-cols-3 gap-4 mb-4">
  390. @if(!empty($mistake['student_answer']) && trim($mistake['student_answer']) !== '' && trim($mistake['student_answer']) !== '未作答')
  391. <div class="bg-red-50 rounded-lg p-4 border border-red-100">
  392. <p class="text-xs font-medium text-red-600 mb-2">
  393. 学生作答
  394. @if(!empty($mistake['answer_confidence']))
  395. <span class="text-gray-400">(置信度: {{ number_format($mistake['answer_confidence'] * 100, 1) }}%)</span>
  396. @endif
  397. </p>
  398. <p class="text-sm text-gray-900">{{ $mistake['student_answer'] }}</p>
  399. </div>
  400. @elseif(!empty($mistake['mark_detected']) && trim($mistake['student_answer']) === '未作答')
  401. {{-- 老师已评分但学生未作答的题目,不显示学生作答区域 --}}
  402. @elseif(!empty($mistake['student_answer']) && trim($mistake['student_answer']) !== '')
  403. <div class="bg-red-50 rounded-lg p-4 border border-red-100">
  404. <p class="text-xs font-medium text-red-600 mb-2">
  405. 学生作答
  406. @if(!empty($mistake['answer_confidence']))
  407. <span class="text-gray-400">(置信度: {{ number_format($mistake['answer_confidence'] * 100, 1) }}%)</span>
  408. @endif
  409. </p>
  410. <p class="text-sm text-gray-900">{{ $mistake['student_answer'] }}</p>
  411. </div>
  412. @endif
  413. @if(!empty($mistake['question']['solution']))
  414. <div class="bg-blue-50 rounded-lg p-4 border border-blue-100">
  415. <p class="text-xs font-medium text-blue-600 mb-2">解题步骤</p>
  416. <div class="prose prose-sm max-w-none text-gray-900">
  417. {{ $mistake['question']['solution'] }}
  418. </div>
  419. </div>
  420. @endif
  421. @if(!empty($mistake['question']['answer']))
  422. <div class="bg-green-50 rounded-lg p-4 border border-green-100">
  423. <p class="text-xs font-medium text-green-600 mb-2">正确答案</p>
  424. <p class="text-sm text-gray-900">{{ $mistake['question']['answer'] }}</p>
  425. </div>
  426. @endif
  427. </div>
  428. {{-- AI分析 --}}
  429. @if(!empty($mistake['ai_analysis']['reason']) || !empty($mistake['ai_analysis']['solution']) || !empty($mistake['ai_analysis']['suggestions']))
  430. <details class="bg-amber-50 rounded-lg border border-amber-100 mb-4">
  431. <summary class="px-4 py-3 text-sm font-medium text-amber-800 cursor-pointer hover:bg-amber-100 rounded-lg transition-colors">
  432. 查看AI分析
  433. @if(!empty($mistake['ai_analysis']['model_used']))
  434. <span class="text-xs text-gray-500 ml-2">({{ $mistake['ai_analysis']['model_used'] }})</span>
  435. @endif
  436. </summary>
  437. <div class="px-4 pb-4 text-sm text-gray-700 space-y-2">
  438. @if(!empty($mistake['ai_analysis']['reason']))
  439. <p><span class="font-medium text-gray-900">错因:</span>{{ $mistake['ai_analysis']['reason'] }}</p>
  440. @endif
  441. @if(!empty($mistake['ai_analysis']['solution']))
  442. <p><span class="font-medium text-gray-900">解法:</span>{{ $mistake['ai_analysis']['solution'] }}</p>
  443. @endif
  444. @if(!empty($mistake['ai_analysis']['suggestions']))
  445. <p><span class="font-medium text-gray-900">建议:</span>{{ $mistake['ai_analysis']['suggestions'] }}</p>
  446. @endif
  447. @if(!empty($mistake['ai_analysis']['next_steps']))
  448. <div>
  449. <span class="font-medium text-gray-900">下一步:</span>
  450. <ul class="list-disc list-inside mt-1">
  451. @foreach($mistake['ai_analysis']['next_steps'] as $step)
  452. <li>{{ is_array($step) ? json_encode($step) : $step }}</li>
  453. @endforeach
  454. </ul>
  455. </div>
  456. @endif
  457. </div>
  458. </details>
  459. @endif
  460. {{-- 操作按钮 --}}
  461. <div class="flex flex-wrap gap-2 pt-4 border-t border-gray-100">
  462. <a href="{{ url('/admin/question-detail') }}?mistake_id={{ $mistake['id'] ?? '' }}&student_id={{ $studentId }}"
  463. class="inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-lg bg-indigo-100 text-indigo-800 hover:bg-indigo-200 transition-colors">
  464. 详情
  465. </a>
  466. <button wire:click="toggleFavorite('{{ $mistake['id'] ?? '' }}')"
  467. class="inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-lg {{ !empty($mistake['favorite']) ? 'bg-yellow-100 text-yellow-800' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }} transition-colors">
  468. {{ !empty($mistake['favorite']) ? '★ 已收藏' : '☆ 收藏' }}
  469. </button>
  470. <button wire:click="markReviewed('{{ $mistake['id'] ?? '' }}')"
  471. class="inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-lg {{ !empty($mistake['reviewed']) ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }} transition-colors">
  472. {{ !empty($mistake['reviewed']) ? '✓ 已复习' : '标记复习' }}
  473. </button>
  474. <button wire:click="loadRelatedQuestions('{{ $mistake['id'] ?? '' }}')"
  475. class="inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-lg bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors">
  476. 关联题
  477. </button>
  478. @if(!empty($mistake['answer_area_crop_path']))
  479. <a href="{{ $mistake['answer_area_crop_path'] }}" target="_blank"
  480. class="inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-lg bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors">
  481. 查看作答图片
  482. </a>
  483. @endif
  484. </div>
  485. {{-- 关联题 --}}
  486. @if(!empty($relatedQuestions[$mistake['id'] ?? ''] ?? []))
  487. <div class="mt-4 bg-gray-50 rounded-lg p-4 border border-gray-100">
  488. <p class="text-xs font-medium text-gray-500 mb-3">关联题目</p>
  489. <div class="space-y-2">
  490. @foreach($relatedQuestions[$mistake['id']] as $related)
  491. <div class="text-sm p-3 bg-white rounded-lg border border-gray-200">
  492. <p class="text-gray-900 line-clamp-2">{{ $related['stem'] ?? '题目' }}</p>
  493. </div>
  494. @endforeach
  495. </div>
  496. </div>
  497. @endif
  498. </div>
  499. </div>
  500. </div>
  501. @endforeach
  502. </div>
  503. {{-- 分页 --}}
  504. @php
  505. $maxPage = (int) ceil($total / $perPage);
  506. @endphp
  507. @if($maxPage > 1)
  508. <div class="mt-6 flex items-center justify-between border-t border-gray-100 pt-4">
  509. <div class="text-sm text-gray-500">
  510. 共 {{ $total }} 条,第 {{ $page }}/{{ $maxPage }} 页
  511. </div>
  512. <div class="flex items-center gap-2">
  513. <button wire:click="prevPage" @disabled($page <= 1)
  514. class="px-3 py-1.5 text-sm font-medium rounded-lg {{ $page <= 1 ? 'bg-gray-100 text-gray-400 cursor-not-allowed' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }} transition-colors">
  515. 上一页
  516. </button>
  517. @for($i = max(1, $page - 2); $i <= min($maxPage, $page + 2); $i++)
  518. <button wire:click="gotoPage({{ $i }})"
  519. class="px-3 py-1.5 text-sm font-medium rounded-lg {{ $i === $page ? 'bg-indigo-600 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }} transition-colors">
  520. {{ $i }}
  521. </button>
  522. @endfor
  523. <button wire:click="nextPage" @disabled($page >= $maxPage)
  524. class="px-3 py-1.5 text-sm font-medium rounded-lg {{ $page >= $maxPage ? 'bg-gray-100 text-gray-400 cursor-not-allowed' : 'bg-gray-100 text-gray-700 hover:bg-gray-200' }} transition-colors">
  525. 下一页
  526. </button>
  527. </div>
  528. </div>
  529. @endif
  530. @endif
  531. </div>
  532. </div>
  533. {{-- 推荐练习题 --}}
  534. @if(!empty($recommendations))
  535. <div class="bg-white shadow-sm rounded-xl border border-gray-200">
  536. <div class="px-6 py-5 border-b border-gray-100">
  537. <h3 class="text-lg font-semibold text-gray-900 flex items-center">
  538. <svg class="w-5 h-5 mr-2 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  539. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  540. </svg>
  541. 推荐练习题 ({{ count($recommendations) }})
  542. </h3>
  543. </div>
  544. <div class="p-6">
  545. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  546. @foreach($recommendations as $rec)
  547. <div class="p-4 border border-gray-200 rounded-lg bg-gray-50">
  548. <p class="text-sm text-gray-900 line-clamp-2">{{ $rec['stem'] ?? '推荐题目' }}</p>
  549. @if(!empty($rec['kp_codes']))
  550. <span class="inline-flex items-center mt-2 px-2 py-0.5 rounded text-xs font-medium bg-indigo-100 text-indigo-800">
  551. {{ is_array($rec['kp_codes']) ? implode(',', $rec['kp_codes']) : $rec['kp_codes'] }}
  552. </span>
  553. @endif
  554. </div>
  555. @endforeach
  556. </div>
  557. </div>
  558. </div>
  559. @endif
  560. {{-- 错误分析 --}}
  561. @if(!empty($patterns['error_types']) || !empty($patterns['top_kps']))
  562. <div class="bg-white shadow-sm rounded-xl border border-gray-200">
  563. <div class="px-6 py-5 border-b border-gray-100">
  564. <h3 class="text-lg font-semibold text-gray-900 flex items-center">
  565. <svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  566. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path>
  567. </svg>
  568. 错误分析
  569. </h3>
  570. </div>
  571. <div class="p-6">
  572. <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
  573. @if(!empty($patterns['error_types']))
  574. <div>
  575. <p class="text-sm font-medium text-gray-900 mb-4">错误类型分布</p>
  576. <div class="space-y-3">
  577. @foreach($patterns['error_types'] as $et)
  578. <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
  579. <span class="text-sm text-gray-700">{{ $et['type'] ?? '未知' }}</span>
  580. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
  581. {{ $et['count'] ?? 0 }}
  582. </span>
  583. </div>
  584. @endforeach
  585. </div>
  586. </div>
  587. @endif
  588. @if(!empty($patterns['top_kps']))
  589. <div>
  590. <p class="text-sm font-medium text-gray-900 mb-4">薄弱知识点</p>
  591. <div class="space-y-3">
  592. @foreach($patterns['top_kps'] as $kp)
  593. <div class="flex items-center justify-between p-3 bg-red-50 rounded-lg">
  594. <span class="text-sm text-gray-700">{{ $kp['name'] ?? $kp['kp_code'] ?? '知识点' }}</span>
  595. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
  596. {{ $kp['mistake_count'] ?? 0 }}
  597. </span>
  598. </div>
  599. @endforeach
  600. </div>
  601. </div>
  602. @endif
  603. </div>
  604. </div>
  605. </div>
  606. @endif
  607. </div>
  608. </div>
  609. @endif
  610. </div>