Update Saqel Platform: 2026-08-28 15:13:58
This commit is contained in:
@@ -39,8 +39,8 @@ class TeacherRatingService
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_teacher_reviews (teacher_id),
|
||||
INDEX idx_student_reviews (student_id),
|
||||
CONSTRAINT fk_tr_teacher FOREIGN KEY (teacher_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_tr_student FOREIGN KEY (student_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
CONSTRAINT fk_tr_teacher FOREIGN KEY (teacher_id) REFERENCES teachers(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_tr_student FOREIGN KEY (student_id) REFERENCES students(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
|
||||
@@ -66,7 +66,7 @@ class TeacherRatingService
|
||||
star_equivalent DECIMAL(3, 2) DEFAULT 4.90,
|
||||
reputation_tier VARCHAR(100) DEFAULT 'معلم نخبوي معتمد 💎',
|
||||
last_calculated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_tpm_teacher FOREIGN KEY (teacher_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
CONSTRAINT fk_tpm_teacher FOREIGN KEY (teacher_id) REFERENCES teachers(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
");
|
||||
}
|
||||
@@ -266,7 +266,7 @@ class TeacherRatingService
|
||||
}
|
||||
|
||||
// Count enrolled students
|
||||
$studentsCount = (int)(Database::selectOne("SELECT COUNT(*) as cnt FROM users WHERE role = 'student'")['cnt'] ?? 0);
|
||||
$studentsCount = (int)(Database::selectOne("SELECT COUNT(*) as cnt FROM students")['cnt'] ?? 0);
|
||||
|
||||
// Upsert into teacher_performance_metrics
|
||||
Database::query(
|
||||
@@ -419,18 +419,16 @@ class TeacherRatingService
|
||||
self::ensureSchema();
|
||||
|
||||
$teachers = Database::select(
|
||||
"SELECT u.id, u.full_name, u.phone_number,
|
||||
tp.specialization, tp.bio,
|
||||
"SELECT t.id, t.full_name, t.specialization, t.bio,
|
||||
COALESCE(m.avg_response_minutes, 3) as avg_response_minutes,
|
||||
COALESCE(m.response_rate_percentage, 99.0) as response_rate_percentage,
|
||||
COALESCE(m.composite_merit_score, 96.50) as composite_merit_score,
|
||||
COALESCE(m.star_equivalent, 4.90) as star_equivalent,
|
||||
COALESCE(m.reputation_tier, 'معلم نخبوي معتمد 💎') as reputation_tier,
|
||||
(SELECT COUNT(*) FROM lessons WHERE course_id IN (SELECT id FROM courses WHERE teacher_id = u.id)) as lessons_count
|
||||
FROM users u
|
||||
LEFT JOIN teacher_profiles tp ON u.id = tp.user_id
|
||||
LEFT JOIN teacher_performance_metrics m ON u.id = m.teacher_id
|
||||
WHERE u.role = 'teacher'
|
||||
(SELECT COUNT(*) FROM lessons WHERE course_id IN (SELECT id FROM courses WHERE teacher_id = t.id)) as lessons_count
|
||||
FROM teachers t
|
||||
LEFT JOIN teacher_performance_metrics m ON t.id = m.teacher_id
|
||||
WHERE t.is_marketplace_public = 1
|
||||
ORDER BY " . ($sortBy === 'fastest' ? "COALESCE(m.avg_response_minutes, 10) ASC" : "COALESCE(m.composite_merit_score, 90.00) DESC")
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user