exam-grading.blade.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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-2 {
  90. display: grid;
  91. grid-template-columns: 1fr 1fr;
  92. gap: 8px 20px;
  93. }
  94. .option { display: flex; align-items: flex-start; font-size: 14px; line-height: 1.6; }
  95. .option strong { margin-right: 4px; }
  96. .option-compact { font-size: 14px; line-height: 1.6; }
  97. .answer-area { position: relative; margin-top: 4px; }
  98. .answer-area.boxy {
  99. min-height: 150px;
  100. border: 1.5px solid #444;
  101. border-radius: 6px;
  102. padding: 14px;
  103. }
  104. .answer-label {
  105. position: absolute;
  106. top: -10px;
  107. left: 10px;
  108. font-size: 10px;
  109. background: #fff;
  110. padding: 0 4px;
  111. color: #555;
  112. letter-spacing: 1px;
  113. }
  114. .answer-meta {
  115. font-size: 12px;
  116. color: #2f2f2f;
  117. line-height: 1.75;
  118. margin-top: 4px;
  119. }
  120. .answer-line + .answer-line { margin-top: 4px; }
  121. .solution-step {
  122. align-items: center;
  123. gap: 6px;
  124. }
  125. .step-box { display: inline-block; }
  126. .step-label { white-space: nowrap; }
  127. .solution-heading { font-weight: 700; }
  128. .solution-content { display: inline-block; line-height: 1.75; }
  129. .solution-section {
  130. margin-top: 8px;
  131. padding: 6px 8px;
  132. }
  133. .solution-section strong {
  134. font-size: 13px;
  135. }
  136. .solution-parsed {
  137. margin-top: 6px;
  138. line-height: 1.8;
  139. }
  140. svg, .math-render svg {
  141. max-width: 100%;
  142. height: auto;
  143. display: block;
  144. /* 确保SVG中的文字和图形元素正确对齐 */
  145. shape-rendering: geometricPrecision;
  146. text-rendering: geometricPrecision;
  147. }
  148. /* 优化SVG中文字标签的显示 */
  149. svg text {
  150. font-family: "SimSun", "Times New Roman", serif !important;
  151. font-size: 12px;
  152. font-weight: bold;
  153. dominant-baseline: middle;
  154. text-anchor: middle;
  155. alignment-baseline: central;
  156. /* 确保文字在点的正中央 */
  157. paint-order: stroke fill;
  158. stroke: none;
  159. fill: #000;
  160. }
  161. /* SVG中点标签的精确对齐 */
  162. svg text.label-point {
  163. font-size: 14px;
  164. font-weight: bold;
  165. dx: 0;
  166. dy: 0;
  167. }
  168. /* 确保SVG中的圆形和线条正确渲染 */
  169. svg circle, svg line, svg polygon, svg polyline {
  170. shape-rendering: geometricPrecision;
  171. }
  172. </style>
  173. </head>
  174. <body>
  175. <div class="page">
  176. <div class="header">
  177. <div style="font-size:22px;font-weight:bold;">判卷专用</div>
  178. <div style="font-size:18px;">{{ $gradingCode }}</div>
  179. <div style="display:flex;justify-content:space-between;font-size:14px;margin-top:8px;">
  180. <span>老师:{{ $teacher['name'] ?? '________' }}</span>
  181. <span>年级:{{ $student['grade'] ?? '________' }}</span>
  182. <span>姓名:{{ $student['name'] ?? '________' }}</span>
  183. <span>得分:________</span>
  184. </div>
  185. </div>
  186. @include('components.exam.paper-body', ['questions' => $questions, 'grading' => true])
  187. </div>
  188. <!-- KaTeX -->
  189. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
  190. <script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"></script>
  191. <script>
  192. document.addEventListener('DOMContentLoaded', function() {
  193. try {
  194. renderMathInElement(document.body, {
  195. delimiters: [
  196. {left: '$$', right: '$$', display: true},
  197. {left: '$', right: '$', display: false},
  198. {left: '\\\\(', right: '\\\\)', display: false},
  199. {left: '\\\\[', right: '\\\\]', display: true}
  200. ],
  201. throwOnError: false,
  202. strict: false,
  203. trust: true
  204. });
  205. } catch(e) {}
  206. });
  207. </script>
  208. </body>
  209. </html>