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,128 @@
|
||||
<?php
|
||||
/**
|
||||
* Staustufen — Wrapper
|
||||
* Laedt sims/staustufen/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-04-26: Modul ist 'geplant'. Sobald die Staustufen-Instanz
|
||||
* App/sims/staustufen/game.html angelegt hat, wird die Sim ausgeliefert.
|
||||
*/
|
||||
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, 'staustufen']);
|
||||
$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'], 'staustufen']);
|
||||
$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 · Staustufen</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:#1f4b37}.lock-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 Staustufen 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 (Fallback solange noch leer) ----
|
||||
$gamePath = __DIR__ . '/../sims/staustufen/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 · Staustufen</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:#1f4b37}.wip-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="wip-card">
|
||||
<h1>🏞️ Staustufen wird gerade gebaut.</h1>
|
||||
<p>Diese Simulation ist in Vorbereitung. Schau im <a href="{$cockpit}">Cockpit</a>
|
||||
in die anderen Module, oder öffne die Detailseite
|
||||
<a href="{$cockpit}">modul-staustufen</a> für Lernziele und Lehrplan-Bezug.</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/staustufen/';
|
||||
$injection =
|
||||
"window.STAUSTUFEN_BASE = '$base';\n" .
|
||||
"window.STAUSTUFEN_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.STAUSTUFEN_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.STAUSTUFEN_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.STAUSTUFEN_API_BASE = '" . BASE_PATH . "/api';";
|
||||
|
||||
$html = str_replace('/*__STAUSTUFEN_INJECTION__*/', $injection, $html);
|
||||
|
||||
// Relative Asset-Pfade auf BASE_PATH umbiegen (analog heli-game.php)
|
||||
$html = str_replace('href="../../favicon-96x96.png"', 'href="' . BASE_PATH . '/favicon-96x96.png"', $html);
|
||||
$html = str_replace('href="../../assets/fonts/inter.css"', 'href="' . BASE_PATH . '/assets/fonts/inter.css"', $html);
|
||||
$html = str_replace('href="../../assets/css/design-system.css"', 'href="' . BASE_PATH . '/assets/css/design-system.css"', $html);
|
||||
$html = str_replace('href="../../schueler"', 'href="' . BASE_PATH . '/schueler"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'staustufen');
|
||||
echo $html;
|
||||
Reference in New Issue
Block a user