Implement verified curriculum, video review, watch sessions, ledger safeguards, and remove demo data

This commit is contained in:
Hamza-Ayed
2026-09-09 17:04:08 +03:00
parent 0dc5df7b5e
commit 5af684a892
49 changed files with 1809 additions and 3005 deletions
+25 -17
View File
@@ -647,16 +647,16 @@ CREATE TABLE IF NOT EXISTS `teacher_reviews` (
`student_id` BIGINT UNSIGNED NOT NULL,
`course_id` BIGINT UNSIGNED DEFAULT NULL,
`lesson_id` BIGINT UNSIGNED DEFAULT NULL,
`rating_overall` DECIMAL(3, 2) NOT NULL DEFAULT 5.00,
`rating_clarity` INT NOT NULL DEFAULT 5,
`rating_response_speed` INT NOT NULL DEFAULT 5,
`rating_socratic_interaction` INT NOT NULL DEFAULT 5,
`rating_overall` DECIMAL(3, 2) NOT NULL,
`rating_clarity` INT NOT NULL,
`rating_response_speed` INT NOT NULL,
`rating_socratic_interaction` INT NOT NULL,
`review_text` TEXT DEFAULT NULL,
`review_weight` DECIMAL(4, 3) NOT NULL DEFAULT 1.000,
`student_watch_percentage` DECIMAL(5, 2) NOT NULL DEFAULT 100.00,
`socratic_accuracy_rate` DECIMAL(5, 2) NOT NULL DEFAULT 100.00,
`student_watch_percentage` DECIMAL(5, 2) NOT NULL DEFAULT 0.00,
`socratic_accuracy_rate` DECIMAL(5, 2) NOT NULL DEFAULT 0.00,
`is_flagged_anomaly` TINYINT(1) NOT NULL DEFAULT 0,
`is_verified` TINYINT(1) NOT NULL DEFAULT 1,
`is_verified` TINYINT(1) NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_tr_teacher` (`teacher_id`),
@@ -670,19 +670,19 @@ CREATE TABLE IF NOT EXISTS `teacher_reviews` (
-- ------------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `teacher_performance_metrics` (
`teacher_id` BIGINT UNSIGNED NOT NULL,
`avg_response_minutes` INT NOT NULL DEFAULT 4,
`response_rate_percentage` DECIMAL(5, 2) NOT NULL DEFAULT 98.50,
`avg_response_minutes` INT NULL DEFAULT NULL,
`response_rate_percentage` DECIMAL(5, 2) NULL DEFAULT NULL,
`active_queue_count` INT UNSIGNED NOT NULL DEFAULT 0,
`total_students_enrolled` INT UNSIGNED NOT NULL DEFAULT 0,
`total_reviews_count` INT UNSIGNED NOT NULL DEFAULT 0,
`raw_avg_rating` DECIMAL(3, 2) NOT NULL DEFAULT 5.00,
`weighted_student_rating` DECIMAL(3, 2) NOT NULL DEFAULT 5.00,
`ai_engagement_score` DECIMAL(5, 2) NOT NULL DEFAULT 96.00,
`sla_speed_score` DECIMAL(5, 2) NOT NULL DEFAULT 98.00,
`mastery_impact_score` DECIMAL(5, 2) NOT NULL DEFAULT 94.00,
`composite_merit_score` DECIMAL(5, 2) NOT NULL DEFAULT 96.50,
`star_equivalent` DECIMAL(3, 2) NOT NULL DEFAULT 4.90,
`reputation_tier` VARCHAR(100) NOT NULL DEFAULT 'معلم نخبوي معتمد 💎',
`raw_avg_rating` DECIMAL(3, 2) NULL DEFAULT NULL,
`weighted_student_rating` DECIMAL(3, 2) NULL DEFAULT NULL,
`ai_engagement_score` DECIMAL(5, 2) NULL DEFAULT NULL,
`sla_speed_score` DECIMAL(5, 2) NULL DEFAULT NULL,
`mastery_impact_score` DECIMAL(5, 2) NULL DEFAULT NULL,
`composite_merit_score` DECIMAL(5, 2) NULL DEFAULT NULL,
`star_equivalent` DECIMAL(3, 2) NULL DEFAULT NULL,
`reputation_tier` VARCHAR(100) NULL DEFAULT NULL,
`last_calculated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`teacher_id`),
CONSTRAINT `fk_tpm_teacher` FOREIGN KEY (`teacher_id`) REFERENCES `teachers` (`id`) ON DELETE CASCADE
@@ -747,3 +747,11 @@ CREATE TABLE IF NOT EXISTS `otp_verifications` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SET FOREIGN_KEY_CHECKS = 1;
-- NEXT-PHASE SCHEMA NOTICE
-- The authoritative additive DDL for curriculum identity, submissions, review,
-- ledger, watch sessions, revenue, English packages, and remediation lives in
-- backend/migrations/20260909_*.sql. Apply it with
-- `php backend/scripts/run_migrations.php`; do not copy those statements here,
-- because duplicated DDL causes the fresh-schema file and production migrations
-- to drift apart.