exam-grading.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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. .parallel {
  169. font-family: "NotoSansMonoCJKjp", monospace;
  170. letter-spacing: 1px;
  171. }
  172. .option .katex {
  173. font-size: 1em !important;
  174. vertical-align: 0;
  175. }
  176. /* 仅提升分式可读性(不放大整行选项) */
  177. .option .katex .mfrac {
  178. font-size: 1em !important;
  179. }
  180. /* 选项里的分子分母保持可读且不挤压横线 */
  181. .option .katex .mfrac .mtight {
  182. font-size: 1em !important;
  183. }
  184. /* 分数线稍加粗 */
  185. .option .katex .frac-line {
  186. border-bottom-width: 0.055em !important;
  187. }
  188. /* 自动化实测后的分式微调:分母下移、分子上移,避免贴线 */
  189. .option .katex .mfrac .vlist > span:nth-child(1) {
  190. transform: translateY(0.24em) !important;
  191. }
  192. .option .katex .mfrac .vlist > span:nth-child(3) {
  193. transform: translateY(-0.16em) !important;
  194. }
  195. .option .katex-display {
  196. display: inline;
  197. margin: 0 !important;
  198. vertical-align: baseline;
  199. }
  200. /* 答案区域:不分页 */
  201. .answer-area {
  202. position: relative;
  203. margin-top: 4px;
  204. page-break-inside: avoid;
  205. break-inside: avoid;
  206. }
  207. .answer-area.boxy {
  208. min-height: 150px;
  209. border: 1.5px solid #444;
  210. border-radius: 6px;
  211. padding: 14px;
  212. }
  213. .answer-label {
  214. position: absolute;
  215. top: -10px;
  216. left: 10px;
  217. font-size: 10px;
  218. background: #fff;
  219. padding: 0 4px;
  220. color: #555;
  221. letter-spacing: 1px;
  222. }
  223. /* 答案元信息:不分页 */
  224. .answer-meta {
  225. font-size: 12px;
  226. color: #2f2f2f;
  227. line-height: 1.75;
  228. margin-top: 4px;
  229. page-break-inside: avoid;
  230. break-inside: avoid;
  231. }
  232. .answer-line + .answer-line { margin-top: 4px; }
  233. .solution-step {
  234. align-items: center;
  235. gap: 6px;
  236. }
  237. .step-box { display: inline-block; }
  238. .step-label { white-space: nowrap; }
  239. .solution-heading { font-weight: 700; }
  240. .solution-content { display: inline-block; line-height: 1.75; }
  241. /* 解析区域:不分页 */
  242. .solution-section {
  243. margin-top: 8px;
  244. padding: 6px 8px;
  245. page-break-inside: avoid;
  246. break-inside: avoid;
  247. }
  248. .solution-section strong {
  249. font-size: 13px;
  250. }
  251. .solution-parsed {
  252. margin-top: 6px;
  253. line-height: 1.8;
  254. }
  255. svg, .math-render svg {
  256. max-width: 100%;
  257. height: auto;
  258. display: block;
  259. /* 确保SVG中的文字和图形元素正确对齐 */
  260. shape-rendering: geometricPrecision;
  261. text-rendering: geometricPrecision;
  262. }
  263. /* 优化SVG中文字标签的显示 */
  264. svg text {
  265. font-family: "Noto Serif", "Noto Serif CJK SC", "Noto Sans CJK SC", "Noto Sans", "STSongti-SC", "PingFang SC", "Songti SC", serif !important;
  266. font-size: 13px !important;
  267. font-weight: bold;
  268. font-style: normal;
  269. dominant-baseline: middle;
  270. text-anchor: middle;
  271. alignment-baseline: central;
  272. /* 确保文字在点的正中央 */
  273. paint-order: stroke fill;
  274. stroke: none;
  275. fill: #000;
  276. }
  277. /* SVG中点标签的精确对齐 */
  278. svg text.label-point {
  279. font-size: 14px;
  280. font-weight: bold;
  281. dx: 0;
  282. dy: 0;
  283. }
  284. /* 确保SVG中的圆形和线条正确渲染 */
  285. svg circle, svg line, svg polygon, svg polyline {
  286. shape-rendering: geometricPrecision;
  287. }
  288. /* PDF图片容器:防止图片跨页分割 - 增强版 */
  289. .pdf-figure {
  290. break-inside: avoid;
  291. page-break-inside: avoid;
  292. -webkit-column-break-inside: avoid;
  293. break-before: avoid;
  294. break-after: avoid;
  295. page-break-before: avoid;
  296. page-break-after: avoid;
  297. margin: 8px 0;
  298. display: block;
  299. /* 确保图片不会在页面底部被截断 */
  300. min-height: 30px;
  301. /* 限制独立图块尺寸,避免图片压过文字 */
  302. max-height: 82mm;
  303. }
  304. .pdf-figure img {
  305. max-width: min(84%, 420px);
  306. max-height: 82mm;
  307. width: auto;
  308. height: auto;
  309. display: block;
  310. margin: 0 auto;
  311. object-fit: contain;
  312. box-sizing: border-box;
  313. -webkit-print-color-adjust: exact;
  314. print-color-adjust: exact;
  315. image-rendering: -webkit-optimize-contrast;
  316. }
  317. /* 题干中的图片样式(向后兼容) */
  318. .question-stem img,
  319. .question-main img,
  320. .question-content img,
  321. .answer-meta img,
  322. .answer-line img,
  323. .solution-content img,
  324. .solution-section img,
  325. .solution-parsed img {
  326. display: block;
  327. max-width: 220px;
  328. max-height: 60mm;
  329. width: auto;
  330. height: auto;
  331. margin: 6px auto;
  332. box-sizing: border-box;
  333. object-fit: contain;
  334. -webkit-print-color-adjust: exact;
  335. print-color-adjust: exact;
  336. image-rendering: -webkit-optimize-contrast;
  337. }
  338. /* 选项中的图片样式 - 防止超出容器 */
  339. .option img {
  340. max-width: 92%;
  341. max-height: 42mm;
  342. height: auto;
  343. object-fit: contain;
  344. vertical-align: middle;
  345. }
  346. .question-stem .katex,
  347. .question-main .katex,
  348. .question-content .katex {
  349. font-size: 1em !important;
  350. /* 避免题干/解析中的行内公式整体下沉 */
  351. vertical-align: 0;
  352. }
  353. .question-stem .katex-display,
  354. .question-main .katex-display,
  355. .question-content .katex-display {
  356. margin: 0.35em 0 !important;
  357. }
  358. @include('pdf.partials.grading-scan-sheet-styles')
  359. </style>
  360. </head>
  361. <body style="page-break-before: always;">
  362. <div class="page">
  363. <div class="header">
  364. <div style="font-size:22px;font-weight:bold;">判题专用</div>
  365. <div style="font-size:18px;">{{ $gradingCode }}</div>
  366. <div style="display:flex;justify-content:space-between;font-size:14px;margin-top:8px;">
  367. <span>老师:{{ $teacher['name'] ?? '________' }}</span>
  368. <span>年级:@formatGrade($student['grade'] ?? '________')</span>
  369. @if(!empty($pdfMeta['assemble_type_label']) && $pdfMeta['assemble_type_label'] !== '未知类型')
  370. <span>类型:{{ $pdfMeta['assemble_type_label'] }}</span>
  371. @endif
  372. <span>姓名:{{ $student['name'] ?? '________' }}</span>
  373. <span>得分:________</span>
  374. </div>
  375. <div style="font-size:13px;margin-top:10px;color:#333;text-align:left;">提示:请根据答案和解析进行批改,在回答正确的 □ 内划 / ,在回答错误的 □ 内打 X 或置空</div>
  376. </div>
  377. @include('components.exam.paper-body', ['questions' => $questions, 'grading' => true])
  378. </div>
  379. @if($appendScanSheet)
  380. @include('pdf.partials.grading-scan-sheet', [
  381. 'questions' => $questions,
  382. 'gradingCode' => $gradingCode,
  383. 'teacher' => $teacher,
  384. 'student' => $student,
  385. 'pdfMeta' => $pdfMeta ?? [],
  386. ])
  387. @endif
  388. <!-- KaTeX -->
  389. <script src="/js/katex.min.js"></script>
  390. <script src="/js/auto-render.min.js"></script>
  391. <script>
  392. document.addEventListener('DOMContentLoaded', function() {
  393. try {
  394. renderMathInElement(document.body, {
  395. delimiters: [
  396. {left: '$$', right: '$$', display: true},
  397. {left: '$', right: '$', display: false},
  398. {left: '\\(', right: '\\)', display: false},
  399. {left: '\\[', right: '\\]', display: true}
  400. ],
  401. throwOnError: false,
  402. strict: false,
  403. trust: true
  404. });
  405. } catch(e) {}
  406. });
  407. </script>
  408. </body>
  409. </html>