simulated-grading.blade.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <x-filament-panels::page>
  2. <div class="min-h-screen bg-gray-50 p-8">
  3. {{-- 页面标题区域 --}}
  4. {{-- 页面标题区域 --}}
  5. <div class="mb-8">
  6. <div class="bg-white rounded-xl shadow-sm p-6 border border-gray-200">
  7. <div class="flex items-center justify-between mb-6">
  8. <div>
  9. <h1 class="text-3xl font-bold text-gray-900 flex items-center">
  10. <svg class="w-8 h-8 mr-3 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  11. <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>
  12. </svg>
  13. 专题测试
  14. </h1>
  15. <p class="mt-2 text-sm text-gray-600 ml-11">
  16. 选择知识点和技能,生成题目进行练习,自动记录答题结果并更新学生掌握度
  17. </p>
  18. </div>
  19. </div>
  20. {{-- 选择器区域 --}}
  21. <div class="bg-gray-50 rounded-lg p-4 border border-gray-200">
  22. <div class="flex items-end space-x-6">
  23. <div class="flex-1">
  24. <label for="teacher-select" class="block text-sm font-medium text-gray-700 mb-2">
  25. <svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  26. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
  27. </svg>
  28. 选择老师
  29. </label>
  30. <select
  31. id="teacher-select"
  32. wire:model.live="teacherId"
  33. class="select select-bordered select-primary w-full bg-white"
  34. >
  35. <option value="">请选择老师</option>
  36. @foreach ($teachers as $teacher)
  37. <option value="{{ $teacher->teacher_id }}">
  38. {{ $teacher->name }} ({{ $teacher->subject }})
  39. </option>
  40. @endforeach
  41. </select>
  42. </div>
  43. <div class="flex-1">
  44. <label for="student-select" class="block text-sm font-medium text-gray-700 mb-2">
  45. <svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  46. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"></path>
  47. </svg>
  48. 选择学生
  49. </label>
  50. <select
  51. id="student-select"
  52. wire:model.live="studentId"
  53. class="select select-bordered select-primary w-full bg-white"
  54. @disabled(empty($teacherId))
  55. >
  56. <option value="">请选择学生</option>
  57. @foreach ($students as $student)
  58. <option value="{{ $student->student_id }}">
  59. {{ $student->name }} - {{ $student->grade }}{{ $student->class_name }}
  60. </option>
  61. @endforeach
  62. </select>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. {{-- 加载状态 --}}
  69. @if ($isLoading)
  70. <div class="mb-8">
  71. <div class="bg-white rounded-xl shadow-sm p-12 border border-gray-200">
  72. <div class="flex flex-col items-center justify-center">
  73. <svg class="animate-spin h-12 w-12 text-indigo-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  74. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  75. <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>
  76. </svg>
  77. <p class="mt-4 text-sm text-gray-600">正在生成题目,请稍候...</p>
  78. </div>
  79. </div>
  80. </div>
  81. @else
  82. {{-- 练习题目模块 --}}
  83. <div class="mb-8">
  84. <div class="bg-white shadow-sm rounded-xl border border-gray-200">
  85. <div class="px-6 py-5 border-b border-gray-100">
  86. <div class="flex items-center justify-between mb-4">
  87. <h3 class="text-lg font-semibold text-gray-900 flex items-center">
  88. <svg class="w-5 h-5 mr-2 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  89. <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>
  90. </svg>
  91. 专题测试练习
  92. </h3>
  93. </div>
  94. <div class="p-6">
  95. <div class="space-y-6">
  96. {{-- 知识点和技能选择区域 --}}
  97. <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
  98. {{-- 知识点选择 --}}
  99. <div class="border border-gray-200 rounded-lg p-4">
  100. <h4 class="text-sm font-medium text-gray-900 mb-3 flex items-center">
  101. <svg class="w-4 h-4 mr-2 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  102. <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>
  103. </svg>
  104. 选择知识点
  105. </h4>
  106. <select
  107. wire:model.live="selectedKnowledgePoint"
  108. class="select select-bordered select-primary w-full bg-white"
  109. >
  110. <option value="">随机知识点</option>
  111. @foreach ($availableKnowledgePoints as $kp)
  112. <option value="{{ $kp['id'] ?? $kp['code'] ?? $kp }}">{{ $kp['name'] ?? $kp['code'] ?? $kp }}</option>
  113. @endforeach
  114. </select>
  115. </div>
  116. {{-- 技能选择 --}}
  117. <div class="border border-gray-200 rounded-lg p-4">
  118. <h4 class="text-sm font-medium text-gray-900 mb-3 flex items-center">
  119. <svg class="w-4 h-4 mr-2 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  120. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path>
  121. </svg>
  122. 选择技能(可多选)
  123. </h4>
  124. <div class="space-y-2 max-h-32 overflow-y-auto">
  125. @foreach ($availableSkills as $skill)
  126. <label class="flex items-center">
  127. <input
  128. type="checkbox"
  129. wire:model.live="selectedSkills"
  130. value="{{ $skill['id'] ?? $skill['code'] ?? $skill }}"
  131. class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
  132. />
  133. <span class="ml-2 text-sm text-gray-700">{{ $skill['name'] ?? $skill['code'] ?? $skill }}</span>
  134. </label>
  135. @endforeach
  136. </div>
  137. </div>
  138. </div>
  139. {{-- 题目数量和生成按钮 --}}
  140. <div class="flex items-center space-x-4 p-4 bg-gray-50 rounded-lg">
  141. <div class="flex items-center space-x-2">
  142. <label class="text-sm font-medium text-gray-700">题目数量:</label>
  143. <input
  144. type="number"
  145. wire:model.live="questionsPerSet"
  146. min="1"
  147. max="10"
  148. class="w-16 rounded-lg border-gray-300 text-sm text-center bg-gray-50"
  149. />
  150. </div>
  151. <button
  152. wire:click="generateBatchQuestions"
  153. wire:loading.attr="disabled"
  154. class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-lg shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500"
  155. >
  156. <svg wire:loading class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  157. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  158. <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>
  159. </svg>
  160. 生成题目组
  161. </button>
  162. <div class="text-sm text-gray-500">
  163. 当前批次ID: {{ $currentBatchId ?: '未生成' }}
  164. </div>
  165. </div>
  166. {{-- 题目列表 --}}
  167. @if (!empty($exerciseQuestions))
  168. <div class="border border-gray-200 rounded-lg p-4">
  169. <h4 class="text-sm font-medium text-gray-900 mb-4">题目列表 (请标记对错)</h4>
  170. <div class="space-y-4 max-h-96 overflow-y-auto">
  171. @foreach ($exerciseQuestions as $index => $question)
  172. <div class="border border-gray-200 rounded-lg p-4">
  173. <div class="flex items-start justify-between mb-3">
  174. <div class="flex-1">
  175. <div class="flex items-center mb-2">
  176. <span class="inline-flex items-center justify-center w-6 h-6 rounded-full bg-indigo-100 text-indigo-800 text-xs font-medium mr-2">
  177. {{ $index + 1 }}
  178. </span>
  179. <span class="text-sm text-gray-500">{{ $question['type'] ?? '数学题' }}</span>
  180. <span class="mx-2 text-gray-300">|</span>
  181. <span class="text-sm text-gray-500">难度: {{ $question['difficulty'] ?? 3 }}/5</span>
  182. </div>
  183. <h5 class="text-base font-medium text-gray-900">
  184. @math($question['content'] ?? '')
  185. </h5>
  186. </div>
  187. </div>
  188. <div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
  189. <div>
  190. <label class="block text-sm font-medium text-gray-700 mb-1">学生答案(可选)</label>
  191. <input
  192. type="text"
  193. wire:model.live="exerciseAnswers.{{ $index }}.user_answer"
  194. placeholder="输入答案..."
  195. class="block w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 text-sm bg-gray-50"
  196. />
  197. </div>
  198. <div>
  199. <label class="block text-sm font-medium text-gray-700 mb-1">答题结果</label>
  200. <div class="flex space-x-4">
  201. <label class="flex items-center">
  202. <input
  203. type="radio"
  204. wire:model.live="exerciseAnswers.{{ $index }}.is_correct"
  205. value="1"
  206. class="h-4 w-4 text-green-600 focus:ring-green-500 border-gray-300"
  207. />
  208. <span class="ml-2 text-sm text-green-700">正确</span>
  209. </label>
  210. <label class="flex items-center">
  211. <input
  212. type="radio"
  213. wire:model.live="exerciseAnswers.{{ $index }}.is_correct"
  214. value="0"
  215. class="h-4 w-4 text-red-600 focus:ring-red-500 border-gray-300"
  216. />
  217. <span class="ml-2 text-sm text-red-700">错误</span>
  218. </label>
  219. </div>
  220. </div>
  221. </div>
  222. <div class="mt-3 p-2 bg-green-50 border border-green-200 rounded">
  223. <span class="text-xs text-green-800">正确答案: </span>
  224. <span class="text-xs">
  225. @math($question['answer'] ?? 'N/A')
  226. </span>
  227. </div>
  228. </div>
  229. @endforeach
  230. </div>
  231. {{-- 批量提交按钮 --}}
  232. <div class="mt-6 pt-4 border-t border-gray-200">
  233. <button
  234. wire:click="submitBatchAnswers"
  235. wire:loading.attr="disabled"
  236. class="w-full inline-flex items-center justify-center px-6 py-3 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"
  237. >
  238. <svg wire:loading class="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  239. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  240. <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>
  241. </svg>
  242. <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  243. <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>
  244. </svg>
  245. 批量提交答案 ({{ count($exerciseQuestions) }} 题)
  246. </button>
  247. </div>
  248. </div>
  249. @else
  250. {{-- 批量模式空状态 --}}
  251. <div class="text-center py-12">
  252. <svg class="mx-auto h-16 w-16 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  253. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
  254. </svg>
  255. <h3 class="mt-4 text-lg font-medium text-gray-900">批量练习模式</h3>
  256. <p class="mt-2 text-sm text-gray-500 max-w-md mx-auto">
  257. 选择知识点和技能,设置题目数量,点击"生成题目组"开始批量答题练习
  258. </p>
  259. </div>
  260. @endif
  261. </div>
  262. </div>
  263. </div>
  264. </div>
  265. </div>
  266. {{-- 答题历史模块 --}}
  267. @if (!empty($studentId))
  268. <div class="mb-8">
  269. <div class="bg-white shadow-sm rounded-xl border border-gray-200">
  270. <div class="px-6 py-5 border-b border-gray-100">
  271. <h3 class="text-lg font-semibold text-gray-900 flex items-center">
  272. <svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  273. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  274. </svg>
  275. 答题历史
  276. </h3>
  277. </div>
  278. <div class="p-6">
  279. {{-- 每页显示数量选择 --}}
  280. <div class="flex items-center justify-between mb-6">
  281. <div class="flex items-center space-x-2">
  282. <label class="text-sm font-medium text-gray-700">每页显示:</label>
  283. <select
  284. wire:model.live="historyPerPage"
  285. class="select select-bordered select-sm select-primary bg-white"
  286. >
  287. <option value="5">5 条</option>
  288. <option value="10">10 条</option>
  289. <option value="20">20 条</option>
  290. <option value="50">50 条</option>
  291. </select>
  292. </div>
  293. <div class="text-sm text-gray-500">
  294. 共 {{ $historyTotal }} 条记录
  295. </div>
  296. </div>
  297. {{-- 历史记录列表 --}}
  298. @if (!empty($exerciseHistory))
  299. <div class="space-y-4">
  300. @foreach ($exerciseHistory as $history)
  301. <div class="border border-gray-200 rounded-lg p-4 hover:bg-gray-50 transition-colors">
  302. <div class="flex items-start justify-between mb-3">
  303. <div class="flex-1">
  304. <div class="flex items-center mb-2">
  305. <span class="inline-flex items-center justify-center w-6 h-6 rounded-full bg-purple-100 text-purple-800 text-xs font-medium mr-2">
  306. {{ $loop->iteration + ($historyCurrentPage - 1) * $historyPerPage }}
  307. </span>
  308. <span class="text-sm text-gray-500">批次: {{ $history['batch_id'] ?? 'N/A' }}</span>
  309. <span class="mx-2 text-gray-300">|</span>
  310. <span class="text-sm text-gray-500">
  311. {{ $history['kp_code'] ?? 'N/A' }}
  312. </span>
  313. </div>
  314. <h5 class="text-base font-medium text-gray-900 mb-2">
  315. @math(Str::limit($history['question_content'] ?? 'N/A', 100))
  316. </h5>
  317. <div class="grid grid-cols-1 lg:grid-cols-2 gap-4 mt-3">
  318. <div>
  319. <span class="text-xs text-gray-500">学生答案:</span>
  320. <div class="text-sm text-gray-900">
  321. {!! $history['student_answer'] ?? '未填写' !!}
  322. </div>
  323. </div>
  324. <div>
  325. <span class="text-xs text-gray-500">正确答案:</span>
  326. <div class="text-sm text-gray-900">
  327. {!! $history['correct_answer'] ?? 'N/A' !!}
  328. </div>
  329. </div>
  330. </div>
  331. </div>
  332. <div class="ml-4 text-right">
  333. @if ($history['is_correct'])
  334. <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800">
  335. <svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  336. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
  337. </svg>
  338. 正确
  339. </span>
  340. @else
  341. <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800">
  342. <svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  343. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
  344. </svg>
  345. 错误
  346. </span>
  347. @endif
  348. <div class="mt-2 text-xs text-gray-500">
  349. {{ date('Y-m-d H:i', strtotime($history['created_at'])) }}
  350. </div>
  351. </div>
  352. </div>
  353. </div>
  354. @endforeach
  355. </div>
  356. {{-- 分页导航 --}}
  357. @if ($historyTotalPages > 1)
  358. <div class="mt-6 pt-4 border-t border-gray-200 flex items-center justify-between">
  359. <div class="text-sm text-gray-700">
  360. 显示第 {{ ($historyCurrentPage - 1) * $historyPerPage + 1 }} -
  361. {{ min($historyCurrentPage * $historyPerPage, $historyTotal) }} 条,
  362. 共 {{ $historyTotal }} 条记录
  363. </div>
  364. <div class="flex items-center gap-2">
  365. <button
  366. wire:click="previousHistoryPage"
  367. @disabled($historyCurrentPage <= 1)
  368. class="px-3 py-1 border rounded-lg text-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
  369. >
  370. 上一页
  371. </button>
  372. @foreach ($this->getHistoryPages() as $page)
  373. <button
  374. wire:click="gotoHistoryPage({{ $page }})"
  375. class="px-3 py-1 border rounded-lg text-sm {{ $page === $historyCurrentPage ? 'bg-indigo-600 text-white' : 'hover:bg-gray-50' }}"
  376. >
  377. {{ $page }}
  378. </button>
  379. @endforeach
  380. <button
  381. wire:click="nextHistoryPage"
  382. @disabled($historyCurrentPage >= $historyTotalPages)
  383. class="px-3 py-1 border rounded-lg text-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"
  384. >
  385. 下一页
  386. </button>
  387. </div>
  388. </div>
  389. @endif
  390. @else
  391. <div class="text-center py-12">
  392. <svg class="mx-auto h-16 w-16 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  393. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  394. </svg>
  395. <h3 class="mt-4 text-lg font-medium text-gray-900">暂无答题历史</h3>
  396. <p class="mt-2 text-sm text-gray-500 max-w-md mx-auto">
  397. 选择学生后,答题历史将显示在这里
  398. </p>
  399. </div>
  400. @endif
  401. </div>
  402. </div>
  403. </div>
  404. @endif
  405. @endif
  406. </div>
  407. <x-math-render />
  408. </x-filament-panels::page>