exam-grading.blade.php 12 KB

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