Implement verified curriculum, video review, watch sessions, ledger safeguards, and remove demo data
This commit is contained in:
@@ -13,12 +13,7 @@ class TeacherController
|
||||
{
|
||||
private static function ensureTeacherColumns(): void
|
||||
{
|
||||
try {
|
||||
Database::query("ALTER TABLE teachers ADD COLUMN grades_taught TEXT DEFAULT NULL");
|
||||
} catch (\Throwable $e) {}
|
||||
try {
|
||||
Database::query("ALTER TABLE teachers ADD COLUMN school_name VARCHAR(255) DEFAULT NULL");
|
||||
} catch (\Throwable $e) {}
|
||||
// Compatibility hook. These columns are installed by migrations.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,6 +103,7 @@ class TeacherController
|
||||
|
||||
$teacher = Database::selectOne("SELECT * FROM teachers WHERE id = ? LIMIT 1", [$teacherId]);
|
||||
|
||||
$metrics = Database::selectOne('SELECT weighted_student_rating, total_reviews_count FROM teacher_performance_metrics WHERE teacher_id = ? LIMIT 1', [$userId]) ?: [];
|
||||
$response->json([
|
||||
'status' => 'success',
|
||||
'message' => 'تم توثيق بيانات المعلم والصفوف والمباحث بنجاح!',
|
||||
@@ -143,14 +139,20 @@ class TeacherController
|
||||
[$userId]
|
||||
)['total'];
|
||||
|
||||
$metrics = Database::selectOne(
|
||||
'SELECT weighted_student_rating, total_reviews_count FROM teacher_performance_metrics WHERE teacher_id = ? LIMIT 1',
|
||||
[$userId]
|
||||
) ?: [];
|
||||
|
||||
$response->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'courses_count' => $coursesCount,
|
||||
'lessons_count' => $lessonsCount,
|
||||
'students_count' => $studentsCount,
|
||||
'rating' => 4.9,
|
||||
'completion_avg' => 87.5
|
||||
'rating' => isset($metrics['weighted_student_rating']) ? (float)$metrics['weighted_student_rating'] : null,
|
||||
'rating_count' => (int)($metrics['total_reviews_count'] ?? 0),
|
||||
'completion_avg' => null
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -413,6 +415,43 @@ class TeacherController
|
||||
return;
|
||||
}
|
||||
|
||||
// Revenue sharing is being rebuilt around provider-backed ledger entries
|
||||
// and eligible watch minutes. Do not turn course prices, platform sales,
|
||||
// or legacy payout rows into a teacher wallet in the meantime.
|
||||
$courses = Database::select(
|
||||
"SELECT c.id, c.title as course_title, c.price_jod, c.is_published,
|
||||
COUNT(l.id) as lessons_total
|
||||
FROM courses c
|
||||
LEFT JOIN lessons l ON l.course_id = c.id
|
||||
WHERE c.teacher_id = ?
|
||||
GROUP BY c.id
|
||||
ORDER BY c.id ASC",
|
||||
[$teacherId]
|
||||
);
|
||||
$response->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'financial_status' => 'unavailable',
|
||||
'financial_message' => 'الأرباح والسحب متوقفان حتى اكتمال دفتر الاستحقاق وربط مزود الدفع.',
|
||||
'audience_breakdown' => [
|
||||
'institutional_students' => ['count' => 0],
|
||||
'marketplace_students' => ['count' => 0],
|
||||
],
|
||||
'course_price_jod' => null,
|
||||
'gross_revenue_jod' => null,
|
||||
'revenue_split' => null,
|
||||
'wallet' => [
|
||||
'available_balance_jod' => null,
|
||||
'pending_clearance_jod' => null,
|
||||
'total_withdrawn_jod' => null,
|
||||
'cliq_payout_alias' => '',
|
||||
'recent_payouts' => [],
|
||||
],
|
||||
'courses' => $courses,
|
||||
],
|
||||
]);
|
||||
return;
|
||||
|
||||
// 1. Real Student Counts from Database
|
||||
$totalStudents = (int)(Database::selectOne("SELECT COUNT(*) as c FROM students")['c'] ?? 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user