From 93c133349a5ccd7a328371fa113dce69d5611f21 Mon Sep 17 00:00:00 2001
From: liuyu <yu.liu@cqgbkj.com>
Date: 星期二, 22 九月 2026 09:25:39 +0800
Subject: [PATCH] feat(tms): 完成课程考试自测等页面与接口对接

---
 apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/mock.ts |   82 +++++++++++++++++++++--------------------
 1 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/mock.ts b/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/mock.ts
index d35d515..8a78b1e 100644
--- a/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/mock.ts
+++ b/apps/jnpf-web-apps-main/src/views/x/tms/onlineExam/mock.ts
@@ -6,11 +6,50 @@
   OnlineExamQuestionItem,
 } from './types';
 
-import { mockGetQuestion, mockQueryQuestions } from '#/views/x/tms/question/mock';
-
 function delay<T>(data: T, ms = 220): Promise<T> {
   return new Promise((resolve) => setTimeout(() => resolve(data), ms));
 }
+
+/** 鍦ㄧ嚎鑰冭瘯 mock 鑷甫鏍烽锛堜笉鍐嶄緷璧栬瘯棰樼鐞� mock锛� */
+const DEMO_QUESTIONS: OnlineExamQuestionItem[] = [
+  {
+    id: 'demo_q1',
+    questionNo: '260001',
+    questionType: 'judge',
+    stem: '鐗圭浣滀笟浜哄憳蹇呴』鍙栧緱鏈夋晥璧勬牸璇佷功鍚庢柟鍙笂宀椾綔涓氥��',
+    score: 20,
+    options: [
+      { optionLabel: 'T', optionContent: '姝g‘', isCorrect: '1' },
+      { optionLabel: 'F', optionContent: '閿欒', isCorrect: '0' },
+    ],
+  },
+  {
+    id: 'demo_q2',
+    questionNo: '260002',
+    questionType: 'multi',
+    stem: '涓嬪垪鍝簺灞炰簬鐗圭璁惧锛�',
+    score: 20,
+    options: [
+      { optionLabel: 'A', optionContent: '鐢垫', isCorrect: '1' },
+      { optionLabel: 'B', optionContent: '鍘嬪姏瀹瑰櫒', isCorrect: '1' },
+      { optionLabel: 'C', optionContent: '鏅�氬姙鍏', isCorrect: '0' },
+      { optionLabel: 'D', optionContent: '閿呯倝', isCorrect: '1' },
+    ],
+  },
+  {
+    id: 'demo_q3',
+    questionNo: '260003',
+    questionType: 'single',
+    stem: 'GMP 鐨勫叏绉版槸锛�',
+    score: 20,
+    options: [
+      { optionLabel: 'A', optionContent: '鑽搧鐢熶骇璐ㄩ噺绠$悊瑙勮寖', isCorrect: '1' },
+      { optionLabel: 'B', optionContent: '鑽搧缁忚惀璐ㄩ噺绠$悊瑙勮寖', isCorrect: '0' },
+      { optionLabel: 'C', optionContent: '瀹為獙瀹ょ鐞嗚鑼�', isCorrect: '0' },
+      { optionLabel: 'D', optionContent: '鏂囦欢绠$悊瑙勮寖', isCorrect: '0' },
+    ],
+  },
+];
 
 const store: MyPaperListItem[] = [
   {
@@ -89,48 +128,11 @@
   });
 }
 
-async function buildQuestions(): Promise<OnlineExamQuestionItem[]> {
-  const all = await mockQueryQuestions({ pageSize: 50, currentPage: 1 });
-  const list = (all.list || []).filter((q) => ['single', 'multi', 'judge'].includes(q.questionType));
-  const picked = list.slice(0, 5);
-  const detailed: OnlineExamQuestionItem[] = [];
-  for (const q of picked) {
-    const full = await mockGetQuestion(q.id!);
-    detailed.push({
-      id: full.id!,
-      questionNo: full.questionNo,
-      questionType: full.questionType as 'single' | 'multi' | 'judge',
-      stem: full.stem,
-      score: 20,
-      options: (full.options || []).map((o) => ({
-        optionLabel: o.optionLabel,
-        optionContent: o.optionContent,
-        isCorrect: o.isCorrect,
-      })),
-    });
-  }
-  // mock 棰樹笉澶熸椂琛ョ┖棰橀伩鍏嶆棤娉曞紑鑰�
-  if (!detailed.length) {
-    detailed.push({
-      id: 'demo_q1',
-      questionType: 'judge',
-      stem: '鐗圭浣滀笟浜哄憳蹇呴』鍙栧緱鏈夋晥璧勬牸璇佷功鍚庢柟鍙笂宀椾綔涓氥��',
-      score: 100,
-      options: [
-        { optionLabel: 'T', optionContent: '姝g‘', isCorrect: '1' },
-        { optionLabel: 'F', optionContent: '閿欒', isCorrect: '0' },
-      ],
-    });
-  }
-  return detailed;
-}
-
 export async function mockStartExam(myPaperId: string): Promise<OnlineExamPaper> {
   const row = store.find((x) => x.id === myPaperId);
   if (!row) return Promise.reject(new Error('璇曞嵎涓嶅瓨鍦�'));
   if (row.status === 'submitted') return Promise.reject(new Error('璇ヨ瘯鍗峰凡浜ゅ嵎锛屾棤娉曞啀娆¤�冭瘯'));
 
-  const questions = await buildQuestions();
   const examId = row.examId || `exam_${Date.now()}`;
   row.status = 'doing';
   row.examId = examId;
@@ -142,7 +144,7 @@
     totalScore: row.totalScore,
     passScore: row.passScore,
     durationMin: row.durationMin,
-    questions,
+    questions: DEMO_QUESTIONS.map((q) => ({ ...q, options: q.options.map((o) => ({ ...o })) })),
   });
 }
 

--
Gitblit v1.8.0