Files
Nexus_Edu/database/seed.sql
2025-11-28 19:23:19 +08:00

122 lines
7.8 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =============================================
-- EduNexus Pro - 初始化数据脚本
-- 用于开发和测试
-- =============================================
SET NAMES utf8mb4;
-- =============================================
-- 1. 插入示例学科
-- =============================================
INSERT INTO `subjects` (`id`, `name`, `code`, `icon`, `created_by`, `updated_by`) VALUES
('sub-math', '数学', 'MATH', '📐', 'system', 'system'),
('sub-chinese', '语文', 'CHINESE', '📖', 'system', 'system'),
('sub-english', '英语', 'ENGLISH', '🌍', 'system', 'system'),
('sub-physics', '物理', 'PHYSICS', '⚛️', 'system', 'system'),
('sub-chemistry', '化学', 'CHEMISTRY', '🧪', 'system', 'system');
-- =============================================
-- 2. 插入示例学校和组织结构
-- =============================================
INSERT INTO `schools` (`id`, `name`, `region_code`, `address`, `created_by`, `updated_by`) VALUES
('school-1', '示范中学', '110000', '北京市海淀区示范路1号', 'system', 'system');
INSERT INTO `grades` (`id`, `school_id`, `name`, `sort_order`, `enrollment_year`, `created_by`, `updated_by`) VALUES
('grade-1', 'school-1', '初一年级', 1, 2024, 'system', 'system'),
('grade-2', 'school-1', '初二年级', 2, 2023, 'system', 'system'),
('grade-3', 'school-1', '初三年级', 3, 2022, 'system', 'system');
--=============================================
-- 3. 插入示例用户(密码: password123实际应用需要hash
-- =============================================
INSERT INTO `application_users` (`id`, `real_name`, `student_id`, `gender`, `current_school_id`, `account_status`, `email`, `phone`, `password_hash`, `created_by`, `updated_by`) VALUES
('user-teacher-1', '张老师', NULL, 'Male', 'school-1', 'Active', 'teacher@example.com', '13800138000', '$2b$10$example_hash', 'system', 'system'),
('user-student-1', '王小明', 'S20240001', 'Male', 'school-1', 'Active', 'student1@example.com', '13800138001', '$2b$10$example_hash', 'system', 'system'),
('user-student-2', '李小红', 'S20240002', 'Female', 'school-1', 'Active', 'student2@example.com', '13800138002', '$2b$10$example_hash', 'system', 'system');
-- =============================================
-- 4. 插入示例班级
-- =============================================
INSERT INTO `classes` (`id`, `grade_id`, `name`, `invite_code`, `head_teacher_id`, `created_by`, `updated_by`) VALUES
('class-1', 'grade-1', '初一(1)班', 'ABC123', 'user-teacher-1', 'system', 'system');
INSERT INTO `class_members` (`id`, `class_id`, `user_id`, `role_in_class`, `created_by`, `updated_by`) VALUES
('cm-1', 'class-1', 'user-teacher-1', 'Teacher', 'system', 'system'),
('cm-2', 'class-1', 'user-student-1', 'Student', 'system', 'system'),
('cm-3', 'class-1', 'user-student-2', 'Student', 'system', 'system');
-- =============================================
-- 5. 插入示例教材
-- =============================================
INSERT INTO `textbooks` (`id`, `subject_id`, `name`, `publisher`, `version_year`, `cover_url`, `created_by`, `updated_by`) VALUES
('textbook-1', 'sub-math', '义务教育教科书·数学(七年级上册)', '人民教育出版社', '2024', 'https://placehold.co/300x400/007AFF/ffffff?text=Math', 'system', 'system');
INSERT INTO `textbook_units` (`id`, `textbook_id`, `name`, `sort_order`, `created_by`, `updated_by`) VALUES
('unit-1', 'textbook-1', '第一章 有理数', 1, 'system', 'system'),
('unit-2', 'textbook-1', '第二章 整式的加减', 2, 'system', 'system');
INSERT INTO `textbook_lessons` (`id`, `unit_id`, `name`, `sort_order`, `created_by`, `updated_by`) VALUES
('lesson-1-1', 'unit-1', '1.1 正数和负数', 1, 'system', 'system'),
('lesson-1-2', 'unit-1', '1.2 有理数', 2, 'system', 'system');
INSERT INTO `knowledge_points` (`id`, `lesson_id`, `parent_knowledge_point_id`, `name`, `difficulty`, `description`, `created_by`, `updated_by`) VALUES
('kp-1', 'lesson-1-1', NULL, '正数的概念', 1, '大于0的数叫做正数', 'system', 'system'),
('kp-2', 'lesson-1-1', NULL, '负数的概念', 1, '小于0的数叫做负数', 'system', 'system'),
('kp-3', 'lesson-1-2', NULL, '有理数的分类', 2, '有理数包括整数和分数', 'system', 'system');
-- =============================================
-- 6. 插入示例题目
-- =============================================
INSERT INTO `questions` (`id`, `subject_id`, `content`, `options_config`, `question_type`, `answer`, `explanation`, `difficulty`, `created_by`, `updated_by`) VALUES
('q-1', 'sub-math', '<p>下列各数中,是负数的是(  )</p>', '{"options": ["A. 0", "B. -1", "C. 1", "D. 2"]}', 'SingleChoice', 'B', '<p>负数是小于0的数所以答案是B</p>', 1, 'system', 'system'),
('q-2', 'sub-math', '<p>|-5| = _____</p>', NULL, 'FillBlank', '5', '<p>绝对值表示数轴上的点到原点的距离</p>', 2, 'system', 'system'),
('q-3', 'sub-math', '<p>计算:(-3) + 5 = ?</p>', NULL, 'Subjective', '2', '<p>负数加正数,按绝对值相减,取绝对值较大数的符号</p>', 2, 'system', 'system');
INSERT INTO `question_knowledge` (`id`, `question_id`, `knowledge_point_id`, `weight`, `created_by`, `updated_by`) VALUES
('qk-1', 'q-1', 'kp-2', 100, 'system', 'system'),
('qk-2', 'q-2', 'kp-3', 80, 'system', 'system');
-- =============================================
-- 7. 插入示例试卷
-- =============================================
INSERT INTO `exams` (`id`, `subject_id`, `title`, `total_score`, `suggested_duration`, `status`, `created_by`, `updated_by`) VALUES
('exam-1', 'sub-math', '第一章单元测试', 100, 90, 'Published', 'user-teacher-1', 'user-teacher-1');
-- 试卷节点(树形结构示例)
INSERT INTO `exam_nodes` (`id`, `exam_id`, `parent_node_id`, `node_type`, `question_id`, `title`, `description`, `score`, `sort_order`, `created_by`, `updated_by`) VALUES
('node-1', 'exam-1', NULL, 'Group', NULL, '第一部分:选择题', '本大题共2小题每小题5分共10分', 10, 1, 'user-teacher-1', 'user-teacher-1'),
('node-1-1', 'exam-1', 'node-1', 'Question', 'q-1', NULL, NULL, 5, 1, 'user-teacher-1', 'user-teacher-1'),
('node-1-2', 'exam-1', 'node-1', 'Question', 'q-2', NULL, NULL, 5, 2, 'user-teacher-1', 'user-teacher-1'),
('node-2', 'exam-1', NULL, 'Group', NULL, '第二部分:解答题', '需要写出完整步骤', 90, 2, 'user-teacher-1', 'user-teacher-1'),
('node-2-1', 'exam-1', 'node-2', 'Question', 'q-3', NULL, NULL, 90, 1, 'user-teacher-1', 'user-teacher-1');
-- =============================================
-- 8. 插入示例作业
-- =============================================
INSERT INTO `assignments` (`id`, `exam_id`, `class_id`, `title`, `start_time`, `end_time`, `allow_late_submission`, `auto_score_enabled`, `created_by`, `updated_by`) VALUES
('assignment-1', 'exam-1', 'class-1', '第一章课后作业', '2024-11-20 08:00:00', '2024-11-27 23:59:59', TRUE, TRUE, 'user-teacher-1', 'user-teacher-1');
-- 插入学生提交记录
INSERT INTO `student_submissions` (`id`, `assignment_id`, `student_id`, `submission_status`, `submit_time`, `time_spent_seconds`, `total_score`, `created_by`, `updated_by`) VALUES
('sub-1', 'assignment-1', 'user-student-1', 'Graded', '2024-11-25 10:30:00', 1800, 95, 'user-student-1', 'user-teacher-1');
-- 插入答题详情
INSERT INTO `submission_details` (`id`, `submission_id`, `exam_node_id`, `student_answer`, `score`, `judgement`, `teacher_comment`, `created_by`, `updated_by`) VALUES
('sd-1', 'sub-1', 'node-1-1', 'B', 5, 'Correct', '正确', 'user-student-1', 'user-teacher-1'),
('sd-2', 'sub-1', 'node-1-2', '5', 5, 'Correct', '正确', 'user-student-1', 'user-teacher-1'),
('sd-3', 'sub-1', 'node-2-1', '(-3) + 5 = 5 - 3 = 2', 85, 'Partial', '步骤正确,但表述可以更规范', 'user-student-1', 'user-teacher-1');
-- =============================================
-- 完成
-- =============================================
SELECT '初始化数据插入完成' AS Status;