exam-grading.blade.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. @php
  2. // 复用题目数据并开启判卷模式(显示方框+答案+思路)
  3. $grading = true;
  4. // 生成13位识别码:判卷以2开头 + 12位paper_id数字部分
  5. $rawPaperId = $paper->paper_id ?? 'unknown';
  6. // 从 paper_id 提取12位数字部分(格式: paper_xxxxxxxxxxxx)
  7. if (preg_match('/paper_(\d{12})/', $rawPaperId, $matches)) {
  8. $paperIdNum = $matches[1];
  9. } else {
  10. // 兼容旧格式,取数字部分或生成哈希
  11. $paperIdNum = preg_replace('/[^0-9]/', '', $rawPaperId);
  12. $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT);
  13. }
  14. $gradingCode = '2' . $paperIdNum; // 判卷识别码:2 + 12位数字
  15. @endphp
  16. <!DOCTYPE html>
  17. <html lang="zh-CN">
  18. <head>
  19. <meta charset="UTF-8">
  20. <title>{{ $paper->paper_name ?? '判卷预览' }}</title>
  21. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
  22. <style>
  23. @page {
  24. size: A4;
  25. margin: 2cm 2cm 2.5cm 2cm;
  26. @top-left {
  27. content: "知了数学";
  28. font-size: 10px;
  29. color: #666;
  30. }
  31. @top-right {
  32. content: "{{ $gradingCode }}";
  33. font-size: 10px;
  34. color: #666;
  35. }
  36. @bottom-left {
  37. content: "{{ $gradingCode }}";
  38. font-size: 10px;
  39. color: #666;
  40. }
  41. @bottom-right {
  42. content: counter(page) "/" counter(pages);
  43. font-size: 10px;
  44. color: #666;
  45. }
  46. }
  47. :root {
  48. --question-gap: 6px;
  49. }
  50. body {
  51. font-family: "SimSun", "Songti SC", serif;
  52. line-height: 1.65;
  53. color: #000;
  54. background: #fff;
  55. font-size: 14px;
  56. }
  57. .page {
  58. max-width: 720px;
  59. margin: 0 auto;
  60. padding: 0 12px;
  61. }
  62. .header { text-align: center; margin-bottom: 1.5rem; border-bottom: 2px solid #000; padding-bottom: 1rem; }
  63. .section-title { font-size: 16px; font-weight: bold; margin-top: 16px; margin-bottom: 10px; }
  64. .question { margin-bottom: 14px; page-break-inside: avoid; }
  65. .question-grid {
  66. display: grid;
  67. grid-template-columns: auto 1fr;
  68. column-gap: 4px;
  69. row-gap: 6px;
  70. align-items: flex-start;
  71. }
  72. .question-lead {
  73. display: flex;
  74. gap: 4px;
  75. align-items: flex-start;
  76. font-weight: 600;
  77. font-size: 14px;
  78. line-height: 1.6;
  79. margin-top: 2px;
  80. }
  81. .question-lead.spacer { visibility: hidden; }
  82. .question-number { white-space: nowrap; margin-right: 2px; }
  83. .grading-boxes { gap: 4px; flex-wrap: wrap; align-items: center; }
  84. .grading-boxes span { vertical-align: middle; }
  85. .question-main { font-size: 14px; line-height: 1.65; font-family: inherit; display: block; }
  86. .question-score { margin-right: 6px; font-weight: 600; }
  87. .question-stem { display: inline-block; font-size: 14px; font-family: inherit; }
  88. .options { display: grid; row-gap: 8px; margin-top: 8px; }
  89. .options-grid-4 {
  90. display: grid;
  91. grid-template-columns: repeat(4, 1fr);
  92. gap: 8px 12px;
  93. }
  94. .options-grid-2 {
  95. display: grid;
  96. grid-template-columns: 1fr 1fr;
  97. gap: 8px 20px;
  98. }
  99. .options-grid-1 {
  100. display: grid;
  101. grid-template-columns: 1fr;
  102. gap: 8px;
  103. }
  104. .option { display: flex; align-items: flex-start; font-size: 14px; line-height: 1.6; }
  105. .option strong { margin-right: 4px; }
  106. .option-compact { font-size: 14px; line-height: 1.6; }
  107. .answer-area { position: relative; margin-top: 4px; }
  108. .answer-area.boxy {
  109. min-height: 150px;
  110. border: 1.5px solid #444;
  111. border-radius: 6px;
  112. padding: 14px;
  113. }
  114. .answer-label {
  115. position: absolute;
  116. top: -10px;
  117. left: 10px;
  118. font-size: 10px;
  119. background: #fff;
  120. padding: 0 4px;
  121. color: #555;
  122. letter-spacing: 1px;
  123. }
  124. .answer-meta {
  125. font-size: 12px;
  126. color: #2f2f2f;
  127. line-height: 1.75;
  128. margin-top: 4px;
  129. }
  130. .answer-line + .answer-line { margin-top: 4px; }
  131. .solution-step {
  132. align-items: center;
  133. gap: 6px;
  134. }
  135. .step-box { display: inline-block; }
  136. .step-label { white-space: nowrap; }
  137. .solution-heading { font-weight: 700; }
  138. .solution-content { display: inline-block; line-height: 1.75; }
  139. .solution-section {
  140. margin-top: 8px;
  141. padding: 6px 8px;
  142. }
  143. .solution-section strong {
  144. font-size: 13px;
  145. }
  146. .solution-parsed {
  147. margin-top: 6px;
  148. line-height: 1.8;
  149. }
  150. svg, .math-render svg {
  151. max-width: 100%;
  152. height: auto;
  153. display: block;
  154. /* 确保SVG中的文字和图形元素正确对齐 */
  155. shape-rendering: geometricPrecision;
  156. text-rendering: geometricPrecision;
  157. }
  158. /* 优化SVG中文字标签的显示 */
  159. svg text {
  160. font-family: "SimSun", "Times New Roman", serif !important;
  161. font-size: 12px;
  162. font-weight: bold;
  163. dominant-baseline: middle;
  164. text-anchor: middle;
  165. alignment-baseline: central;
  166. /* 确保文字在点的正中央 */
  167. paint-order: stroke fill;
  168. stroke: none;
  169. fill: #000;
  170. }
  171. /* SVG中点标签的精确对齐 */
  172. svg text.label-point {
  173. font-size: 14px;
  174. font-weight: bold;
  175. dx: 0;
  176. dy: 0;
  177. }
  178. /* 确保SVG中的圆形和线条正确渲染 */
  179. svg circle, svg line, svg polygon, svg polyline {
  180. shape-rendering: geometricPrecision;
  181. }
  182. </style>
  183. </head>
  184. <body>
  185. <div class="page">
  186. <div class="header">
  187. <div style="font-size:22px;font-weight:bold;">判卷专用</div>
  188. <div style="font-size:18px;">{{ $gradingCode }}</div>
  189. <div style="display:flex;justify-content:space-between;font-size:14px;margin-top:8px;">
  190. <span>老师:{{ $teacher['name'] ?? '________' }}</span>
  191. <span>年级:{{ $student['grade'] ?? '________' }}</span>
  192. <span>姓名:{{ $student['name'] ?? '________' }}</span>
  193. <span>得分:________</span>
  194. </div>
  195. </div>
  196. @include('components.exam.paper-body', ['questions' => $questions, 'grading' => true])
  197. </div>
  198. <!-- KaTeX -->
  199. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
  200. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"></script>
  201. <script>
  202. document.addEventListener('DOMContentLoaded', function() {
  203. try {
  204. renderMathInElement(document.body, {
  205. delimiters: [
  206. {left: '$$', right: '$$', display: true},
  207. {left: '$', right: '$', display: false},
  208. {left: '\\(', right: '\\)', display: false},
  209. {left: '\\[', right: '\\]', display: true}
  210. ],
  211. throwOnError: false,
  212. strict: false,
  213. trust: true
  214. });
  215. } catch(e) {}
  216. });
  217. </script>
  218. </body>
  219. </html>