exam-grading.blade.php 14 KB

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