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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. <div>
  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. window.printBoth = function() {
  116. const examFrame = document.getElementById('pdfFrame');
  117. const gradingFrame = document.getElementById('gradingFrame');
  118. if (examFrame?.contentWindow) {
  119. examFrame.contentWindow.focus();
  120. examFrame.contentWindow.print();
  121. }
  122. setTimeout(() => {
  123. if (gradingFrame?.contentWindow) {
  124. gradingFrame.contentWindow.focus();
  125. gradingFrame.contentWindow.print();
  126. }
  127. }, 600);
  128. };
  129. </script>
  130. @endpush
  131. <div class="space-y-6">
  132. <!-- 页面标题 -->
  133. <div class="flex justify-between items-center">
  134. <div>
  135. <h2 class="text-2xl font-bold text-gray-900">智能出卷系统</h2>
  136. <p class="mt-1 text-sm text-gray-500">
  137. 基于知识点掌握度,智能生成个性化试卷
  138. </p>
  139. </div>
  140. <div class="flex gap-3">
  141. <button
  142. wire:click="resetForm"
  143. type="button"
  144. 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"
  145. >
  146. 重置
  147. </button>
  148. </div>
  149. </div>
  150. <!-- 基本信息卡片 -->
  151. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  152. <div class="flex items-center gap-3 mb-6">
  153. <div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
  154. <svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  155. <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" />
  156. </svg>
  157. </div>
  158. <div>
  159. <h3 class="text-xl font-semibold text-gray-900">步骤 1:基本信息设置</h3>
  160. <p class="text-sm text-gray-500">设置试卷的基本参数</p>
  161. </div>
  162. </div>
  163. <div class="space-y-4">
  164. <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
  165. <div class="selection-card border rounded-lg p-4">
  166. <label class="block text-sm font-medium text-gray-700 mb-2">年级</label>
  167. <select wire:model="selectedGrade" class="form-select w-full px-3 py-2 rounded-lg text-sm">
  168. <option value="初中">初中整体</option>
  169. <option value="七年级">七年级</option>
  170. <option value="八年级">八年级</option>
  171. <option value="九年级">九年级</option>
  172. </select>
  173. </div>
  174. <div class="selection-card border rounded-lg p-4">
  175. <label class="block text-sm font-medium text-gray-700 mb-2">难度选择 <span class="text-gray-400 font-normal">(多选,不选=随机)</span></label>
  176. <div class="space-y-2">
  177. @php
  178. $difficultyLevels = ['基础', '中等', '拔高'];
  179. @endphp
  180. @foreach($difficultyLevels as $level)
  181. <label class="flex items-center gap-2 cursor-pointer hover:bg-blue-50 p-2 rounded-lg transition-all">
  182. <input
  183. type="checkbox"
  184. wire:model.live="selectedDifficultyLevels"
  185. value="{{ $level }}"
  186. class="w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  187. />
  188. <span class="text-sm text-gray-700">{{ $level }}</span>
  189. </label>
  190. @endforeach
  191. </div>
  192. @if(empty($selectedDifficultyLevels))
  193. <p class="text-xs text-amber-600 mt-2 flex items-center gap-1">
  194. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  195. <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" />
  196. </svg>
  197. 未选择难度,将随机生成
  198. </p>
  199. @else
  200. <p class="text-xs text-blue-600 mt-2">
  201. 已选择: {{ implode(', ', $selectedDifficultyLevels) }}
  202. </p>
  203. @endif
  204. </div>
  205. <div class="selection-card border rounded-lg p-4">
  206. <label class="block text-sm font-medium text-gray-700 mb-2">题目数量 <span class="text-red-500">*</span></label>
  207. <input
  208. type="number"
  209. wire:model="totalQuestions"
  210. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  211. min="6"
  212. max="100"
  213. required
  214. />
  215. </div>
  216. <div class="selection-card border rounded-lg p-4">
  217. <label class="block text-sm font-medium text-gray-700 mb-2">总分</label>
  218. <input
  219. type="number"
  220. wire:model="totalScore"
  221. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  222. min="0"
  223. max="200"
  224. />
  225. </div>
  226. </div>
  227. <div class="selection-card border rounded-lg p-4">
  228. <label class="block text-sm font-medium text-gray-700 mb-2">试卷名称 <span class="text-gray-400 font-normal">(选填,未填则自动生成)</span></label>
  229. <input
  230. type="text"
  231. wire:model="paperName"
  232. class="form-input w-full px-3 py-2 rounded-lg text-sm"
  233. placeholder="例如:因式分解专项练习(基础版)"
  234. />
  235. </div>
  236. </div>
  237. </div>
  238. <!-- 教师和学生选择 -->
  239. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  240. <div class="flex items-center gap-3 mb-6">
  241. <div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
  242. <svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  243. <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" />
  244. </svg>
  245. </div>
  246. <div>
  247. <h3 class="text-xl font-semibold text-gray-900">步骤 2:选择教师与学生</h3>
  248. <p class="text-sm text-gray-500">启用个性化出卷功能</p>
  249. </div>
  250. </div>
  251. <div class="space-y-6">
  252. <!-- 直接在父组件中显示教师和学生选择,避免组件间通信问题 -->
  253. @if(!$this->isTeacher)
  254. <div class="grid grid-cols-2 gap-4">
  255. <div class="selection-card border rounded-lg p-4">
  256. <label class="block text-sm font-medium text-gray-700 mb-2">选择教师</label>
  257. <select
  258. wire:model.live="selectedTeacherId"
  259. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  260. >
  261. <option value="">-- 请选择教师 --</option>
  262. @foreach($this->teachers as $teacher)
  263. <option value="{{ $teacher->teacher_id }}">
  264. {{ trim($teacher->name ?? $teacher->teacher_id) . ($teacher->subject ? " ({$teacher->subject})" : '') }}
  265. </option>
  266. @endforeach
  267. </select>
  268. </div>
  269. <div class="selection-card border rounded-lg p-4">
  270. <label class="block text-sm font-medium text-gray-700 mb-2">选择学生</label>
  271. <select
  272. wire:model.live="selectedStudentId"
  273. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  274. @if(empty($selectedTeacherId)) disabled @endif
  275. >
  276. <option value="">
  277. @if(empty($selectedTeacherId))
  278. 请先选择教师
  279. @else
  280. -- 请选择学生 --
  281. @endif
  282. </option>
  283. @foreach($this->students as $student)
  284. <option value="{{ $student->student_id }}" @if(request('student_id') == $student->student_id) selected @endif>
  285. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  286. </option>
  287. @endforeach
  288. </select>
  289. </div>
  290. </div>
  291. @else
  292. <div class="grid grid-cols-1 gap-4">
  293. <div class="selection-card border rounded-lg p-4">
  294. <label class="block text-sm font-medium text-gray-700 mb-2">选择学生</label>
  295. <select
  296. wire:model.live="selectedStudentId"
  297. class="form-select w-full px-3 py-2 rounded-lg text-sm"
  298. >
  299. <option value="">-- 请选择学生 --</option>
  300. @foreach($this->students as $student)
  301. <option value="{{ $student->student_id }}" @if(request('student_id') == $student->student_id) selected @endif>
  302. {{ trim($student->name ?? $student->student_id) . " ({$student->grade} - {$student->class_name})" }}
  303. </option>
  304. @endforeach
  305. </select>
  306. </div>
  307. </div>
  308. @endif
  309. <!-- 显示当前选择状态 -->
  310. <div class="mt-4 p-4 bg-gray-50 rounded-lg">
  311. <div class="grid grid-cols-2 gap-4">
  312. <div>
  313. <div class="text-xs font-medium text-gray-500 mb-1">当前选择的教师</div>
  314. <div class="text-sm bg-white px-3 py-2 rounded border">
  315. {{ $this->getSelectedTeacherName() }}
  316. </div>
  317. </div>
  318. <div>
  319. <div class="text-xs font-medium text-gray-500 mb-1">当前选择的学生</div>
  320. <div class="text-sm bg-white px-3 py-2 rounded border">
  321. {{ $this->getSelectedStudentName() }}
  322. </div>
  323. </div>
  324. </div>
  325. </div>
  326. @if($selectedTeacherId && $selectedStudentId)
  327. <div class="p-4 bg-blue-50 rounded-lg">
  328. <div class="flex items-start gap-3">
  329. <svg class="w-5 h-5 text-blue-600 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  330. <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>
  331. </svg>
  332. <div>
  333. <div class="font-medium text-blue-900">针对性出卷已启用</div>
  334. @if($this->hasStudentWeaknesses)
  335. <div class="text-sm text-blue-700 mt-1">
  336. 将根据所选学生的薄弱知识点进行智能推荐,建议自动勾选相关知识点
  337. </div>
  338. <label class="flex items-center gap-2 mt-3 cursor-pointer">
  339. <input
  340. type="checkbox"
  341. wire:model.live="filterByStudentWeakness"
  342. class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  343. />
  344. <span class="text-sm text-blue-700">根据学生薄弱点自动选择知识点</span>
  345. </label>
  346. @else
  347. <div class="text-sm text-gray-500 mt-1">
  348. 该学生暂无薄弱知识点数据,请在下方手动选择知识点
  349. </div>
  350. <label class="flex items-center gap-2 mt-3 opacity-50 cursor-not-allowed">
  351. <input
  352. type="checkbox"
  353. disabled
  354. class="rounded border-gray-300 text-gray-400"
  355. />
  356. <span class="text-sm text-gray-400">根据学生薄弱点自动选择知识点(暂无数据)</span>
  357. </label>
  358. @endif
  359. </div>
  360. </div>
  361. </div>
  362. @endif
  363. </div>
  364. </div>
  365. <!-- 学生薄弱知识点展示区域 -->
  366. @if($selectedStudentId && $filterByStudentWeakness && count($this->studentWeaknesses) > 0)
  367. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  368. <div class="flex items-center gap-3 mb-6">
  369. <div class="w-12 h-12 bg-orange-100 rounded-xl flex items-center justify-center">
  370. <svg class="w-6 h-6 text-orange-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  371. <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" />
  372. </svg>
  373. </div>
  374. <div>
  375. <h3 class="text-xl font-semibold text-gray-900">学生薄弱知识点分析</h3>
  376. <p class="text-sm text-gray-500">基于答题数据的智能分析(共{{ count($this->studentWeaknesses) }}个)</p>
  377. </div>
  378. </div>
  379. <div class="bg-gradient-to-r from-orange-50 to-amber-50 border border-orange-200 rounded-xl p-5 mb-6">
  380. <div class="flex items-start gap-3">
  381. <svg class="h-6 w-6 text-orange-500 flex-shrink-0 mt-0.5" viewBox="0 0 20 20" fill="currentColor">
  382. <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>
  383. </svg>
  384. <div>
  385. <p class="text-sm text-orange-800 font-medium mb-1">
  386. 智能分析结果(可选)
  387. </p>
  388. <p class="text-sm text-orange-700">
  389. 以下是根据该学生的答题数据自动分析出的薄弱知识点(共{{ count($this->studentWeaknesses) }}个)。
  390. <strong>您可以选择这些薄弱点</strong>,或者在下方<strong>步骤3</strong>中手动选择任何知识点。
  391. 两个区域的知识点会合并生效。
  392. </p>
  393. </div>
  394. </div>
  395. </div>
  396. <div class="grid grid-cols-1 gap-3">
  397. @foreach($this->studentWeaknesses as $weakness)
  398. @php
  399. $isSelected = in_array($weakness['kp_code'], $selectedKpCodes);
  400. $masteryPercent = round(($weakness['mastery'] ?? 0) * 100, 1);
  401. $weaknessLevel = $weakness['weakness_level'] ?? (1 - ($weakness['mastery'] ?? 0));
  402. $priority = $weakness['priority'] ?? '中';
  403. $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');
  404. @endphp
  405. <div class="selection-card border rounded-xl p-5 {{ $isSelected ? 'selected' : '' }}">
  406. <div class="flex items-start justify-between">
  407. <div class="flex items-start gap-4 flex-1">
  408. <div class="mt-1">
  409. @if($isSelected)
  410. <svg class="w-6 h-6 text-blue-600" fill="currentColor" viewBox="0 0 20 20">
  411. <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>
  412. </svg>
  413. @else
  414. <input
  415. type="checkbox"
  416. wire:model.live="selectedKpCodes"
  417. value="{{ $weakness['kp_code'] }}"
  418. class="w-5 h-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  419. wire:key="weakness-{{ $weakness['kp_code'] }}"
  420. />
  421. @endif
  422. </div>
  423. <div class="flex-1">
  424. <div class="font-semibold text-gray-900 text-base">
  425. {{ $weakness['kp_name'] ?? $weakness['kp_code'] }}
  426. <span class="ml-2 text-sm text-gray-500">({{ $weakness['kp_code'] }})</span>
  427. </div>
  428. <div class="mt-3 flex items-center gap-6 text-sm">
  429. <div class="flex items-center gap-2">
  430. <span class="text-gray-600">掌握度</span>
  431. <span class="font-bold text-lg {{ $masteryPercent < 50 ? 'text-red-600' : ($masteryPercent < 70 ? 'text-yellow-600' : 'text-green-600') }}">
  432. {{ $masteryPercent }}%
  433. </span>
  434. </div>
  435. <div class="flex items-center gap-2">
  436. <span class="text-gray-600">练习次数</span>
  437. <span class="font-semibold text-gray-900">{{ $weakness['practice_count'] ?? 0 }}</span>
  438. </div>
  439. <div class="flex items-center gap-2">
  440. <span class="text-gray-600">成功率</span>
  441. <span class="font-semibold text-gray-900">{{ round(($weakness['success_rate'] ?? 0) * 100, 1) }}%</span>
  442. </div>
  443. </div>
  444. </div>
  445. </div>
  446. <span class="px-3 py-1.5 text-sm font-semibold rounded-full {{ $priorityColor }}">
  447. {{ $priority }}优先级
  448. </span>
  449. </div>
  450. </div>
  451. @endforeach
  452. </div>
  453. <div class="mt-6 flex items-center justify-between bg-gray-50 rounded-xl p-4">
  454. <div class="flex items-center gap-3">
  455. <button
  456. wire:click="selectAllWeaknesses"
  457. type="button"
  458. 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"
  459. >
  460. 全选薄弱知识点 ({{ count($this->studentWeaknesses) }})
  461. </button>
  462. <button
  463. wire:click="clearSelection"
  464. type="button"
  465. 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"
  466. >
  467. 清空选择
  468. </button>
  469. </div>
  470. <div class="flex items-center gap-2 text-sm text-gray-600" x-data x-effect="$el.querySelector('.count').textContent = $wire.selectedKpCodes.length">
  471. <span>已选择</span>
  472. <span class="font-bold text-lg text-blue-600 count">{{ count($selectedKpCodes) }}</span>
  473. <span>个知识点</span>
  474. </div>
  475. </div>
  476. </div>
  477. @endif
  478. <!-- 知识点选择 -->
  479. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card">
  480. <div class="flex items-center gap-3 mb-6">
  481. <div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
  482. <svg class="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  483. <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" />
  484. </svg>
  485. </div>
  486. <div>
  487. <h3 class="text-xl font-semibold text-gray-900">步骤 3:选择知识点 <span class="text-sm font-normal text-gray-500">(可选,未选择将按年级出题)</span></h3>
  488. <p class="text-sm text-gray-500" x-data x-effect="$el.textContent = `勾选要考查的知识点(已选择: ${$wire.selectedKpCodes.length} 个,未选择将按年级随机生成)`">
  489. 勾选要考查的知识点(已选择: {{ count($selectedKpCodes) }} 个,未选择将按年级随机生成)
  490. </p>
  491. @if($selectedStudentId && $filterByStudentWeakness && count($this->studentWeaknesses) > 0)
  492. <p class="text-xs text-blue-600 mt-1">
  493. 💡 提示:您也可以在上方选择学生的薄弱知识点,两个区域的知识点会合并生效
  494. </p>
  495. @else
  496. <p class="text-xs text-blue-600 mt-1">
  497. 💡 提示:如果不选择知识点,系统将根据所选年级自动生成题目
  498. </p>
  499. @endif
  500. </div>
  501. </div>
  502. <div class="grid grid-cols-1 md:grid-cols-3 gap-3 max-h-72 overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100">
  503. @foreach($this->knowledgePoints as $kp)
  504. @php
  505. $isSelected = in_array($kp['kp_code'], $selectedKpCodes);
  506. @endphp
  507. <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' : '' }}">
  508. <input
  509. type="checkbox"
  510. wire:model.live="selectedKpCodes"
  511. value="{{ $kp['kp_code'] }}"
  512. class="mt-0.5 w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"
  513. wire:key="kp-{{ $kp['kp_code'] }}"
  514. />
  515. <div class="flex-1 min-w-0">
  516. <div class="font-semibold text-gray-900 text-sm leading-tight">{{ Str::limit($kp['cn_name'] ?? $kp['kp_code'], 16) }}</div>
  517. <div class="flex items-center gap-1 mt-1.5">
  518. <span class="text-xs px-2 py-0.5 bg-blue-100 text-blue-700 rounded-full font-medium">
  519. {{ $kp['kp_code'] }}
  520. </span>
  521. </div>
  522. @if(!empty($kp['description']))
  523. <div class="text-xs text-gray-500 mt-1 line-clamp-2">{{ Str::limit($kp['description'], 30) }}</div>
  524. @endif
  525. @if($isSelected)
  526. <div class="text-xs text-blue-600 mt-1 font-medium">✓ 已选择</div>
  527. @endif
  528. </div>
  529. </label>
  530. @endforeach
  531. </div>
  532. </div>
  533. <!-- 生成按钮 -->
  534. @php
  535. $hasTeacherStudent = !empty($selectedTeacherId) && !empty($selectedStudentId);
  536. $hasKnowledgePoints = count($selectedKpCodes) > 0;
  537. $questionCountValid = $totalQuestions >= 6;
  538. $readyToGenerate = $this->canGenerate();
  539. $missingSteps = [];
  540. if (empty($selectedTeacherId)) { $missingSteps[] = '选择教师'; }
  541. if (empty($selectedStudentId)) { $missingSteps[] = '选择学生'; }
  542. // 注意:不强制要求选择知识点,没有选择时将按年级或随机生成
  543. if (!$questionCountValid) { $missingSteps[] = '题目数量需 ≥ 6 题'; }
  544. // 强制访问 selectedKpCodes 来触发 Livewire 刷新
  545. $selectedKpCodesForDebug = $selectedKpCodes;
  546. // 调试信息
  547. $debugInfo = "教师: " . ($selectedTeacherId ? "✓" : "✗") .
  548. " | 学生: " . ($selectedStudentId ? "✓" : "✗") .
  549. " | 知识点: " . ($hasKnowledgePoints ? "✓ (" . count($selectedKpCodesForDebug) . "个)" : "○ (未选,将按年级出题)") .
  550. " | 题目数: " . ($questionCountValid ? "✓ ({$totalQuestions})" : "✗ ({$totalQuestions})");
  551. // 显示实际的知识点代码
  552. $kpCodesList = implode(', ', array_slice($selectedKpCodesForDebug, 0, 10));
  553. if (count($selectedKpCodesForDebug) > 10) {
  554. $kpCodesList .= '...';
  555. }
  556. @endphp
  557. <div class="bg-white p-8 rounded-xl border shadow-sm exam-card space-y-6">
  558. <div class="flex items-center justify-between">
  559. <div class="flex items-center gap-3">
  560. <div class="w-12 h-12 bg-gradient-to-br from-blue-500 to-purple-600 rounded-xl flex items-center justify-center">
  561. <svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  562. <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" />
  563. </svg>
  564. </div>
  565. <div>
  566. <h3 class="text-xl font-semibold text-gray-900">步骤 4:出卷前检查与生成</h3>
  567. <p class="text-sm text-gray-500">验证配置并生成试卷</p>
  568. </div>
  569. </div>
  570. <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' }}">
  571. <span class="h-2.5 w-2.5 rounded-full {{ $readyToGenerate ? 'bg-green-500 animate-pulse' : 'bg-amber-500' }}"></span>
  572. {{ $readyToGenerate ? '✓ 可以生成试卷' : '⚠ 待完善配置' }}
  573. </span>
  574. </div>
  575. <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
  576. <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' }}">
  577. <div class="flex items-center gap-3 mb-2">
  578. <div class="w-10 h-10 rounded-lg {{ $hasTeacherStudent ? 'bg-green-100' : 'bg-amber-100' }} flex items-center justify-center">
  579. @if($hasTeacherStudent)
  580. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  581. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  582. </svg>
  583. @else
  584. <svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  585. <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" />
  586. </svg>
  587. @endif
  588. </div>
  589. <span class="text-sm font-bold {{ $hasTeacherStudent ? 'text-green-800' : 'text-amber-800' }}">教师 / 学生</span>
  590. </div>
  591. <p class="text-sm {{ $hasTeacherStudent ? 'text-green-700' : 'text-amber-700' }}">
  592. {{ $hasTeacherStudent ? '✓ ' . $this->getSelectedTeacherName() . ' / ' . $this->getSelectedStudentName() : '请选择教师和学生' }}
  593. </p>
  594. </div>
  595. <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-blue-300 bg-gradient-to-br from-blue-50 to-indigo-50' }}">
  596. <div class="flex items-center gap-3 mb-2">
  597. <div class="w-10 h-10 rounded-lg {{ $hasKnowledgePoints ? 'bg-green-100' : 'bg-blue-100' }} flex items-center justify-center">
  598. @if($hasKnowledgePoints)
  599. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  600. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  601. </svg>
  602. @else
  603. <svg class="w-5 h-5 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  604. <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" />
  605. </svg>
  606. @endif
  607. </div>
  608. <span class="text-sm font-bold {{ $hasKnowledgePoints ? 'text-green-800' : 'text-blue-800' }}">知识点选择</span>
  609. </div>
  610. <p class="text-sm {{ $hasKnowledgePoints ? 'text-green-700' : 'text-blue-700' }}" x-data x-effect="$el.textContent = $wire.selectedKpCodes.length > 0 ? `✓ 已选 ${$wire.selectedKpCodes.length} 个知识点` : '○ 未选择,将按年级出题'">
  611. {{ $hasKnowledgePoints ? '✓ 已选 ' . count($selectedKpCodes) . ' 个知识点' : '○ 未选择,将按年级出题' }}
  612. </p>
  613. </div>
  614. <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' }}">
  615. <div class="flex items-center gap-3 mb-2">
  616. <div class="w-10 h-10 rounded-lg {{ $questionCountValid ? 'bg-green-100' : 'bg-amber-100' }} flex items-center justify-center">
  617. @if($questionCountValid)
  618. <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  619. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  620. </svg>
  621. @else
  622. <svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  623. <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" />
  624. </svg>
  625. @endif
  626. </div>
  627. <span class="text-sm font-bold {{ $questionCountValid ? 'text-green-800' : 'text-amber-800' }}">题目数量</span>
  628. </div>
  629. <p class="text-sm {{ $questionCountValid ? 'text-green-700' : 'text-amber-700' }}" x-data x-effect="$el.textContent = $wire.totalQuestions >= 6 ? `✓ 将生成 ${$wire.totalQuestions} 题` : '至少需要6题'">
  630. {{ $questionCountValid ? '✓ 将生成 ' . $totalQuestions . ' 题' : '至少需要6题' }}
  631. </p>
  632. </div>
  633. </div>
  634. @unless($readyToGenerate)
  635. <div class="rounded-xl border-2 border-amber-300 bg-gradient-to-r from-amber-50 to-orange-50 px-6 py-4">
  636. <div class="flex items-start gap-3">
  637. <svg class="w-6 h-6 text-amber-600 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  638. <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" />
  639. </svg>
  640. <div>
  641. <p class="text-sm font-bold text-amber-800 mb-1">请完成以下必填项</p>
  642. <p class="text-sm text-amber-700">{{ implode(' / ', $missingSteps) }}</p>
  643. <p class="text-xs text-amber-600 mt-2">
  644. <strong>实时状态:</strong> {{ $debugInfo }}
  645. </p>
  646. <p class="text-xs text-amber-600 mt-1">
  647. <strong>实际代码:</strong> {{ $kpCodesList ?: '(无)' }}
  648. </p>
  649. </div>
  650. </div>
  651. </div>
  652. @endunless
  653. <div class="relative">
  654. <button
  655. wire:click="generateExam"
  656. type="button"
  657. 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' }}"
  658. wire:loading.attr="disabled"
  659. @if(!$readyToGenerate) disabled @endif
  660. aria-disabled="{{ $readyToGenerate ? 'false' : 'true' }}"
  661. title="{{ $readyToGenerate ? '根据当前选择生成试卷' : '请先完成必选项再生成' }}"
  662. >
  663. @if($isGenerating)
  664. <svg class="animate-spin h-6 w-6 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  665. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  666. <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>
  667. </svg>
  668. <span class="text-lg">正在生成试卷,请稍候...</span>
  669. @else
  670. <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  671. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M13 10V3L4 14h7v7l9-11h-7z" />
  672. </svg>
  673. <span class="text-lg">🚀 智能生成试卷</span>
  674. @endif
  675. </button>
  676. @if($readyToGenerate && !$isGenerating)
  677. <div class="absolute -top-3 -right-3 w-8 h-8 bg-yellow-400 rounded-full flex items-center justify-center animate-bounce">
  678. <svg class="w-5 h-5 text-yellow-800" fill="currentColor" viewBox="0 0 20 20">
  679. <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" />
  680. </svg>
  681. </div>
  682. @endif
  683. </div>
  684. @if($generatedPaperId)
  685. <div class="mt-6 p-6 bg-gradient-to-br from-green-50 to-emerald-50 border-2 border-green-300 rounded-xl">
  686. <div class="flex items-start gap-4">
  687. <div class="w-12 h-12 bg-green-500 rounded-full flex items-center justify-center flex-shrink-0">
  688. <svg class="w-7 h-7 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  689. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"/>
  690. </svg>
  691. </div>
  692. <div class="flex-1">
  693. <h4 class="text-xl font-bold text-green-800 mb-2">🎉 试卷生成成功!</h4>
  694. <div class="space-y-2 text-sm">
  695. <div class="flex items-center gap-2 text-green-700">
  696. <span class="font-semibold">试卷ID:</span>
  697. <span class="font-mono bg-white px-3 py-1 rounded border border-green-300">{{ $generatedPaperId }}</span>
  698. </div>
  699. <div class="text-green-700">
  700. 试卷已准备就绪,您可以查看预览或导出PDF
  701. </div>
  702. </div>
  703. <div class="mt-5 flex gap-3">
  704. <button
  705. onclick="document.getElementById('pdfPreview').scrollIntoView({behavior: 'smooth'})"
  706. type="button"
  707. 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"
  708. >
  709. 查看预览
  710. </button>
  711. <button
  712. wire:click="exportToPdf"
  713. type="button"
  714. 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"
  715. >
  716. 导出PDF
  717. </button>
  718. </div>
  719. </div>
  720. </div>
  721. </div>
  722. <!-- PDF 预览区域 -->
  723. <div id="pdfPreview" class="mt-8 bg-white rounded-xl border-2 border-gray-200 shadow-lg overflow-hidden">
  724. <div class="p-5 border-b bg-gradient-to-r from-gray-50 to-gray-100 flex justify-between items-center">
  725. <div class="flex items-center gap-3">
  726. <div class="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center">
  727. <svg class="w-4 h-4 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  728. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
  729. <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" />
  730. </svg>
  731. </div>
  732. <h3 class="text-lg font-bold text-gray-900">试卷预览</h3>
  733. </div>
  734. <button
  735. onclick="document.getElementById('pdfFrame').contentWindow.print()"
  736. 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"
  737. >
  738. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  739. <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" />
  740. </svg>
  741. 打印试卷
  742. </button>
  743. </div>
  744. <div class="p-6 bg-gray-100">
  745. <iframe
  746. id="pdfFrame"
  747. src="{{ route('filament.admin.auth.intelligent-exam.pdf', ['paper_id' => $generatedPaperId, 'answer' => 'false']) }}"
  748. class="w-full border-0 rounded-lg shadow-lg"
  749. style="height: 1200px; background: white;"
  750. title="试卷预览">
  751. </iframe>
  752. </div>
  753. </div>
  754. <!-- 判卷预览区域 -->
  755. <div id="gradingPreview" class="mt-8 bg-white rounded-xl border-2 border-gray-200 shadow-lg overflow-hidden">
  756. <div class="p-5 border-b bg-gradient-to-r from-amber-50 to-amber-100 flex justify-between items-center">
  757. <div class="flex items-center gap-3">
  758. <div class="w-8 h-8 bg-amber-100 rounded-lg flex items-center justify-center">
  759. <svg class="w-4 h-4 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  760. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
  761. </svg>
  762. </div>
  763. <h3 class="text-lg font-bold text-gray-900">判卷预览</h3>
  764. </div>
  765. <div class="flex gap-3">
  766. <button
  767. onclick="document.getElementById('gradingFrame').contentWindow.print()"
  768. class="px-4 py-2 bg-amber-600 text-white font-semibold rounded-lg hover:bg-amber-700 transition-all shadow-md flex items-center gap-2"
  769. >
  770. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  771. <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" />
  772. </svg>
  773. 打印判卷
  774. </button>
  775. <button
  776. onclick="printBoth()"
  777. class="px-4 py-2 border-2 border-amber-600 text-amber-700 font-semibold rounded-lg hover:bg-amber-50 transition-all shadow-sm flex items-center gap-2"
  778. >
  779. <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  780. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 17l4 4 4-4m0-10l-4-4-4 4" />
  781. </svg>
  782. 连续打印试卷+判卷
  783. </button>
  784. </div>
  785. </div>
  786. <div class="p-6 bg-gray-100">
  787. <iframe
  788. id="gradingFrame"
  789. src="{{ route('filament.admin.auth.intelligent-exam.grading', ['paper_id' => $generatedPaperId]) }}"
  790. class="w-full border-0 rounded-lg shadow-lg"
  791. style="height: 1200px; background: white;"
  792. title="判卷预览">
  793. </iframe>
  794. </div>
  795. </div>
  796. @endif
  797. </div>
  798. </div>
  799. </div>