added submission history, data insights, download all functionality

This commit is contained in:
2026-06-01 12:54:56 +02:00
parent 9a6fa22d84
commit bee7b74e53
19 changed files with 1863 additions and 110 deletions

28
handlers/coaches.php Normal file
View File

@ -0,0 +1,28 @@
<?php
$tokenRec = require_valid_token_web();
require_role(['admin', 'supervisor'], $tokenRec);
require_once __DIR__ . '/../lib/analytics.php';
if ($method !== 'GET') {
json_error('METHOD_NOT_ALLOWED', 'Method not allowed', 405);
}
[$pdo, $tmpDb, $lockFp] = qdb_open(false);
try {
$coachID = trim((string)($_GET['coachID'] ?? ''));
if ($coachID !== '' && !empty($_GET['recent'])) {
$recent = qdb_coach_recent_submissions($pdo, $tokenRec, $coachID);
qdb_discard($tmpDb, $lockFp);
json_success(['submissions' => $recent]);
}
$coaches = qdb_coach_activity_list($pdo, $tokenRec);
qdb_discard($tmpDb, $lockFp);
json_success(['coaches' => $coaches]);
} catch (Throwable $e) {
qdb_discard($tmpDb, $lockFp);
error_log('coaches GET: ' . $e->getMessage());
json_error('SERVER_ERROR', 'Server error', 500);
}