exam-grading.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. @php
  2. $grading = true;
  3. // 提取15位paper_id数字部分作为学案编号
  4. $rawPaperId = $paper->paper_id ?? 'unknown';
  5. preg_match('/paper_(\d{15})/', $rawPaperId, $matches);
  6. $gradingCode = $matches[1] ?? preg_replace('/[^0-9]/', '', $rawPaperId);
  7. $studentName = $student['name'] ?? ($paper->student_id ?? '________');
  8. // 生成时间(格式:2026年01月30日 15:04:05)
  9. $generateDateTime = now()->format('Y年m月d日 H:i:s');
  10. // 是否在判卷PDF末尾追加扫描判题卡
  11. $appendScanSheet = config('exam.pdf_grading_append_scan_sheet', false);
  12. @endphp
  13. <!DOCTYPE html>
  14. <html lang="zh-CN">
  15. <head>
  16. <meta charset="UTF-8">
  17. <title>{{ $paper->paper_name ?? '判卷预览' }}</title>
  18. <link rel="stylesheet" href="/css/katex/katex.min.css">
  19. <style>
  20. @page {
  21. size: A4;
  22. margin: 2.2cm 2cm 2.3cm 2cm;
  23. @top-left {
  24. content: "知了数学·{{ $generateDateTime }}";
  25. font-size: 13px;
  26. color: #666;
  27. }
  28. @top-center {
  29. content: "{{ $studentName }}";
  30. font-size: 13px;
  31. color: #666;
  32. }
  33. @top-right {
  34. content: "{{ $gradingCode }}";
  35. font-size: 17px;
  36. font-weight: 600;
  37. font-family: "Noto Sans", "Liberation Sans", "Nimbus Sans", sans-serif;
  38. letter-spacing: 0;
  39. padding-right: 3mm;
  40. padding-top: 1.2mm;
  41. color: #222;
  42. }
  43. @bottom-left {
  44. content: "{{ $gradingCode }}";
  45. font-size: 13px;
  46. color: #666;
  47. }
  48. @bottom-right {
  49. content: counter(page) "/" counter(pages);
  50. font-size: 13px;
  51. color: #666;
  52. }
  53. }
  54. :root {
  55. --question-gap: 6px;
  56. }
  57. body {
  58. font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif;
  59. line-height: 1.65;
  60. color: #000;
  61. background: #fff;
  62. font-size: 14px;
  63. }
  64. .page {
  65. max-width: 720px;
  66. margin: 0 auto;
  67. padding: 0 12px;
  68. }
  69. .header { text-align: center; margin-bottom: 1.5rem; border-bottom: 2px solid #000; padding-bottom: 1rem; }
  70. /* 大题标题:不与后面内容分开 */
  71. .section-title {
  72. font-size: 16px;
  73. font-weight: bold;
  74. margin-top: 16px;
  75. margin-bottom: 10px;
  76. page-break-after: avoid;
  77. break-after: avoid;
  78. }
  79. /* 题目整体:不分页 */
  80. .question {
  81. margin-bottom: 14px;
  82. page-break-inside: avoid;
  83. break-inside: avoid;
  84. -webkit-column-break-inside: avoid;
  85. }
  86. /* 题目网格:不分页 */
  87. .question-grid {
  88. display: grid;
  89. grid-template-columns: auto 1fr;
  90. column-gap: 4px;
  91. row-gap: 6px;
  92. align-items: flex-start;
  93. page-break-inside: avoid;
  94. break-inside: avoid;
  95. }
  96. .question-lead {
  97. display: flex;
  98. gap: 4px;
  99. align-items: flex-start;
  100. font-weight: 600;
  101. font-size: 14px;
  102. line-height: 1.65;
  103. margin-top: 1px;
  104. }
  105. .question-lead.spacer { visibility: hidden; }
  106. .question-number { white-space: nowrap; margin-right: 2px; }
  107. .grading-boxes { gap: 4px; flex-wrap: wrap; align-items: center; }
  108. .grading-boxes span { vertical-align: middle; }
  109. /* 题目内容:防止孤行 */
  110. .question-main {
  111. font-size: 14px;
  112. line-height: 1.65;
  113. font-family: inherit;
  114. display: block;
  115. orphans: 3;
  116. widows: 3;
  117. }
  118. .question-score { margin-right: 6px; font-weight: 600; }
  119. .question-stem {
  120. display: inline-block;
  121. font-size: 14px;
  122. font-family: inherit;
  123. orphans: 3;
  124. widows: 3;
  125. }
  126. /* 选项容器:不分页 */
  127. .options {
  128. display: grid;
  129. row-gap: 8px;
  130. margin-top: 8px;
  131. page-break-inside: avoid;
  132. break-inside: avoid;
  133. }
  134. .options-grid-4 {
  135. display: grid;
  136. grid-template-columns: repeat(4, 1fr);
  137. gap: 8px 12px;
  138. page-break-inside: avoid;
  139. break-inside: avoid;
  140. }
  141. .options-grid-2 {
  142. display: grid;
  143. grid-template-columns: 1fr 1fr;
  144. gap: 8px 20px;
  145. page-break-inside: avoid;
  146. break-inside: avoid;
  147. }
  148. .options-grid-1 {
  149. display: grid;
  150. grid-template-columns: 1fr;
  151. gap: 8px;
  152. page-break-inside: avoid;
  153. break-inside: avoid;
  154. }
  155. /* 单个选项:不分页 */
  156. .option {
  157. display: flex;
  158. align-items: baseline;
  159. font-size: 13.2px;
  160. line-height: 1.6;
  161. page-break-inside: avoid;
  162. break-inside: avoid;
  163. }
  164. .option strong { margin-right: 4px; flex: 0 0 auto; line-height: 1.6; }
  165. .option-compact { line-height: inherit; }
  166. .option p, .option div { margin: 0; display: inline; }
  167. .option .katex {
  168. font-size: 1em !important;
  169. vertical-align: 0;
  170. }
  171. /* 仅提升分式可读性(不放大整行选项) */
  172. .option .katex .mfrac {
  173. font-size: 1em !important;
  174. }
  175. /* 选项里的分子分母保持可读且不挤压横线 */
  176. .option .katex .mfrac .mtight {
  177. font-size: 1em !important;
  178. }
  179. /* 分数线稍加粗 */
  180. .option .katex .frac-line {
  181. border-bottom-width: 0.055em !important;
  182. }
  183. /* 自动化实测后的分式微调:分母下移、分子上移,避免贴线 */
  184. .option .katex .mfrac .vlist > span:nth-child(1) {
  185. transform: translateY(0.24em) !important;
  186. }
  187. .option .katex .mfrac .vlist > span:nth-child(3) {
  188. transform: translateY(-0.16em) !important;
  189. }
  190. .option .katex-display {
  191. display: inline;
  192. margin: 0 !important;
  193. vertical-align: baseline;
  194. }
  195. /* 答案区域:不分页 */
  196. .answer-area {
  197. position: relative;
  198. margin-top: 4px;
  199. page-break-inside: avoid;
  200. break-inside: avoid;
  201. }
  202. .answer-area.boxy {
  203. min-height: 150px;
  204. border: 1.5px solid #444;
  205. border-radius: 6px;
  206. padding: 14px;
  207. }
  208. .answer-label {
  209. position: absolute;
  210. top: -10px;
  211. left: 10px;
  212. font-size: 10px;
  213. background: #fff;
  214. padding: 0 4px;
  215. color: #555;
  216. letter-spacing: 1px;
  217. }
  218. /* 答案元信息:不分页 */
  219. .answer-meta {
  220. font-size: 12px;
  221. color: #2f2f2f;
  222. line-height: 1.75;
  223. margin-top: 4px;
  224. page-break-inside: avoid;
  225. break-inside: avoid;
  226. }
  227. .answer-line + .answer-line { margin-top: 4px; }
  228. .solution-step {
  229. align-items: center;
  230. gap: 6px;
  231. }
  232. .step-box { display: inline-block; }
  233. .step-label { white-space: nowrap; }
  234. .solution-heading { font-weight: 700; }
  235. .solution-content { display: inline-block; line-height: 1.75; }
  236. /* 解析区域:不分页 */
  237. .solution-section {
  238. margin-top: 8px;
  239. padding: 6px 8px;
  240. page-break-inside: avoid;
  241. break-inside: avoid;
  242. }
  243. .solution-section strong {
  244. font-size: 13px;
  245. }
  246. .solution-parsed {
  247. margin-top: 6px;
  248. line-height: 1.8;
  249. }
  250. svg, .math-render svg {
  251. max-width: 100%;
  252. height: auto;
  253. display: block;
  254. /* 确保SVG中的文字和图形元素正确对齐 */
  255. shape-rendering: geometricPrecision;
  256. text-rendering: geometricPrecision;
  257. }
  258. /* 优化SVG中文字标签的显示 */
  259. svg text {
  260. font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif !important;
  261. font-size: 13px !important;
  262. font-weight: bold;
  263. font-style: normal;
  264. dominant-baseline: middle;
  265. text-anchor: middle;
  266. alignment-baseline: central;
  267. /* 确保文字在点的正中央 */
  268. paint-order: stroke fill;
  269. stroke: none;
  270. fill: #000;
  271. }
  272. /* SVG中点标签的精确对齐 */
  273. svg text.label-point {
  274. font-size: 14px;
  275. font-weight: bold;
  276. dx: 0;
  277. dy: 0;
  278. }
  279. /* 确保SVG中的圆形和线条正确渲染 */
  280. svg circle, svg line, svg polygon, svg polyline {
  281. shape-rendering: geometricPrecision;
  282. }
  283. /* PDF图片容器:防止图片跨页分割 - 增强版 */
  284. .pdf-figure {
  285. break-inside: avoid;
  286. page-break-inside: avoid;
  287. -webkit-column-break-inside: avoid;
  288. break-before: avoid;
  289. break-after: avoid;
  290. page-break-before: avoid;
  291. page-break-after: avoid;
  292. margin: 8px 0;
  293. display: block;
  294. /* 确保图片不会在页面底部被截断 */
  295. min-height: 30px;
  296. /* 限制独立图块尺寸,避免图片压过文字 */
  297. max-height: 82mm;
  298. }
  299. .pdf-figure img {
  300. max-width: min(84%, 420px);
  301. max-height: 82mm;
  302. width: auto;
  303. height: auto;
  304. display: block;
  305. margin: 0 auto;
  306. object-fit: contain;
  307. box-sizing: border-box;
  308. -webkit-print-color-adjust: exact;
  309. print-color-adjust: exact;
  310. image-rendering: -webkit-optimize-contrast;
  311. }
  312. /* 题干中的图片样式(向后兼容) */
  313. .question-stem img,
  314. .question-main img,
  315. .question-content img,
  316. .answer-meta img,
  317. .answer-line img,
  318. .solution-content img,
  319. .solution-section img,
  320. .solution-parsed img {
  321. display: block;
  322. max-width: 220px;
  323. max-height: 60mm;
  324. width: auto;
  325. height: auto;
  326. margin: 6px auto;
  327. box-sizing: border-box;
  328. object-fit: contain;
  329. -webkit-print-color-adjust: exact;
  330. print-color-adjust: exact;
  331. image-rendering: -webkit-optimize-contrast;
  332. }
  333. /* 选项中的图片样式 - 防止超出容器 */
  334. .option img {
  335. max-width: 100%;
  336. height: auto;
  337. vertical-align: middle;
  338. }
  339. .question-stem .katex,
  340. .question-main .katex,
  341. .question-content .katex {
  342. font-size: 1em !important;
  343. /* 避免题干/解析中的行内公式整体下沉 */
  344. vertical-align: 0;
  345. }
  346. .question-stem .katex-display,
  347. .question-main .katex-display,
  348. .question-content .katex-display {
  349. margin: 0.35em 0 !important;
  350. }
  351. @include('pdf.partials.grading-scan-sheet-styles')
  352. </style>
  353. </head>
  354. <body style="page-break-before: always;">
  355. <div class="page">
  356. <div class="header">
  357. <div style="font-size:22px;font-weight:bold;">判卷专用</div>
  358. <div style="font-size:18px;">{{ $gradingCode }}</div>
  359. <div style="display:flex;justify-content:space-between;font-size:14px;margin-top:8px;">
  360. <span>老师:{{ $teacher['name'] ?? '________' }}</span>
  361. <span>年级:@formatGrade($student['grade'] ?? '________')</span>
  362. <span>姓名:{{ $student['name'] ?? '________' }}</span>
  363. <span>得分:________</span>
  364. </div>
  365. <div style="font-size:13px;margin-top:10px;color:#333;text-align:left;">提示:请根据答案和解析进行批改,在回答正确的 □ 前划 / ,在回答错误的 □ 前打 X 或置空</div>
  366. </div>
  367. @include('components.exam.paper-body', ['questions' => $questions, 'grading' => true])
  368. </div>
  369. @if($appendScanSheet)
  370. @include('pdf.partials.grading-scan-sheet', [
  371. 'questions' => $questions,
  372. 'gradingCode' => $gradingCode,
  373. 'teacher' => $teacher,
  374. 'student' => $student,
  375. ])
  376. @endif
  377. <!-- KaTeX -->
  378. <script src="/js/katex.min.js"></script>
  379. <script src="/js/auto-render.min.js"></script>
  380. <script>
  381. document.addEventListener('DOMContentLoaded', function() {
  382. try {
  383. renderMathInElement(document.body, {
  384. delimiters: [
  385. {left: '$$', right: '$$', display: true},
  386. {left: '$', right: '$', display: false},
  387. {left: '\\(', right: '\\)', display: false},
  388. {left: '\\[', right: '\\]', display: true}
  389. ],
  390. throwOnError: false,
  391. strict: false,
  392. trust: true
  393. });
  394. } catch(e) {}
  395. });
  396. </script>
  397. </body>
  398. </html>