<?php
declare(strict_types=1);
require __DIR__ . '/bootstrap.php';

require_method('GET');
require_admin();

$course = active_course();
$pdo = db();

json_response([
    'students' => (int) $pdo->query("SELECT COUNT(*) FROM users WHERE role = 'student'")->fetchColumn(),
    'enrollments' => (int) $pdo->query('SELECT COUNT(*) FROM enrollments')->fetchColumn(),
    'submissions' => (int) $pdo->query('SELECT COUNT(*) FROM assignment_submissions')->fetchColumn(),
    'certificates' => (int) $pdo->query('SELECT COUNT(*) FROM certificates')->fetchColumn(),
    'course' => $course,
]);
