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:
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Sonnensystem — Wrapper
|
||||
* Laedt sims/sonnensystem/game.html und injiziert Base-Path + Session-Mode.
|
||||
*
|
||||
* Integrations-Vertrag §6.1: mode + forcedLevel + easy aus der
|
||||
* Schueler-Session abgeleitet, an das Frontend uebergeben.
|
||||
*
|
||||
* Stand 2026-05-03: Modul ist 'beta' (Phase 1 — Plattform-Integration aktiv).
|
||||
* Beobachtungs-Modus folgt in Phase 2.
|
||||
*/
|
||||
require_once __DIR__ . '/../php/config/app.php';
|
||||
require_once __DIR__ . '/../php/config/db.php';
|
||||
|
||||
$db = getDB();
|
||||
|
||||
// ---- Mode-Check (Integrations-Vertrag §6.1) ----
|
||||
$sessionId = $_COOKIE['ggs_session'] ?? null;
|
||||
$mode = 'free';
|
||||
$forcedLevel = null;
|
||||
$easy = false;
|
||||
|
||||
if ($sessionId) {
|
||||
$stmt = $db->prepare('SELECT class_id, display_name FROM student_sessions WHERE id = ?');
|
||||
$stmt->execute([$sessionId]);
|
||||
$sess = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($sess && !empty($sess['class_id'])) {
|
||||
$classId = (int)$sess['class_id'];
|
||||
$cm = $db->prepare('SELECT mode, current_level FROM class_modules WHERE class_id = ? AND module_id = ?');
|
||||
$cm->execute([$classId, 'sonnensystem']);
|
||||
$cmRow = $cm->fetch(PDO::FETCH_ASSOC);
|
||||
if ($cmRow) {
|
||||
$mode = $cmRow['mode'];
|
||||
if ($mode === 'teacher_started') $forcedLevel = (int)($cmRow['current_level'] ?? 1);
|
||||
} else {
|
||||
$mode = 'locked';
|
||||
}
|
||||
$so = $db->prepare(
|
||||
'SELECT sm.mode FROM student_modules sm
|
||||
JOIN students s ON s.id = sm.student_id
|
||||
WHERE s.class_id = ? AND s.display_name = ? AND sm.module_id = ?'
|
||||
);
|
||||
$so->execute([$classId, $sess['display_name'], 'sonnensystem']);
|
||||
$soRow = $so->fetch(PDO::FETCH_ASSOC);
|
||||
if ($soRow) $mode = $soRow['mode'];
|
||||
$eq = $db->prepare(
|
||||
'SELECT easy_language FROM students WHERE class_id = ? AND display_name = ?'
|
||||
);
|
||||
$eq->execute([$classId, $sess['display_name']]);
|
||||
$eqRow = $eq->fetch(PDO::FETCH_ASSOC);
|
||||
if ($eqRow) $easy = !empty($eqRow['easy_language']);
|
||||
}
|
||||
}
|
||||
|
||||
// Locked-Seite
|
||||
if ($mode === 'locked') {
|
||||
http_response_code(403);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
$cssHref = BASE_PATH . '/assets/css/design-system.css';
|
||||
$cockpit = BASE_PATH . '/schueler';
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html><html lang="de"><head>
|
||||
<meta charset="utf-8"><title>Gesperrt · Sonnensystem</title>
|
||||
<link rel="stylesheet" href="{$cssHref}">
|
||||
<style>body{font-family:system-ui,sans-serif;padding:40px;max-width:640px;margin:auto;color:#333}
|
||||
h1{color:#3d2c8d}.lock-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 Sonnensystem ist gesperrt.</h1>
|
||||
<p>Deine Lehrkraft hat dieses Modul für eure Klasse noch nicht freigegeben.</p>
|
||||
<p>Im <a href="{$cockpit}">Cockpit</a> findest du die derzeit freigegebenen Module.</p>
|
||||
</div>
|
||||
</body></html>
|
||||
HTML;
|
||||
exit;
|
||||
}
|
||||
|
||||
// ---- Sim-Datei laden ----
|
||||
$gamePath = __DIR__ . '/../sims/sonnensystem/game.html';
|
||||
if (!is_file($gamePath)) {
|
||||
http_response_code(503);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
$cssHref = BASE_PATH . '/assets/css/design-system.css';
|
||||
$cockpit = BASE_PATH . '/schueler';
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html><html lang="de"><head>
|
||||
<meta charset="utf-8"><title>In Vorbereitung · Sonnensystem</title>
|
||||
<link rel="stylesheet" href="{$cssHref}">
|
||||
<style>body{font-family:system-ui,sans-serif;padding:40px;max-width:640px;margin:auto;color:#333}
|
||||
h1{color:#3d2c8d}.wip-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="wip-card">
|
||||
<h1>🪐 Sonnensystem wird gerade gebaut.</h1>
|
||||
<p>Diese Simulation ist in Vorbereitung. Schau im <a href="{$cockpit}">Cockpit</a>
|
||||
in die anderen Module.</p>
|
||||
</div>
|
||||
</body></html>
|
||||
HTML;
|
||||
exit;
|
||||
}
|
||||
|
||||
$html = file_get_contents($gamePath);
|
||||
|
||||
$modeJs = json_encode($mode);
|
||||
$forcedLevelJs = json_encode($forcedLevel);
|
||||
$easyJs = $easy ? 'true' : 'false';
|
||||
$sessionIdJs = json_encode($sessionId);
|
||||
|
||||
$base = BASE_PATH . '/sims/sonnensystem/';
|
||||
$injection =
|
||||
"window.SONNENSYSTEM_BASE = '$base';\n" .
|
||||
"window.SONNENSYSTEM_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.SONNENSYSTEM_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.SONNENSYSTEM_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.SONNENSYSTEM_API_BASE = '" . BASE_PATH . "/api';";
|
||||
|
||||
// Injection wird via Marker eingesetzt (falls in Sim verlangt) — sonst hängen wir
|
||||
// die globalen Variablen direkt vor das schließende </head>.
|
||||
if (strpos($html, '/*__SONNENSYSTEM_INJECTION__*/') !== false) {
|
||||
$html = str_replace('/*__SONNENSYSTEM_INJECTION__*/', $injection, $html);
|
||||
} else {
|
||||
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
||||
}
|
||||
|
||||
// Asset-Pfade auf BASE_PATH umbiegen (Sim liegt unter sims/sonnensystem/, vom
|
||||
// Wrapper aus serviert werden Asset-Pfade ohne Praefix sonst falsch aufgeloest).
|
||||
$baseSim = BASE_PATH . '/sims/sonnensystem/';
|
||||
$html = preg_replace(
|
||||
"/(['\"])assets\/img\//",
|
||||
"$1{$baseSim}assets/img/",
|
||||
$html
|
||||
);
|
||||
|
||||
// Cockpit-Link absolut machen
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'sonnensystem');
|
||||
echo $html;
|
||||
Reference in New Issue
Block a user