Ver Fonte

fix: 由于学案编号15位,需要修正pdf上的学案编号

大侠咬超人 há 1 semana atrás
pai
commit
fde050dca0

+ 2 - 3
app/Services/PaperIdGenerator.php

@@ -74,15 +74,14 @@ class PaperIdGenerator
     }
 
     /**
-     * 验证数字ID格式(支持12位旧格式和15位新格式
+     * 验证数字ID格式(15位)
      *
      * @param string $id
      * @return bool
      */
     public static function validate(string $id): bool
     {
-        // 支持12位(旧)和15位(新)格式
-        return preg_match('/^[1-9]\d{11,14}$/', $id) === 1;
+        return preg_match('/^[1-9]\d{14}$/', $id) === 1;
     }
 
     /**

+ 3 - 6
app/Services/PaperPayloadService.php

@@ -113,12 +113,9 @@ class PaperPayloadService
 
     public function generatePaperCodes(string $paperId): array
     {
-        if (preg_match('/paper_(\d{12})/', $paperId, $matches)) {
-            $paperIdNum = $matches[1];
-        } else {
-            $paperIdNum = preg_replace('/[^0-9]/', '', $paperId);
-            $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT);
-        }
+        // 提取15位数字ID
+        preg_match('/paper_(\d{15})/', $paperId, $matches);
+        $paperIdNum = $matches[1] ?? preg_replace('/[^0-9]/', '', $paperId);
 
         return [
             'paper_id_num' => $paperIdNum,

+ 4 - 10
resources/views/exam-analysis/pdf-report.blade.php

@@ -1,15 +1,9 @@
 @php
-    // 【参考试卷和判卷格式】学情报告以3开头 + 12位paper_id数字部分
+    // 学情报告识别码:3开头 + 15位paper_id数字部分
     $rawPaperId = $paper['id'] ?? $paper['paper_id'] ?? 'unknown';
-    // 从 paper_id 提取12位数字部分(格式: paper_xxxxxxxxxxxx)
-    if (preg_match('/paper_(\d{12})/', $rawPaperId, $matches)) {
-        $paperIdNum = $matches[1];
-    } else {
-        // 兼容旧格式,取数字部分或生成哈希
-        $paperIdNum = preg_replace('/[^0-9]/', '', $rawPaperId);
-        $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT);
-    }
-    $reportCode = '3' . $paperIdNum; // 学情报告识别码:3 + 12位数字
+    preg_match('/paper_(\d{15})/', $rawPaperId, $matches);
+    $paperIdNum = $matches[1] ?? preg_replace('/[^0-9]/', '', $rawPaperId);
+    $reportCode = '3' . $paperIdNum;
     $averageMastery = isset($mastery['average']) ? number_format($mastery['average'] * 100, 1) . '%' : '无数据';
 
     // 【修复】从insights中获取AI分析结果(而不是从analysis_data)

+ 4 - 11
resources/views/pdf/exam-grading.blade.php

@@ -1,17 +1,10 @@
 @php
-    // 复用题目数据并开启判卷模式(显示方框+答案+思路)
     $grading = true;
-    // 生成13位识别码:判卷以2开头 + 12位paper_id数字部分
+    // 生成识别码:判卷以2开头 + 15位paper_id数字部分
     $rawPaperId = $paper->paper_id ?? 'unknown';
-    // 从 paper_id 提取12位数字部分(格式: paper_xxxxxxxxxxxx)
-    if (preg_match('/paper_(\d{12})/', $rawPaperId, $matches)) {
-        $paperIdNum = $matches[1];
-    } else {
-        // 兼容旧格式,取数字部分或生成哈希
-        $paperIdNum = preg_replace('/[^0-9]/', '', $rawPaperId);
-        $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT);
-    }
-    $gradingCode = '2' . $paperIdNum; // 判卷识别码:2 + 12位数字
+    preg_match('/paper_(\d{15})/', $rawPaperId, $matches);
+    $paperIdNum = $matches[1] ?? preg_replace('/[^0-9]/', '', $rawPaperId);
+    $gradingCode = '2' . $paperIdNum;
 @endphp
 <!DOCTYPE html>
 <html lang="zh-CN">

+ 4 - 10
resources/views/pdf/exam-paper.blade.php

@@ -5,17 +5,11 @@
     <title>{{ $paper->paper_name ?? '试卷预览' }}</title>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
     @php
-        // 生成13位识别码:试卷以1开头 + 12位paper_id数字部分
+        // 生成识别码:试卷以1开头 + 15位paper_id数字部分
         $rawPaperId = $paper->paper_id ?? 'unknown';
-        // 从 paper_id 提取12位数字部分(格式: paper_xxxxxxxxxxxx)
-        if (preg_match('/paper_(\d{12})/', $rawPaperId, $matches)) {
-            $paperIdNum = $matches[1];
-        } else {
-            // 兼容旧格式,取数字部分或生成哈希
-            $paperIdNum = preg_replace('/[^0-9]/', '', $rawPaperId);
-            $paperIdNum = str_pad(substr($paperIdNum, 0, 12), 12, '0', STR_PAD_LEFT);
-        }
-        $examCode = '1' . $paperIdNum; // 试卷识别码:1 + 12位数字
+        preg_match('/paper_(\d{15})/', $rawPaperId, $matches);
+        $paperIdNum = $matches[1] ?? preg_replace('/[^0-9]/', '', $rawPaperId);
+        $examCode = '1' . $paperIdNum;
     @endphp
     <style>
         @page {

+ 2 - 8
scripts/katex-render.mjs

@@ -137,14 +137,8 @@ function processDelimiter(html, left, right, displayMode) {
                 return match;
             }
 
-            // 【安全检查】如果内容看起来不像 LaTeX,跳过
-            // 跳过只有普通文本的内容(没有任何 LaTeX 特征)
-            if (!/[\\^_{}]/.test(cleanLatex) && !/[a-zA-Z]{2,}/.test(cleanLatex)) {
-                // 可能只是普通数字或单字母,检查是否有意义
-                if (/^[\d\s\.\,\-\+]+$/.test(cleanLatex)) {
-                    return match; // 纯数字,不渲染
-                }
-            }
+            // 不再跳过任何内容 - 既然用 $...$ 包裹了,就应该渲染
+            // 在数学教育场景下,$123$ 应该显示为数学字体的数字
 
             // 渲染 KaTeX
             const rendered = katex.renderToString(cleanLatex, {