Files
geograsim/v2-platform/mock/api/teacher/live-status.php
T
Adminator 1e51ef7def Nachtrag: alle bisher untracked Ordner + hängende Änderungen mit-committen
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/
- 12 code-workspace-Files
- STATUS-*.md
- viele M/D/R-Änderungen an bereits getrackten Files
- .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-08 02:27:02 +02:00

45 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../lib/bootstrap.php';
v2_validate_method('GET');
v2_auth_require('teacher');
mock_log('GET /api/teacher/live-status', $_GET ?: []);
// Mock: liest aus dem Mock-Log die letzten Telemetry-Events und baut Status-Snapshot
$logFile = __DIR__ . '/../../uploads/log.jsonl';
$status = [];
if (file_exists($logFile)) {
$lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// letzte ~50 telemetry-Events
$recent = array_slice($lines, -200);
$perStudent = []; // simulieren: Mock-Plattform kennt keinen Student-Bezug per Token
foreach ($recent as $line) {
$e = json_decode($line, true);
if (!$e || ($e['endpoint'] ?? '') !== 'POST /api/telemetry') continue;
$b = $e['body'] ?? [];
$sid = 42; // Mock kennt nur Lena
$perStudent[$sid] = [
'studentId' => $sid, 'displayName' => 'Lena', 'avatarSlug' => 'fuchs-explorer',
'nachteilsausgleich' => false,
'moduleSlug' => $b['moduleSlug'] ?? '?',
'eventType' => $b['type'] ?? '?',
'phase' => $b['phase'] ?? null,
'phaseLabel' => $b['phaseLabel'] ?? null,
'currentScore' => $b['currentScore'] ?? null,
'scoreMax' => $b['scoreMax'] ?? null,
'idleS' => $b['idleS'] ?? null,
'lastTs' => $e['ts'],
'isStuck' => ($b['type'] ?? '') === 'stuck',
];
}
$status = array_values($perStudent);
}
v2_response_ok([
'studentStatus' => $status,
'newEvents' => [],
'maxId' => 0,
'_mock' => 'Live-Status aus mock/uploads/log.jsonl rekonstruiert.',
]);