exam-grading.blade.php 12 KB

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