intelligent-exam-generation-simple.blade.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <x-filament-panels::page>
  2. @push('styles')
  3. <style>
  4. .exam-card {
  5. transition: all 0.3s ease;
  6. border: 1px solid rgba(0, 0, 0, 0.05);
  7. }
  8. .exam-card:hover {
  9. transform: translateY(-2px);
  10. box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  11. border-color: rgba(59, 130, 246, 0.2);
  12. }
  13. .generate-button {
  14. transition: all 0.3s ease;
  15. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  16. box-shadow: 0 4px 15px 0 rgba(102, 126, 234, 0.4);
  17. font-weight: 600;
  18. font-size: 16px;
  19. padding: 14px 28px;
  20. }
  21. .generate-button:hover:not(:disabled) {
  22. transform: translateY(-2px);
  23. box-shadow: 0 6px 20px 0 rgba(102, 126, 234, 0.6);
  24. background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
  25. }
  26. .generate-button:active:not(:disabled) {
  27. transform: translateY(0);
  28. }
  29. .generate-button:disabled {
  30. background: #cbd5e1;
  31. box-shadow: none;
  32. cursor: not-allowed;
  33. }
  34. .step-indicator {
  35. position: relative;
  36. padding-left: 30px;
  37. }
  38. .step-indicator::before {
  39. content: '';
  40. position: absolute;
  41. left: 10px;
  42. top: 0;
  43. bottom: 0;
  44. width: 2px;
  45. background: #e5e7eb;
  46. }
  47. .step-item {
  48. position: relative;
  49. margin-bottom: 20px;
  50. }
  51. .step-item::before {
  52. content: attr(data-step);
  53. position: absolute;
  54. left: -30px;
  55. top: 0;
  56. width: 20px;
  57. height: 20px;
  58. background: #fff;
  59. border: 2px solid #d1d5db;
  60. border-radius: 50%;
  61. display: flex;
  62. align-items: center;
  63. justify-content: center;
  64. font-size: 11px;
  65. font-weight: 600;
  66. color: #9ca3af;
  67. }
  68. .step-item.completed::before {
  69. background: #10b981;
  70. border-color: #10b981;
  71. color: #fff;
  72. }
  73. .step-item.active::before {
  74. background: #3b82f6;
  75. border-color: #3b82f6;
  76. color: #fff;
  77. }
  78. .selection-card {
  79. transition: all 0.2s ease;
  80. }
  81. .selection-card:hover {
  82. background-color: #f9fafb;
  83. border-color: #3b82f6;
  84. }
  85. .selection-card.selected {
  86. background-color: #eff6ff;
  87. border-color: #3b82f6;
  88. box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  89. }
  90. .form-select, .form-input {
  91. background-color: white;
  92. border: 2px solid #e5e7eb;
  93. transition: all 0.2s ease;
  94. }
  95. .form-select:focus, .form-input:focus {
  96. border-color: #3b82f6;
  97. box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  98. outline: none;
  99. }
  100. </style>
  101. @endpush
  102. @push('scripts')
  103. <script>
  104. // 监听window事件,确保组件间通信正常
  105. document.addEventListener('DOMContentLoaded', function() {
  106. // 监听学生选择变化
  107. Livewire.on('window-student-changed', (data) => {
  108. console.log('Window学生变更事件:', data);
  109. });
  110. // 监听教师选择变化
  111. Livewire.on('window-teacher-changed', (data) => {
  112. console.log('Window教师变更事件:', data);
  113. });
  114. });
  115. </script>
  116. @endpush
  117. <div class="space-y-6">
  118. <!-- 页面标题 -->
  119. <div class="flex justify-between items-center">
  120. <div>
  121. <h2 class="text-2xl font-bold text-gray-900">智能出卷系统</h2>
  122. <p class="mt-1 text-sm text-gray-500">
  123. 基于知识点掌握度,智能生成个性化试卷
  124. </p>
  125. </div>
  126. <div class="flex gap-3">
  127. <button
  128. wire:click="resetForm"
  129. type="button"
  130. class="filament-button filament-button-size-sm filament-button-color-gray filament-button-icon-start inline-flex items-center justify-center px-4 py-2 text-sm font-medium transition-colors border border-transparent rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
  131. >
  132. 重置
  133. </button>
  134. </div>
  135. </div>
  136. <!-- 基本信息卡片 -->
  137. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  138. <div class="flex items-center gap-3 mb-6">
  139. <div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
  140. <svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  141. <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" />
  142. </svg>
  143. </div>
  144. <div>
  145. <h3 class="text-xl font-semibold text-gray-900">步骤 1:基本信息设置</h3>
  146. <p class="text-sm text-gray-500">设置试卷的基本参数</p>
  147. </div>
  148. </div>
  149. <div class="space-y-4">
  150. <div class="grid grid-cols-3 gap-4">
  151. <div class="selection-card border rounded-lg p-4">
  152. <label class="block text-sm font-medium text-gray-700 mb-2">难度分类</label>
  153. <select wire:model="difficultyCategory" class="form-select w-full px-3 py-2 rounded-lg text-sm">
  154. <option value="基础">基础</option>
  155. <option value="进阶">进阶</option>
  156. <option value="竞赛">竞赛</option>
  157. </select>
  158. </div>
  159. <div class="selection-card border rounded-lg p-4">
  160. <label class="block text-sm font-medium text-gray-700 mb-2">题目数量 <span class="text-red-500">*</span></label>
  161. <input
  162. type="number"
  163. wire:model="totalQuestions"
  164. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  165. min="6"
  166. max="100"
  167. required
  168. />
  169. </div>
  170. <div class="selection-card border rounded-lg p-4">
  171. <label class="block text-sm font-medium text-gray-700 mb-2">总分</label>
  172. <input
  173. type="number"
  174. wire:model="totalScore"
  175. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  176. min="0"
  177. max="200"
  178. />
  179. </div>
  180. </div>
  181. <div class="selection-card border rounded-lg p-4">
  182. <label class="block text-sm font-medium text-gray-700 mb-2">试卷名称 <span class="text-gray-400 font-normal">(选填,未填则自动生成)</span></label>
  183. <input
  184. type="text"
  185. wire:model="paperName"
  186. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  187. placeholder="例如:因式分解专项练习(基础版)"
  188. />
  189. </div>
  190. </div>
  191. </div>
  192. <!-- 教师和学生选择 -->
  193. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  194. <div class="flex items-center gap-3 mb-6">
  195. <div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
  196. <svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  197. <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" />
  198. </svg>
  199. </div>
  200. <div>
  201. <h3 class="text-xl font-semibold text-gray-900">步骤 2:选择教师与学生</h3>
  202. <p class="text-sm text-gray-500">启用个性化出卷功能</p>
  203. </div>
  204. </div>
  205. <div class="space-y-6">
  206. <!-- 直接在父组件中显示教师和学生选择,避免组件间通信问题 -->
  207. @if(!$this->isTeacher)
  208. <div class="grid grid-cols-2 gap-4">
  209. <div class="selection-card border rounded-lg p-4">
  210. <label class="block text-sm font-medium text-gray-700 mb-2">选择教师</label>
  211. <select
  212. wire:model.live="selectedTeacherId"
  213. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  214. >
  215. <option value="">-- 请选择教师 --</option>
  216. @foreach($this->teachers as $teacher)
  217. <option value="{{ $teacher->teacher_id }}">
  218. {{ trim($teacher->name ?? $teacher->teacher_id) . ($teacher->subject ? " ({$teacher->subject})" : '') }}
  219. </option>
  220. @endforeach
  221. </select>
  222. </div>
  223. <div class="selection-card border rounded-lg p-4">
  224. <label class="block text-sm font-medium text-gray-700 mb-2">选择学生</label>
  225. <select
  226. wire:model.live="selectedStudentId"
  227. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  228. @if(empty($selectedTeacherId)) disabled @endif
  229. >
  230. <option value="">
  231. @if(empty($selectedTeacherId))
  232. 请先选择教师
  233. @else
  234. -- 请选择学生 --
  235. @endif
  236. </option>
  237. @foreach($this->students as $student)
  238. <option value="{{ $student->student_id }}" @if(request('student_id') == $student->student_id) selected @endif>
  239. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  240. </option>
  241. @endforeach
  242. </select>
  243. </div>
  244. </div>
  245. @else
  246. <div class="grid grid-cols-1 gap-4">
  247. <div class="selection-card border rounded-lg p-4">
  248. <label class="block text-sm font-medium text-gray-700 mb-2">选择学生</label>
  249. <select
  250. wire:model.live="selectedStudentId"
  251. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  252. >
  253. <option value="">-- 请选择学生 --</option>
  254. @foreach($this->students as $student)
  255. <option value="{{ $student->student_id }}" @if(request('student_id') == $student->student_id) selected @endif>
  256. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  257. </option>
  258. @endforeach
  259. </select>
  260. </div>
  261. </div>
  262. @endif
  263. <!-- 显示当前选择状态 -->
  264. <div class="mt-4 p-4 bg-gray-50 rounded-lg">
  265. <div class="grid grid-cols-2 gap-4">
  266. <div>
  267. <div class="text-xs font-medium text-gray-500 mb-1">当前选择的教师</div>
  268. <div class="text-sm bg-white px-3 py-2 rounded border">
  269. {{ $this->getSelectedTeacherName() }}
  270. </div>
  271. </div>
  272. <div>
  273. <div class="text-xs font-medium text-gray-500 mb-1">当前选择的学生</div>
  274. <div class="text-sm bg-white px-3 py-2 rounded border">
  275. {{ $this->getSelectedStudentName() }}
  276. </div>
  277. </div>
  278. </div>
  279. </div>
  280. @if($selectedTeacherId && $selectedStudentId)
  281. <div class="p-4 bg-blue-50 rounded-lg">
  282. <div class="flex items-start gap-3">
  283. <svg class="w-5 h-5 text-blue-600 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  284. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  285. </svg>
  286. <div>
  287. <div class="font-medium text-blue-900">针对性出卷已启用</div>
  288. <div class="text-sm text-blue-700 mt-1">
  289. 将根据所选学生的薄弱知识点进行智能推荐,建议自动勾选相关知识点
  290. </div>
  291. <label class="flex items-center gap-2 mt-3">
  292. <input
  293. type="checkbox"
  294. wire:model.live="filterByStudentWeakness"
  295. class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  296. />
  297. <span class="text-sm text-blue-700">根据学生薄弱点自动选择知识点</span>
  298. </label>
  299. </div>
  300. </div>
  301. </div>
  302. @endif
  303. </div>
  304. </div>
  305. <!-- 学生薄弱知识点展示区域 -->
  306. @if($selectedStudentId && $filterByStudentWeakness && count($this->studentWeaknesses) > 0)
  307. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  308. <div class="flex items-center gap-3 mb-6">
  309. <div class="w-12 h-12 bg-orange-100 rounded-xl flex items-center justify-center">
  310. <svg class="w-6 h-6 text-orange-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  311. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
  312. </svg>
  313. </div>
  314. <div>
  315. <h3 class="text-xl font-semibold text-gray-900">学生薄弱知识点分析</h3>
  316. <p class="text-sm text-gray-500">基于答题数据的智能分析(共{{ count($this->studentWeaknesses) }}个)</p>
  317. </div>
  318. </div>
  319. <div class="bg-gradient-to-r from-orange-50 to-amber-50 border border-orange-200 rounded-xl p-5 mb-6">
  320. <div class="flex items-start gap-3">
  321. <svg class="h-6 w-6 text-orange-500 flex-shrink-0 mt-0.5" viewBox="0 0 20 20" fill="currentColor">
  322. <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path>
  323. </svg>
  324. <div>
  325. <p class="text-sm text-orange-800 font-medium mb-1">
  326. 智能分析结果(可选)
  327. </p>
  328. <p class="text-sm text-orange-700">
  329. 以下是根据该学生的答题数据自动分析出的薄弱知识点(共{{ count($this->studentWeaknesses) }}个)。
  330. <strong>您可以选择这些薄弱点</strong>,或者在下方<strong>步骤3</strong>中手动选择任何知识点。
  331. 两个区域的知识点会合并生效。
  332. </p>
  333. </div>
  334. </div>
  335. </div>
  336. <div class="grid grid-cols-1 gap-3">
  337. @foreach($this->studentWeaknesses as $weakness)
  338. @php
  339. $isSelected = in_array($weakness['kp_code'], $selectedKpCodes);
  340. $masteryPercent = round(($weakness['mastery'] ?? 0) * 100, 1);
  341. $weaknessLevel = $weakness['weakness_level'] ?? (1 - ($weakness['mastery'] ?? 0));
  342. $priority = $weakness['priority'] ?? '中';
  343. $priorityColor = $priority === '高' ? 'bg-red-100 text-red-800 border-red-200' : ($priority === '中' ? 'bg-yellow-100 text-yellow-800 border-yellow-200' : 'bg-green-100 text-green-800 border-green-200');
  344. @endphp
  345. <div class="selection-card border rounded-xl p-5 {{ $isSelected ? 'selected' : '' }}">
  346. <div class="flex items-start justify-between">
  347. <div class="flex items-start gap-4 flex-1">
  348. <div class="mt-1">
  349. @if($isSelected)
  350. <svg class="w-6 h-6 text-blue-600" fill="currentColor" viewBox="0 0 20 20">
  351. <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path>
  352. </svg>
  353. @else
  354. <input
  355. type="checkbox"
  356. wire:model.live="selectedKpCodes"
  357. value="{{ $weakness['kp_code'] }}"
  358. class="w-5 h-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  359. wire:key="weakness-{{ $weakness['kp_code'] }}"
  360. />
  361. @endif
  362. </div>
  363. <div class="flex-1">
  364. <div class="font-semibold text-gray-900 text-base">
  365. {{ $weakness['kp_name'] ?? $weakness['kp_code'] }}
  366. <span class="ml-2 text-sm text-gray-500">({{ $weakness['kp_code'] }})</span>
  367. </div>
  368. <div class="mt-3 flex items-center gap-6 text-sm">
  369. <div class="flex items-center gap-2">
  370. <span class="text-gray-600">掌握度</span>
  371. <span class="font-bold text-lg {{ $masteryPercent < 50 ? 'text-red-600' : ($masteryPercent < 70 ? 'text-yellow-600' : 'text-green-600') }}">
  372. {{ $masteryPercent }}%
  373. </span>
  374. </div>
  375. <div class="flex items-center gap-2">
  376. <span class="text-gray-600">练习次数</span>
  377. <span class="font-semibold text-gray-900">{{ $weakness['practice_count'] ?? 0 }}</span>
  378. </div>
  379. <div class="flex items-center gap-2">
  380. <span class="text-gray-600">成功率</span>
  381. <span class="font-semibold text-gray-900">{{ round(($weakness['success_rate'] ?? 0) * 100, 1) }}%</span>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. <span class="px-3 py-1.5 text-sm font-semibold rounded-full {{ $priorityColor }}">
  387. {{ $priority }}优先级
  388. </span>
  389. </div>
  390. </div>
  391. @endforeach
  392. </div>
  393. <div class="mt-6 flex items-center justify-between bg-gray-50 rounded-xl p-4">
  394. <div class="flex items-center gap-3">
  395. <button
  396. wire:click="selectAllWeaknesses"
  397. type="button"
  398. class="px-5 py-2.5 bg-gradient-to-r from-orange-500 to-amber-500 text-white text-sm font-semibold rounded-lg hover:from-orange-600 hover:to-amber-600 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2 transition-all shadow-md"
  399. >
  400. 全选薄弱知识点 ({{ count($this->studentWeaknesses) }})
  401. </button>
  402. <button
  403. wire:click="clearSelection"
  404. type="button"
  405. class="px-5 py-2.5 bg-white border-2 border-gray-300 text-gray-700 text-sm font-semibold rounded-lg hover:bg-gray-50 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 transition-all"
  406. >
  407. 清空选择
  408. </button>
  409. </div>
  410. <div class="flex items-center gap-2 text-sm text-gray-600" x-data x-effect="$el.querySelector('.count').textContent = $wire.selectedKpCodes.length">
  411. <span>已选择</span>
  412. <span class="font-bold text-lg text-blue-600 count">{{ count($selectedKpCodes) }}</span>
  413. <span>个知识点</span>
  414. </div>
  415. </div>
  416. </div>
  417. @endif
  418. <!-- 知识点选择 -->
  419. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  420. <div class="flex items-center gap-3 mb-6">
  421. <div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
  422. <svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  423. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z" />
  424. </svg>
  425. </div>
  426. <div>
  427. <h3 class="text-xl font-semibold text-gray-900">步骤 3:选择知识点</h3>
  428. <p class="text-sm text-gray-500" x-data x-effect="$el.textContent = `勾选要考查的知识点(已选择: ${$wire.selectedKpCodes.length} 个)`">
  429. 勾选要考查的知识点(已选择: {{ count($selectedKpCodes) }} 个)
  430. </p>
  431. @if($selectedStudentId && $filterByStudentWeakness && count($this->studentWeaknesses) > 0)
  432. <p class="text-xs text-blue-600 mt-1">
  433. 💡 提示:您也可以在上方选择学生的薄弱知识点,两个区域的知识点会合并生效
  434. </p>
  435. @endif
  436. </div>
  437. </div>
  438. <div class="grid grid-cols-1 md:grid-cols-3 gap-3 max-h-36 overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100">
  439. @foreach($this->knowledgePoints as $kp)
  440. @php
  441. $isSelected = in_array($kp['kp_code'], $selectedKpCodes);
  442. @endphp
  443. <label class="selection-card flex items-start gap-3 p-3 border rounded-lg cursor-pointer hover:bg-blue-50 hover:border-blue-400 transition-all shadow-sm hover:shadow-md {{ $isSelected ? 'border-blue-500 bg-blue-50' : '' }}">
  444. <input
  445. type="checkbox"
  446. wire:model.live="selectedKpCodes"
  447. value="{{ $kp['kp_code'] }}"
  448. class="mt-0.5 w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  449. wire:key="kp-{{ $kp['kp_code'] }}"
  450. />
  451. <div class="flex-1 min-w-0">
  452. <div class="font-semibold text-gray-900 text-sm leading-tight">{{ Str::limit($kp['cn_name'] ?? $kp['kp_code'], 16) }}</div>
  453. <div class="flex items-center gap-1 mt-1.5">
  454. <span class="text-xs px-2 py-0.5 bg-blue-100 text-blue-700 rounded-full font-medium">
  455. {{ $kp['kp_code'] }}
  456. </span>
  457. </div>
  458. @if(!empty($kp['description']))
  459. <div class="text-xs text-gray-500 mt-1 line-clamp-2">{{ Str::limit($kp['description'], 30) }}</div>
  460. @endif
  461. @if($isSelected)
  462. <div class="text-xs text-blue-600 mt-1 font-medium">✓ 已选择</div>
  463. @endif
  464. </div>
  465. </label>
  466. @endforeach
  467. </div>
  468. </div>
  469. <!-- 生成按钮 -->
  470. @php
  471. $hasTeacherStudent = !empty($selectedTeacherId) && !empty($selectedStudentId);
  472. $hasKnowledgePoints = count($selectedKpCodes) > 0;
  473. $questionCountValid = $totalQuestions >= 6;
  474. $readyToGenerate = $this->canGenerate();
  475. $missingSteps = [];
  476. if (empty($selectedTeacherId)) { $missingSteps[] = '选择教师'; }
  477. if (empty($selectedStudentId)) { $missingSteps[] = '选择学生'; }
  478. if (!$hasKnowledgePoints) { $missingSteps[] = '勾选至少 1 个知识点'; }
  479. if (!$questionCountValid) { $missingSteps[] = '题目数量需 ≥ 6 题'; }
  480. // 强制访问 selectedKpCodes 来触发 Livewire 刷新
  481. $selectedKpCodesForDebug = $selectedKpCodes;
  482. // 调试信息
  483. $debugInfo = "教师: " . ($selectedTeacherId ? "✓" : "✗") .
  484. " | 学生: " . ($selectedStudentId ? "✓" : "✗") .
  485. " | 知识点: " . ($hasKnowledgePoints ? "✓ (" . count($selectedKpCodesForDebug) . "个)" : "✗ (实际:" . count($selectedKpCodesForDebug) . "个)") .
  486. " | 题目数: " . ($questionCountValid ? "✓ ({$totalQuestions})" : "✗ ({$totalQuestions})");
  487. // 显示实际的知识点代码
  488. $kpCodesList = implode(', ', array_slice($selectedKpCodesForDebug, 0, 10));
  489. if (count($selectedKpCodesForDebug) > 10) {
  490. $kpCodesList .= '...';
  491. }
  492. @endphp
  493. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card space-y-6">
  494. <div class="flex items-center justify-between">
  495. <div class="flex items-center gap-3">
  496. <div class="w-12 h-12 bg-gradient-to-br from-blue-500 to-purple-600 rounded-xl flex items-center justify-center">
  497. <svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  498. <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" />
  499. </svg>
  500. </div>
  501. <div>
  502. <h3 class="text-xl font-semibold text-gray-900">步骤 4:出卷前检查与生成</h3>
  503. <p class="text-sm text-gray-500">验证配置并生成试卷</p>
  504. </div>
  505. </div>
  506. <span class="inline-flex items-center gap-2 px-4 py-2 text-sm font-semibold rounded-full {{ $readyToGenerate ? 'bg-green-100 text-green-800 border-2 border-green-300' : 'bg-amber-100 text-amber-800 border-2 border-amber-300' }}">
  507. <span class="h-2.5 w-2.5 rounded-full {{ $readyToGenerate ? 'bg-green-500 animate-pulse' : 'bg-amber-500' }}"></span>
  508. {{ $readyToGenerate ? '✓ 可以生成试卷' : '⚠ 待完善配置' }}
  509. </span>
  510. </div>
  511. <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
  512. <div class="selection-card border-2 rounded-xl p-5 {{ $hasTeacherStudent ? 'border-green-400 bg-gradient-to-br from-green-50 to-emerald-50' : 'border-amber-300 bg-gradient-to-br from-amber-50 to-orange-50' }}">
  513. <div class="flex items-center gap-3 mb-2">
  514. <div class="w-10 h-10 rounded-lg {{ $hasTeacherStudent ? 'bg-green-100' : 'bg-amber-100' }} flex items-center justify-center">
  515. @if($hasTeacherStudent)
  516. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  517. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  518. </svg>
  519. @else
  520. <svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  521. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
  522. </svg>
  523. @endif
  524. </div>
  525. <span class="text-sm font-bold {{ $hasTeacherStudent ? 'text-green-800' : 'text-amber-800' }}">教师 / 学生</span>
  526. </div>
  527. <p class="text-sm {{ $hasTeacherStudent ? 'text-green-700' : 'text-amber-700' }}">
  528. {{ $hasTeacherStudent ? '✓ ' . $this->getSelectedTeacherName() . ' / ' . $this->getSelectedStudentName() : '请选择教师和学生' }}
  529. </p>
  530. </div>
  531. <div class="selection-card border-2 rounded-xl p-5 {{ $hasKnowledgePoints ? 'border-green-400 bg-gradient-to-br from-green-50 to-emerald-50' : 'border-amber-300 bg-gradient-to-br from-amber-50 to-orange-50' }}">
  532. <div class="flex items-center gap-3 mb-2">
  533. <div class="w-10 h-10 rounded-lg {{ $hasKnowledgePoints ? 'bg-green-100' : 'bg-amber-100' }} flex items-center justify-center">
  534. @if($hasKnowledgePoints)
  535. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  536. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  537. </svg>
  538. @else
  539. <svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  540. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
  541. </svg>
  542. @endif
  543. </div>
  544. <span class="text-sm font-bold {{ $hasKnowledgePoints ? 'text-green-800' : 'text-amber-800' }}">知识点选择</span>
  545. </div>
  546. <p class="text-sm {{ $hasKnowledgePoints ? 'text-green-700' : 'text-amber-700' }}" x-data x-effect="$el.textContent = $wire.selectedKpCodes.length > 0 ? `✓ 已选 ${$wire.selectedKpCodes.length} 个知识点` : '请选择至少1个知识点'">
  547. {{ $hasKnowledgePoints ? '✓ 已选 ' . count($selectedKpCodes) . ' 个知识点' : '请选择至少1个知识点' }}
  548. </p>
  549. </div>
  550. <div class="selection-card border-2 rounded-xl p-5 {{ $questionCountValid ? 'border-green-400 bg-gradient-to-br from-green-50 to-emerald-50' : 'border-amber-300 bg-gradient-to-br from-amber-50 to-orange-50' }}">
  551. <div class="flex items-center gap-3 mb-2">
  552. <div class="w-10 h-10 rounded-lg {{ $questionCountValid ? 'bg-green-100' : 'bg-amber-100' }} flex items-center justify-center">
  553. @if($questionCountValid)
  554. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  555. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  556. </svg>
  557. @else
  558. <svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  559. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
  560. </svg>
  561. @endif
  562. </div>
  563. <span class="text-sm font-bold {{ $questionCountValid ? 'text-green-800' : 'text-amber-800' }}">题目数量</span>
  564. </div>
  565. <p class="text-sm {{ $questionCountValid ? 'text-green-700' : 'text-amber-700' }}" x-data x-effect="$el.textContent = $wire.totalQuestions >= 6 ? `✓ 将生成 ${$wire.totalQuestions} 题` : '至少需要6题'">
  566. {{ $questionCountValid ? '✓ 将生成 ' . $totalQuestions . ' 题' : '至少需要6题' }}
  567. </p>
  568. </div>
  569. </div>
  570. @unless($readyToGenerate)
  571. <div class="rounded-xl border-2 border-amber-300 bg-gradient-to-r from-amber-50 to-orange-50 px-6 py-4">
  572. <div class="flex items-start gap-3">
  573. <svg class="w-6 h-6 text-amber-600 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  574. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
  575. </svg>
  576. <div>
  577. <p class="text-sm font-bold text-amber-800 mb-1">请完成以下必填项</p>
  578. <p class="text-sm text-amber-700">{{ implode(' / ', $missingSteps) }}</p>
  579. <p class="text-xs text-amber-600 mt-2">
  580. <strong>实时状态:</strong> {{ $debugInfo }}
  581. </p>
  582. <p class="text-xs text-amber-600 mt-1">
  583. <strong>实际代码:</strong> {{ $kpCodesList ?: '(无)' }}
  584. </p>
  585. </div>
  586. </div>
  587. </div>
  588. @endunless
  589. <div class="relative">
  590. <button
  591. wire:click="generateExam"
  592. type="button"
  593. class="generate-button w-full text-white rounded-xl py-4 px-8 text-lg font-bold flex items-center justify-center gap-3 {{ !$readyToGenerate ? 'opacity-50 cursor-not-allowed' : 'hover:shadow-2xl' }}"
  594. wire:loading.attr="disabled"
  595. @if(!$readyToGenerate) disabled @endif
  596. aria-disabled="{{ $readyToGenerate ? 'false' : 'true' }}"
  597. title="{{ $readyToGenerate ? '根据当前选择生成试卷' : '请先完成必选项再生成' }}"
  598. >
  599. @if($isGenerating)
  600. <svg class="animate-spin h-6 w-6 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  601. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  602. <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>
  603. </svg>
  604. <span class="text-lg">正在生成试卷,请稍候...</span>
  605. @else
  606. <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  607. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M13 10V3L4 14h7v7l9-11h-7z" />
  608. </svg>
  609. <span class="text-lg">🚀 智能生成试卷</span>
  610. @endif
  611. </button>
  612. @if($readyToGenerate && !$isGenerating)
  613. <div class="absolute -top-3 -right-3 w-8 h-8 bg-yellow-400 rounded-full flex items-center justify-center animate-bounce">
  614. <svg class="w-5 h-5 text-yellow-800" fill="currentColor" viewBox="0 0 20 20">
  615. <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
  616. </svg>
  617. </div>
  618. @endif
  619. </div>
  620. @if($generatedPaperId)
  621. <div class="mt-6 p-6 bg-gradient-to-br from-green-50 to-emerald-50 border-2 border-green-300 rounded-xl">
  622. <div class="flex items-start gap-4">
  623. <div class="w-12 h-12 bg-green-500 rounded-full flex items-center justify-center flex-shrink-0">
  624. <svg class="w-7 h-7 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  625. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"/>
  626. </svg>
  627. </div>
  628. <div class="flex-1">
  629. <h4 class="text-xl font-bold text-green-800 mb-2">🎉 试卷生成成功!</h4>
  630. <div class="space-y-2 text-sm">
  631. <div class="flex items-center gap-2 text-green-700">
  632. <span class="font-semibold">试卷ID:</span>
  633. <span class="font-mono bg-white px-3 py-1 rounded border border-green-300">{{ $generatedPaperId }}</span>
  634. </div>
  635. <div class="text-green-700">
  636. 试卷已准备就绪,您可以查看预览或导出PDF
  637. </div>
  638. </div>
  639. <div class="mt-5 flex gap-3">
  640. <button
  641. onclick="document.getElementById('pdfPreview').scrollIntoView({behavior: 'smooth'})"
  642. type="button"
  643. class="px-5 py-2.5 bg-white border-2 border-green-500 text-green-700 font-semibold rounded-lg hover:bg-green-50 transition-all shadow-sm"
  644. >
  645. 查看预览
  646. </button>
  647. <button
  648. wire:click="exportToPdf"
  649. type="button"
  650. class="px-5 py-2.5 bg-gradient-to-r from-green-500 to-emerald-600 text-white font-semibold rounded-lg hover:from-green-600 hover:to-emerald-700 transition-all shadow-md"
  651. >
  652. 导出PDF
  653. </button>
  654. </div>
  655. </div>
  656. </div>
  657. </div>
  658. <!-- PDF 预览区域 -->
  659. <div id="pdfPreview" class="mt-8 bg-white rounded-xl border-2 border-gray-200 shadow-lg overflow-hidden">
  660. <div class="p-5 border-b bg-gradient-to-r from-gray-50 to-gray-100 flex justify-between items-center">
  661. <div class="flex items-center gap-3">
  662. <div class="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center">
  663. <svg class="w-4 h-4 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  664. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
  665. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
  666. </svg>
  667. </div>
  668. <h3 class="text-lg font-bold text-gray-900">试卷预览</h3>
  669. </div>
  670. <button
  671. onclick="document.getElementById('pdfFrame').contentWindow.print()"
  672. class="px-4 py-2 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-all shadow-md flex items-center gap-2"
  673. >
  674. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  675. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z" />
  676. </svg>
  677. 打印试卷
  678. </button>
  679. </div>
  680. <div class="p-6 bg-gray-100">
  681. <iframe
  682. id="pdfFrame"
  683. src="{{ route('filament.admin.auth.intelligent-exam.pdf', ['paper_id' => $generatedPaperId]) }}"
  684. class="w-full border-0 rounded-lg shadow-lg"
  685. style="height: 1200px; background: white;"
  686. title="试卷预览">
  687. </iframe>
  688. </div>
  689. </div>
  690. @endif
  691. </div>
  692. </div>
  693. </x-filament-panels::page>