exam-grading.blade.php 8.8 KB

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