feat: Real-time Workerman gateway + Multi-level exam hierarchy (lesson, unit, final, AI adaptive) and student mastery tracking
This commit is contained in:
+111
-12
@@ -159,49 +159,148 @@ CREATE TABLE `lessons` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 8. Table: quizzes (الكويزات داخل الفيديو - Socratic Checkpoints)
|
||||
-- 8. Table: exams (الامتحانات الشاملة: درس، وحدة، فصل، ومحاكاة وزاري)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `quizzes` (
|
||||
CREATE TABLE `exams` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`lesson_id` BIGINT UNSIGNED NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`course_id` BIGINT UNSIGNED NOT NULL,
|
||||
`lesson_id` BIGINT UNSIGNED DEFAULT NULL,
|
||||
`created_by_id` BIGINT UNSIGNED DEFAULT NULL,
|
||||
`creator_type` ENUM('teacher', 'ai_adaptive', 'ministry_standard') NOT NULL DEFAULT 'teacher',
|
||||
`scope` ENUM('in_video_checkpoint', 'lesson_exam', 'unit_exam', 'semester_final') NOT NULL DEFAULT 'lesson_exam',
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`description` TEXT DEFAULT NULL,
|
||||
`duration_minutes` INT UNSIGNED NOT NULL DEFAULT 30,
|
||||
`timestamp_seconds` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`is_mandatory` TINYINT(1) NOT NULL DEFAULT 1,
|
||||
`rewind_on_fail_seconds` INT UNSIGNED NOT NULL DEFAULT 45,
|
||||
`passing_percentage` DECIMAL(5,2) NOT NULL DEFAULT 60.00,
|
||||
`total_points` INT UNSIGNED NOT NULL DEFAULT 100,
|
||||
`is_mandatory` TINYINT(1) NOT NULL DEFAULT 1,
|
||||
`is_published` TINYINT(1) NOT NULL DEFAULT 1,
|
||||
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_quizzes_lesson` (`lesson_id`),
|
||||
CONSTRAINT `fk_quizzes_lesson` FOREIGN KEY (`lesson_id`) REFERENCES `lessons` (`id`) ON DELETE CASCADE
|
||||
UNIQUE KEY `idx_exams_uuid` (`uuid`),
|
||||
KEY `idx_exams_course` (`course_id`),
|
||||
KEY `idx_exams_lesson` (`lesson_id`),
|
||||
KEY `idx_exams_scope` (`scope`),
|
||||
KEY `idx_exams_creator` (`creator_type`),
|
||||
CONSTRAINT `fk_exams_course` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_exams_lesson` FOREIGN KEY (`lesson_id`) REFERENCES `lessons` (`id`) ON DELETE SET NULL,
|
||||
CONSTRAINT `fk_exams_creator` FOREIGN KEY (`created_by_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 9. Table: questions (الأسئلة)
|
||||
-- 9. Table: questions (الأسئلة والتحليل المعرفي للذكاء الاصطناعي)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `questions` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`quiz_id` BIGINT UNSIGNED NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`exam_id` BIGINT UNSIGNED NOT NULL,
|
||||
`question_text` TEXT NOT NULL,
|
||||
`question_type` ENUM('multiple_choice', 'true_false', 'short_answer') NOT NULL DEFAULT 'multiple_choice',
|
||||
`bloom_taxonomy` ENUM('recall', 'comprehension', 'application', 'analysis') NOT NULL DEFAULT 'comprehension',
|
||||
`topic_tag` VARCHAR(150) DEFAULT NULL,
|
||||
`points` INT UNSIGNED NOT NULL DEFAULT 10,
|
||||
`explanation_text` TEXT DEFAULT NULL,
|
||||
`points` INT UNSIGNED NOT NULL DEFAULT 1,
|
||||
`ai_hint` TEXT DEFAULT NULL,
|
||||
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_questions_quiz` (`quiz_id`),
|
||||
CONSTRAINT `fk_questions_quiz` FOREIGN KEY (`quiz_id`) REFERENCES `quizzes` (`id`) ON DELETE CASCADE
|
||||
UNIQUE KEY `idx_questions_uuid` (`uuid`),
|
||||
KEY `idx_questions_exam` (`exam_id`),
|
||||
KEY `idx_questions_topic` (`topic_tag`),
|
||||
CONSTRAINT `fk_questions_exam` FOREIGN KEY (`exam_id`) REFERENCES `exams` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 10. Table: question_options (خيارات الإجابة)
|
||||
-- 10. Table: question_options (خيارات الإجابة والتغذية الراجعة)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `question_options` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`question_id` BIGINT UNSIGNED NOT NULL,
|
||||
`option_text` TEXT NOT NULL,
|
||||
`is_correct` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`feedback_text` TEXT DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_options_question` (`question_id`),
|
||||
CONSTRAINT `fk_options_question` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 11. Table: exam_attempts (محاولات ونتائج الامتحانات وتحليل الذكاء الاصطناعي)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `exam_attempts` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`student_id` BIGINT UNSIGNED NOT NULL,
|
||||
`exam_id` BIGINT UNSIGNED NOT NULL,
|
||||
`attempt_number` INT UNSIGNED NOT NULL DEFAULT 1,
|
||||
`score` DECIMAL(6,2) NOT NULL DEFAULT 0.00,
|
||||
`total_score` DECIMAL(6,2) NOT NULL DEFAULT 100.00,
|
||||
`percentage` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
||||
`status` ENUM('passed', 'failed', 'needs_remediation', 'in_progress') NOT NULL DEFAULT 'in_progress',
|
||||
`time_spent_seconds` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`weak_topics_json` JSON DEFAULT NULL,
|
||||
`ai_diagnostic_report` TEXT DEFAULT NULL,
|
||||
`completed_at` TIMESTAMP NULL DEFAULT NULL,
|
||||
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_attempts_uuid` (`uuid`),
|
||||
KEY `idx_attempts_student_exam` (`student_id`, `exam_id`),
|
||||
KEY `idx_attempts_status` (`status`),
|
||||
CONSTRAINT `fk_attempts_student` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_attempts_exam` FOREIGN KEY (`exam_id`) REFERENCES `exams` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 12. Table: student_question_answers (تفاصيل إجابات الطالب على كل سؤال)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `student_question_answers` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`attempt_id` BIGINT UNSIGNED NOT NULL,
|
||||
`student_id` BIGINT UNSIGNED NOT NULL,
|
||||
`question_id` BIGINT UNSIGNED NOT NULL,
|
||||
`selected_option_id` BIGINT UNSIGNED DEFAULT NULL,
|
||||
`text_answer` TEXT DEFAULT NULL,
|
||||
`is_correct` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`points_awarded` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
||||
`time_spent_seconds` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_sqa_attempt` (`attempt_id`),
|
||||
KEY `idx_sqa_student_question` (`student_id`, `question_id`),
|
||||
CONSTRAINT `fk_sqa_attempt` FOREIGN KEY (`attempt_id`) REFERENCES `exam_attempts` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_sqa_student` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_sqa_question` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_sqa_option` FOREIGN KEY (`selected_option_id`) REFERENCES `question_options` (`id`) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 13. Table: student_mastery_analytics (مؤشر الفهم التراكمي والجاهزية للوزاري)
|
||||
-- ------------------------------------------------------------------------------
|
||||
CREATE TABLE `student_mastery_analytics` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`student_id` BIGINT UNSIGNED NOT NULL,
|
||||
`course_id` BIGINT UNSIGNED NOT NULL,
|
||||
`subject_id` BIGINT UNSIGNED NOT NULL,
|
||||
`mastery_percentage` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
||||
`tawjihi_readiness_score` DECIMAL(5,2) NOT NULL DEFAULT 0.00,
|
||||
`lessons_completed_count` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`exams_passed_count` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`exams_total_count` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`weak_concepts_summary` TEXT DEFAULT NULL,
|
||||
`ai_recommendations` TEXT DEFAULT NULL,
|
||||
`guardian_last_notified_at` TIMESTAMP NULL DEFAULT NULL,
|
||||
`updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_mastery_student_course` (`student_id`, `course_id`),
|
||||
KEY `idx_mastery_subject` (`subject_id`),
|
||||
CONSTRAINT `fk_mastery_student` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_mastery_course` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_mastery_subject` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- 11. Table: lesson_progress (سجل متابعة ونبض المشاهدة)
|
||||
-- ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user