Atlas: Live-View-Feature + Submit-Bug-Fixes + Admin-Styleguide
- Neuer API-Endpoint /api/live (heartbeat / spectator) + DB-Tabelle live_sessions + class_modules.paused-Spalte - Plattform-Live-Client (assets/js/live-client.js): Heartbeat, Pause-Overlay, Spectator-Mode bei ?view=teacher - ggs_inject_live() in _scripts.php als Helper, in alle 11 Sim-Wrapper integriert - Lehrer-Cockpit: tabellarische Klassen-Live-Ansicht pro Sim, Pause-Toggle, blinkender Tab-Indikator wenn aktive Sessions - Submit-Bug erschlagen: progress.php hat jetzt submit_assessment- und reflection-Action; saves.php akzeptiert beide Key-Konventionen; alle Direkt-Pfad-API-Files mit require_once-Bootstrap - Avatar-Default: zufaelliger DALL-E-Avatar fuer neue Schueler:innen - Admin-Styleguide-Seite mit Bildstil, Farb-Tokens, Layout, iPad-Pattern - Klima 2D + 3D: GGS_LIVE_STATE-Hook, Klima 2D zusaetzlich skipResume fuer Klassenaufgaben-Reset - Test-Lehrer Jakob + 3 Schueler:innen lokal + auf Live angelegt - Rundbriefe an alle Sim-Instanzen + Submit-Briefe an sonnensystem, busfahrt, energiemanager + Glossar-Anfrage zu Grundriess - Status-Uebergabe in _inbox/zentrale/_status.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,40 @@ function injectSessionContext(): void {
|
||||
echo '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE) . ';</script>' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Plattform-Live-Client in eine Sim-Render-HTML einfügen.
|
||||
*
|
||||
* Stellt sicher, dass `window.__GGS__` mit `sessionId`, `simId`, `baseUrl`,
|
||||
* `basePath`, `apiUrl` belegt ist (Sim-eigene Werte gewinnen) und lädt
|
||||
* danach `assets/js/live-client.js`. Der Live-Client kümmert sich dann um
|
||||
* Heartbeat / Pause-Polling / Spectator-Mode.
|
||||
*
|
||||
* In jedem Sim-Wrapper kurz vor `echo $html` aufrufen:
|
||||
* $html = ggs_inject_live($html, 'logistik');
|
||||
*/
|
||||
function ggs_inject_live(string $html, string $simId): string {
|
||||
$bp = BASE_PATH;
|
||||
$bu = BASE_URL;
|
||||
$sid = Session::studentId() ?? '';
|
||||
$ctx = [
|
||||
'sessionId' => $sid,
|
||||
'simId' => $simId,
|
||||
'baseUrl' => $bu,
|
||||
'basePath' => $bp,
|
||||
'apiUrl' => $bu . '/php/api',
|
||||
];
|
||||
$ctxJson = json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
// Sim-eigene __GGS__-Felder gewinnen — wir ergänzen nur Plattform-Felder.
|
||||
$bootstrap = '<script>window.__GGS__=Object.assign(' . $ctxJson . ',window.__GGS__||{});</script>';
|
||||
$tag = '<script src="' . htmlspecialchars($bp . '/assets/js/live-client.js', ENT_QUOTES) . '" defer></script>';
|
||||
$injection = $bootstrap . "\n" . $tag . "\n";
|
||||
|
||||
// Sicheres Inject: vor dem letzten </body>. Falls keines, einfach anhängen.
|
||||
$pos = strrpos($html, '</body>');
|
||||
if ($pos === false) return $html . "\n" . $injection;
|
||||
return substr($html, 0, $pos) . $injection . substr($html, $pos);
|
||||
}
|
||||
|
||||
/** Seite rendern: HTML laden, Session-Kontext + Favicon injizieren, ausgeben */
|
||||
function renderPage(string $htmlFile): void {
|
||||
$html = file_get_contents(APP_ROOT . '/' . $htmlFile);
|
||||
|
||||
Reference in New Issue
Block a user