refactor: RBAC权限系统重构 + UI组件拆分 + 测试修复 + 架构文档
Some checks failed
CI / build-deploy (push) Has been cancelled
Some checks failed
CI / build-deploy (push) Has been cancelled
- RBAC: 新增30个权限点、DataScope行级权限、requirePermission守卫,所有57+ Server Action接入权限校验 - UI拆分: exam-form(1623行→11文件)、textbook-reader(744行→7文件),均降至300行以内 - 测试: 新增5个单元测试文件(19用例),修复4个集成测试文件(38用例全部通过) - 架构文档: 新增架构影响地图(004/005)、标准功能清单(006)、差距审计报告(007) - 项目规则: 架构图优先规则,改码必同步图 - 安全: rehype-sanitize净化、AES加密API Key、权限路由守卫 - 无障碍: skip-link、aria-label、prefers-reduced-motion - 性能: next/font优化、next/image、代码分割
This commit is contained in:
102
src/mocks/exam-data.ts
Normal file
102
src/mocks/exam-data.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { Exam, ExamSubmission } from "../modules/exams/types"
|
||||
|
||||
export let MOCK_EXAMS: Exam[] = [
|
||||
{
|
||||
id: "exam_001",
|
||||
title: "Algebra Midterm",
|
||||
subject: "Mathematics",
|
||||
grade: "Grade 10",
|
||||
status: "draft",
|
||||
difficulty: 3,
|
||||
totalScore: 100,
|
||||
durationMin: 90,
|
||||
questionCount: 25,
|
||||
scheduledAt: undefined,
|
||||
createdAt: new Date().toISOString(),
|
||||
tags: ["Algebra", "Functions"],
|
||||
},
|
||||
{
|
||||
id: "exam_002",
|
||||
title: "Physics Mechanics Quiz",
|
||||
subject: "Physics",
|
||||
grade: "Grade 11",
|
||||
status: "published",
|
||||
difficulty: 4,
|
||||
totalScore: 50,
|
||||
durationMin: 45,
|
||||
questionCount: 15,
|
||||
scheduledAt: new Date(Date.now() + 86400000).toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
tags: ["Mechanics", "Kinematics"],
|
||||
},
|
||||
{
|
||||
id: "exam_003",
|
||||
title: "English Reading Comprehension",
|
||||
subject: "English",
|
||||
grade: "Grade 12",
|
||||
status: "published",
|
||||
difficulty: 2,
|
||||
totalScore: 80,
|
||||
durationMin: 60,
|
||||
questionCount: 20,
|
||||
scheduledAt: new Date(Date.now() + 2 * 86400000).toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
tags: ["Reading", "Vocabulary"],
|
||||
},
|
||||
{
|
||||
id: "exam_004",
|
||||
title: "Chemistry Final",
|
||||
subject: "Chemistry",
|
||||
grade: "Grade 12",
|
||||
status: "archived",
|
||||
difficulty: 5,
|
||||
totalScore: 120,
|
||||
durationMin: 120,
|
||||
questionCount: 40,
|
||||
scheduledAt: new Date(Date.now() - 30 * 86400000).toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
tags: ["Organic", "Inorganic"],
|
||||
},
|
||||
{
|
||||
id: "exam_005",
|
||||
title: "Geometry Chapter Test",
|
||||
subject: "Mathematics",
|
||||
grade: "Grade 9",
|
||||
status: "published",
|
||||
difficulty: 3,
|
||||
totalScore: 60,
|
||||
durationMin: 50,
|
||||
questionCount: 18,
|
||||
scheduledAt: new Date(Date.now() + 3 * 86400000).toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
tags: ["Geometry", "Triangles"],
|
||||
},
|
||||
]
|
||||
|
||||
export const MOCK_SUBMISSIONS: ExamSubmission[] = [
|
||||
{
|
||||
id: "sub_001",
|
||||
examId: "exam_002",
|
||||
examTitle: "Physics Mechanics Quiz",
|
||||
studentName: "Alice Zhang",
|
||||
submittedAt: new Date().toISOString(),
|
||||
status: "pending",
|
||||
},
|
||||
{
|
||||
id: "sub_002",
|
||||
examId: "exam_003",
|
||||
examTitle: "English Reading Comprehension",
|
||||
studentName: "Bob Li",
|
||||
submittedAt: new Date().toISOString(),
|
||||
score: 72,
|
||||
status: "graded",
|
||||
},
|
||||
]
|
||||
|
||||
export function addMockExam(exam: Exam) {
|
||||
MOCK_EXAMS = [exam, ...MOCK_EXAMS]
|
||||
}
|
||||
|
||||
export function updateMockExam(id: string, updates: Partial<Exam>) {
|
||||
MOCK_EXAMS = MOCK_EXAMS.map((e) => (e.id === id ? { ...e, ...updates } : e))
|
||||
}
|
||||
124
src/mocks/question-data.ts
Normal file
124
src/mocks/question-data.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import { Question } from "../modules/questions/types";
|
||||
|
||||
export const MOCK_QUESTIONS: Question[] = [
|
||||
{
|
||||
id: "q-001",
|
||||
content: "What is the capital of France?",
|
||||
type: "single_choice",
|
||||
difficulty: 1,
|
||||
createdAt: new Date("2023-11-01"),
|
||||
updatedAt: new Date("2023-11-01"),
|
||||
author: { id: "u-1", name: "Alice Teacher", image: null },
|
||||
knowledgePoints: [{ id: "kp-1", name: "Geography" }, { id: "kp-2", name: "Europe" }],
|
||||
},
|
||||
{
|
||||
id: "q-002",
|
||||
content: "Explain the theory of relativity in simple terms.",
|
||||
type: "text",
|
||||
difficulty: 5,
|
||||
createdAt: new Date("2023-11-02"),
|
||||
updatedAt: new Date("2023-11-02"),
|
||||
author: { id: "u-2", name: "Bob Physicist", image: null },
|
||||
knowledgePoints: [{ id: "kp-3", name: "Physics" }],
|
||||
},
|
||||
{
|
||||
id: "q-003",
|
||||
content: "True or False: The earth is flat.",
|
||||
type: "judgment",
|
||||
difficulty: 1,
|
||||
createdAt: new Date("2023-11-03"),
|
||||
updatedAt: new Date("2023-11-03"),
|
||||
author: { id: "u-1", name: "Alice Teacher", image: null },
|
||||
knowledgePoints: [{ id: "kp-1", name: "Geography" }],
|
||||
},
|
||||
{
|
||||
id: "q-004",
|
||||
content: "Select all prime numbers below 10.",
|
||||
type: "multiple_choice",
|
||||
difficulty: 2,
|
||||
createdAt: new Date("2023-11-04"),
|
||||
updatedAt: new Date("2023-11-04"),
|
||||
author: { id: "u-3", name: "Charlie Math", image: null },
|
||||
knowledgePoints: [{ id: "kp-4", name: "Math" }],
|
||||
},
|
||||
{
|
||||
id: "q-005",
|
||||
content: "Write a function to reverse a string in JavaScript.",
|
||||
type: "text",
|
||||
difficulty: 3,
|
||||
createdAt: new Date("2023-11-05"),
|
||||
updatedAt: new Date("2023-11-05"),
|
||||
author: { id: "u-4", name: "Dave Coder", image: null },
|
||||
knowledgePoints: [{ id: "kp-5", name: "Programming" }, { id: "kp-6", name: "JavaScript" }],
|
||||
},
|
||||
{
|
||||
id: "q-006",
|
||||
content: "Which of the following are fruits? (Apple, Carrot, Banana, Potato)",
|
||||
type: "multiple_choice",
|
||||
difficulty: 1,
|
||||
createdAt: new Date("2023-11-06"),
|
||||
updatedAt: new Date("2023-11-06"),
|
||||
author: { id: "u-1", name: "Alice Teacher", image: null },
|
||||
knowledgePoints: [{ id: "kp-7", name: "Biology" }],
|
||||
},
|
||||
{
|
||||
id: "q-007",
|
||||
content: "Water boils at 100 degrees Celsius at sea level.",
|
||||
type: "judgment",
|
||||
difficulty: 2,
|
||||
createdAt: new Date("2023-11-07"),
|
||||
updatedAt: new Date("2023-11-07"),
|
||||
author: { id: "u-2", name: "Bob Physicist", image: null },
|
||||
knowledgePoints: [{ id: "kp-3", name: "Physics" }],
|
||||
},
|
||||
{
|
||||
id: "q-008",
|
||||
content: "What is the powerhouse of the cell?",
|
||||
type: "single_choice",
|
||||
difficulty: 2,
|
||||
createdAt: new Date("2023-11-08"),
|
||||
updatedAt: new Date("2023-11-08"),
|
||||
author: { id: "u-5", name: "Eve Biologist", image: null },
|
||||
knowledgePoints: [{ id: "kp-7", name: "Biology" }],
|
||||
},
|
||||
{
|
||||
id: "q-009",
|
||||
content: "Solve for x: 2x + 5 = 15",
|
||||
type: "single_choice",
|
||||
difficulty: 2,
|
||||
createdAt: new Date("2023-11-09"),
|
||||
updatedAt: new Date("2023-11-09"),
|
||||
author: { id: "u-3", name: "Charlie Math", image: null },
|
||||
knowledgePoints: [{ id: "kp-4", name: "Math" }],
|
||||
},
|
||||
{
|
||||
id: "q-010",
|
||||
content: "Describe the impact of the Industrial Revolution.",
|
||||
type: "text",
|
||||
difficulty: 4,
|
||||
createdAt: new Date("2023-11-10"),
|
||||
updatedAt: new Date("2023-11-10"),
|
||||
author: { id: "u-6", name: "Frank Historian", image: null },
|
||||
knowledgePoints: [{ id: "kp-8", name: "History" }],
|
||||
},
|
||||
{
|
||||
id: "q-011",
|
||||
content: "Light travels faster than sound.",
|
||||
type: "judgment",
|
||||
difficulty: 1,
|
||||
createdAt: new Date("2023-11-11"),
|
||||
updatedAt: new Date("2023-11-11"),
|
||||
author: { id: "u-2", name: "Bob Physicist", image: null },
|
||||
knowledgePoints: [{ id: "kp-3", name: "Physics" }],
|
||||
},
|
||||
{
|
||||
id: "q-012",
|
||||
content: "Which element has the chemical symbol 'O'?",
|
||||
type: "single_choice",
|
||||
difficulty: 1,
|
||||
createdAt: new Date("2023-11-12"),
|
||||
updatedAt: new Date("2023-11-12"),
|
||||
author: { id: "u-7", name: "Grace Chemist", image: null },
|
||||
knowledgePoints: [{ id: "kp-9", name: "Chemistry" }],
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user