exam-grading.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. // 生成日期(格式:1月24日)
  8. $generateDate = now()->locale('zh_CN')->isoFormat('M月D日');
  9. @endphp
  10. <!DOCTYPE html>
  11. <html lang="zh-CN">
  12. <head>
  13. <meta charset="UTF-8">
  14. <title>{{ $paper->paper_name ?? '判卷预览' }}</title>
  15. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
  16. <style>
  17. @page {
  18. size: A4;
  19. margin: 2cm 2cm 2.5cm 2cm;
  20. @top-left {
  21. content: "知了数学·{{ $generateDate }}";
  22. font-size: 12px;
  23. color: #666;
  24. }
  25. @top-right {
  26. content: "{{ $gradingCode }}";
  27. font-size: 12px;
  28. color: #666;
  29. }
  30. @bottom-left {
  31. content: "{{ $gradingCode }}";
  32. font-size: 12px;
  33. color: #666;
  34. }
  35. @bottom-right {
  36. content: counter(page) "/" counter(pages);
  37. font-size: 12px;
  38. color: #666;
  39. }
  40. }
  41. :root {
  42. --question-gap: 6px;
  43. }
  44. body {
  45. font-family: "SimSun", "Songti SC", serif;
  46. line-height: 1.65;
  47. color: #000;
  48. background: #fff;
  49. font-size: 14px;
  50. }
  51. .page {
  52. max-width: 720px;
  53. margin: 0 auto;
  54. padding: 0 12px;
  55. }
  56. .header { text-align: center; margin-bottom: 1.5rem; border-bottom: 2px solid #000; padding-bottom: 1rem; }
  57. /* 大题标题:不与后面内容分开 */
  58. .section-title {
  59. font-size: 16px;
  60. font-weight: bold;
  61. margin-top: 16px;
  62. margin-bottom: 10px;
  63. page-break-after: avoid;
  64. break-after: avoid;
  65. }
  66. /* 题目整体:不分页 */
  67. .question {
  68. margin-bottom: 14px;
  69. page-break-inside: avoid;
  70. break-inside: avoid;
  71. -webkit-column-break-inside: avoid;
  72. }
  73. /* 题目网格:不分页 */
  74. .question-grid {
  75. display: grid;
  76. grid-template-columns: auto 1fr;
  77. column-gap: 4px;
  78. row-gap: 6px;
  79. align-items: flex-start;
  80. page-break-inside: avoid;
  81. break-inside: avoid;
  82. }
  83. .question-lead {
  84. display: flex;
  85. gap: 4px;
  86. align-items: flex-start;
  87. font-weight: 600;
  88. font-size: 14px;
  89. line-height: 1.6;
  90. margin-top: 2px;
  91. }
  92. .question-lead.spacer { visibility: hidden; }
  93. .question-number { white-space: nowrap; margin-right: 2px; }
  94. .grading-boxes { gap: 4px; flex-wrap: wrap; align-items: center; }
  95. .grading-boxes span { vertical-align: middle; }
  96. /* 题目内容:防止孤行 */
  97. .question-main {
  98. font-size: 14px;
  99. line-height: 1.65;
  100. font-family: inherit;
  101. display: block;
  102. orphans: 3;
  103. widows: 3;
  104. }
  105. .question-score { margin-right: 6px; font-weight: 600; }
  106. .question-stem {
  107. display: inline-block;
  108. font-size: 14px;
  109. font-family: inherit;
  110. orphans: 3;
  111. widows: 3;
  112. }
  113. /* 选项容器:不分页 */
  114. .options {
  115. display: grid;
  116. row-gap: 8px;
  117. margin-top: 8px;
  118. page-break-inside: avoid;
  119. break-inside: avoid;
  120. }
  121. .options-grid-4 {
  122. display: grid;
  123. grid-template-columns: repeat(4, 1fr);
  124. gap: 8px 12px;
  125. page-break-inside: avoid;
  126. break-inside: avoid;
  127. }
  128. .options-grid-2 {
  129. display: grid;
  130. grid-template-columns: 1fr 1fr;
  131. gap: 8px 20px;
  132. page-break-inside: avoid;
  133. break-inside: avoid;
  134. }
  135. .options-grid-1 {
  136. display: grid;
  137. grid-template-columns: 1fr;
  138. gap: 8px;
  139. page-break-inside: avoid;
  140. break-inside: avoid;
  141. }
  142. /* 单个选项:不分页 */
  143. .option {
  144. display: flex;
  145. align-items: flex-start;
  146. font-size: 14px;
  147. line-height: 1.6;
  148. page-break-inside: avoid;
  149. break-inside: avoid;
  150. }
  151. .option strong { margin-right: 4px; }
  152. .option-compact { font-size: 14px; line-height: 1.6; }
  153. /* 答案区域:不分页 */
  154. .answer-area {
  155. position: relative;
  156. margin-top: 4px;
  157. page-break-inside: avoid;
  158. break-inside: avoid;
  159. }
  160. .answer-area.boxy {
  161. min-height: 150px;
  162. border: 1.5px solid #444;
  163. border-radius: 6px;
  164. padding: 14px;
  165. }
  166. .answer-label {
  167. position: absolute;
  168. top: -10px;
  169. left: 10px;
  170. font-size: 10px;
  171. background: #fff;
  172. padding: 0 4px;
  173. color: #555;
  174. letter-spacing: 1px;
  175. }
  176. /* 答案元信息:不分页 */
  177. .answer-meta {
  178. font-size: 12px;
  179. color: #2f2f2f;
  180. line-height: 1.75;
  181. margin-top: 4px;
  182. page-break-inside: avoid;
  183. break-inside: avoid;
  184. }
  185. .answer-line + .answer-line { margin-top: 4px; }
  186. .solution-step {
  187. align-items: center;
  188. gap: 6px;
  189. }
  190. .step-box { display: inline-block; }
  191. .step-label { white-space: nowrap; }
  192. .solution-heading { font-weight: 700; }
  193. .solution-content { display: inline-block; line-height: 1.75; }
  194. /* 解析区域:不分页 */
  195. .solution-section {
  196. margin-top: 8px;
  197. padding: 6px 8px;
  198. page-break-inside: avoid;
  199. break-inside: avoid;
  200. }
  201. .solution-section strong {
  202. font-size: 13px;
  203. }
  204. .solution-parsed {
  205. margin-top: 6px;
  206. line-height: 1.8;
  207. }
  208. svg, .math-render svg {
  209. max-width: 100%;
  210. height: auto;
  211. display: block;
  212. /* 确保SVG中的文字和图形元素正确对齐 */
  213. shape-rendering: geometricPrecision;
  214. text-rendering: geometricPrecision;
  215. }
  216. /* 优化SVG中文字标签的显示 */
  217. svg text {
  218. font-family: "SimSun", "Times New Roman", serif !important;
  219. font-size: 12px;
  220. font-weight: bold;
  221. dominant-baseline: middle;
  222. text-anchor: middle;
  223. alignment-baseline: central;
  224. /* 确保文字在点的正中央 */
  225. paint-order: stroke fill;
  226. stroke: none;
  227. fill: #000;
  228. }
  229. /* SVG中点标签的精确对齐 */
  230. svg text.label-point {
  231. font-size: 14px;
  232. font-weight: bold;
  233. dx: 0;
  234. dy: 0;
  235. }
  236. /* 确保SVG中的圆形和线条正确渲染 */
  237. svg circle, svg line, svg polygon, svg polyline {
  238. shape-rendering: geometricPrecision;
  239. }
  240. /* PDF图片容器:防止图片跨页分割 - 增强版 */
  241. .pdf-figure {
  242. break-inside: avoid;
  243. page-break-inside: avoid;
  244. -webkit-column-break-inside: avoid;
  245. break-before: avoid;
  246. break-after: avoid;
  247. page-break-before: avoid;
  248. page-break-after: avoid;
  249. margin: 8px 0;
  250. display: block;
  251. /* 确保图片不会在页面底部被截断 */
  252. min-height: 30px;
  253. /* 限制单张图片最大高度,防止过大图片跨页 */
  254. max-height: 180mm;
  255. }
  256. .pdf-figure img {
  257. max-width: 100%;
  258. height: auto;
  259. display: block;
  260. margin: 0 auto;
  261. object-fit: contain;
  262. box-sizing: border-box;
  263. }
  264. /* 题干中的图片样式(向后兼容) */
  265. .question-stem img,
  266. .question-main img,
  267. .question-content img {
  268. display: block;
  269. max-width: 100%;
  270. height: auto;
  271. margin: 12px auto;
  272. box-sizing: border-box;
  273. }
  274. /* 选项中的图片样式 - 防止超出容器 */
  275. .option img {
  276. max-width: 100%;
  277. height: auto;
  278. vertical-align: middle;
  279. }
  280. </style>
  281. </head>
  282. <body style="page-break-before: always;">
  283. <div class="page">
  284. <div class="header">
  285. <div style="font-size:22px;font-weight:bold;">判卷专用</div>
  286. <div style="font-size:18px;">{{ $gradingCode }}</div>
  287. <div style="display:flex;justify-content:space-between;font-size:14px;margin-top:8px;">
  288. <span>老师:{{ $teacher['name'] ?? '________' }}</span>
  289. <span>年级:@formatGrade($student['grade'] ?? '________')</span>
  290. <span>姓名:{{ $student['name'] ?? '________' }}</span>
  291. <span>得分:________</span>
  292. </div>
  293. <div style="font-size:13px;margin-top:10px;color:#333;text-align:left;">提示:请根据答案和解析进行批改,在回答正确的 □ 前划 / ,在回答错误的 □ 前打 X 或置空</div>
  294. </div>
  295. @include('components.exam.paper-body', ['questions' => $questions, 'grading' => true])
  296. </div>
  297. <!-- KaTeX -->
  298. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
  299. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"></script>
  300. <script>
  301. document.addEventListener('DOMContentLoaded', function() {
  302. try {
  303. renderMathInElement(document.body, {
  304. delimiters: [
  305. {left: '$$', right: '$$', display: true},
  306. {left: '$', right: '$', display: false},
  307. {left: '\\(', right: '\\)', display: false},
  308. {left: '\\[', right: '\\]', display: true}
  309. ],
  310. throwOnError: false,
  311. strict: false,
  312. trust: true
  313. });
  314. } catch(e) {}
  315. });
  316. </script>
  317. </body>
  318. </html>