exam-grading.blade.php 14 KB

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