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,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Busfahrt — Wrapper
|
||||
* Laedt sims/busfahrt/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 'geplant' — Phase 0 (Skelett) abgeschlossen.
|
||||
* Phase 1 (Karte tippen + 3 Versuche + Info-Card) folgt durch die
|
||||
* Busfahrt-Instanz.
|
||||
*/
|
||||
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, 'busfahrt']);
|
||||
$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'], 'busfahrt']);
|
||||
$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 · Busfahrt</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:#404040}.lock-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 Busfahrt 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/busfahrt/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 · Busfahrt</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:#404040}.wip-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="wip-card">
|
||||
<h1>🚌 Busfahrt 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/busfahrt/';
|
||||
$injection =
|
||||
"window.BUSFAHRT_BASE = '$base';\n" .
|
||||
"window.BUSFAHRT_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.BUSFAHRT_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.BUSFAHRT_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.BUSFAHRT_API_BASE = '" . BASE_PATH . "/api';\n" .
|
||||
"window.BUSFAHRT_TILE_PROXY = '" . BASE_PATH . "/php/tile-proxy.php';";
|
||||
|
||||
if (strpos($html, '/*__BUSFAHRT_INJECTION__*/') !== false) {
|
||||
$html = str_replace('/*__BUSFAHRT_INJECTION__*/', $injection, $html);
|
||||
} else {
|
||||
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
||||
}
|
||||
|
||||
// Asset-Pfade auf BASE_PATH umbiegen
|
||||
$baseSim = BASE_PATH . '/sims/busfahrt/';
|
||||
$html = preg_replace(
|
||||
"/(['\"])assets\/(img|data|js|css)\//",
|
||||
"$1{$baseSim}assets/$2/",
|
||||
$html
|
||||
);
|
||||
|
||||
// Engine.js relativ → absolut
|
||||
$html = str_replace('src="engine.js"', 'src="' . $baseSim . 'engine.js"', $html);
|
||||
|
||||
// Cockpit-Link absolut
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'busfahrt');
|
||||
echo $html;
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Energiemanager — Wrapper
|
||||
* Laedt sims/energiemanager/game.html und biegt Asset-Pfade auf BASE_PATH um.
|
||||
*
|
||||
* Integrations-Vertrag §6.1: mode + forcedLevel + easy aus der
|
||||
* Schueler-Session abgeleitet, an das Frontend uebergeben.
|
||||
*/
|
||||
require_once __DIR__ . '/../php/config/app.php';
|
||||
require_once __DIR__ . '/../php/config/db.php';
|
||||
|
||||
$db = getDB();
|
||||
$MODULE_ID = 'energiemanager';
|
||||
|
||||
// ---- 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, $MODULE_ID]);
|
||||
$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'], $MODULE_ID]);
|
||||
$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 · Energiemanager</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:#f4f1e8;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 Energiemanager 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;
|
||||
}
|
||||
|
||||
$gamePath = __DIR__ . '/../sims/energiemanager/game.html';
|
||||
if (!is_file($gamePath)) {
|
||||
http_response_code(503);
|
||||
echo '<h1>Energiemanager wird gerade gebaut.</h1>';
|
||||
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/energiemanager/';
|
||||
$injection =
|
||||
"window.EM_BASE = '$base';\n" .
|
||||
"window.EM_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.EM_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.EM_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.EM_API_BASE = '" . BASE_PATH . "/api';";
|
||||
|
||||
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
||||
|
||||
// Asset-Pfade umbiegen: das game.html nutzt relative Pfade (../../assets/...,
|
||||
// ../../favicon..., ../../sim, ../../). Vom Wrapper-URL aus aufgelöst landen
|
||||
// die im falschen Verzeichnis. Wir biegen alle ../../-Refs auf BASE_PATH um.
|
||||
$rewrites = [
|
||||
'href="../../"' => 'href="' . cockpit_href() . '"',
|
||||
'href="../../sim"' => 'href="' . cockpit_href() . '"',
|
||||
'href="../../schueler"' => 'href="' . cockpit_href() . '"',
|
||||
'href="/schueler"' => 'href="' . cockpit_href() . '"',
|
||||
'"../../assets/' => '"' . BASE_PATH . '/assets/',
|
||||
"'../../assets/" => "'" . BASE_PATH . "/assets/",
|
||||
'"../../favicon' => '"' . BASE_PATH . '/favicon',
|
||||
"'../../favicon" => "'" . BASE_PATH . "/favicon",
|
||||
];
|
||||
foreach ($rewrites as $from => $to) {
|
||||
$html = str_replace($from, $to, $html);
|
||||
}
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'energiemanager');
|
||||
echo $html;
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* EU-Werkstatt — Wrapper
|
||||
* Laedt sims/eu-werkstatt/game.html und injiziert Base-Path + Session-Mode.
|
||||
*
|
||||
* Integrations-Vertrag §6.1: mode + forcedLevel + easy aus der
|
||||
* Schueler-Session abgeleitet, an das Frontend uebergeben.
|
||||
*/
|
||||
require_once __DIR__ . '/../php/config/app.php';
|
||||
require_once __DIR__ . '/../php/config/db.php';
|
||||
|
||||
$db = getDB();
|
||||
$MODULE_ID = 'eu-werkstatt';
|
||||
|
||||
// ---- 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, $MODULE_ID]);
|
||||
$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'], $MODULE_ID]);
|
||||
$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 · EU-Werkstatt</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:#f4f1e8;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 EU-Werkstatt 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;
|
||||
}
|
||||
|
||||
$gamePath = __DIR__ . '/../sims/eu-werkstatt/game.html';
|
||||
if (!is_file($gamePath)) {
|
||||
http_response_code(503);
|
||||
echo '<h1>EU-Werkstatt wird gerade gebaut.</h1>';
|
||||
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/eu-werkstatt/';
|
||||
$injection =
|
||||
"window.EUW_BASE = '$base';\n" .
|
||||
"window.EUW_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.EUW_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.EUW_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.EUW_API_BASE = '" . BASE_PATH . "/api';";
|
||||
|
||||
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
||||
|
||||
// Cockpit-Link in der Topbar setzen
|
||||
$html = str_replace('id="backToCockpit" href="#"', 'id="backToCockpit" href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'eu-werkstatt');
|
||||
echo $html;
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Farmer / Landwirtschaft — Wrapper
|
||||
* Laedt sims/farmer/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 'geplant' — Phase 0 (Skelett) abgeschlossen.
|
||||
* Phase 1 (Welt-Karte + Köppen-Layer + 3 Pflanzen + Reveal-Logik) folgt.
|
||||
*/
|
||||
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, 'farmer']);
|
||||
$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'], 'farmer']);
|
||||
$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 · Landwirtschaft</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:#8b5a2b}.lock-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="lock-card">
|
||||
<h1>🔒 Landwirtschaft 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/farmer/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 · Landwirtschaft</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:#8b5a2b}.wip-card{background:#f5f3ea;border:1px solid #e2ddd1;padding:24px;border-radius:8px}</style>
|
||||
</head><body>
|
||||
<div class="wip-card">
|
||||
<h1>🌾 Landwirtschaft 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/farmer/';
|
||||
$injection =
|
||||
"window.FARMER_BASE = '$base';\n" .
|
||||
"window.FARMER_SESSION_MODE = {$modeJs};\n" .
|
||||
"window.FARMER_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
||||
"window.FARMER_SESSION_ID = {$sessionIdJs};\n" .
|
||||
"window.STUDENT_EASY = {$easyJs};\n" .
|
||||
"window.FARMER_API_BASE = '" . BASE_PATH . "/api';\n" .
|
||||
"window.FARMER_TILE_PROXY = '" . BASE_PATH . "/php/tile-proxy.php';";
|
||||
|
||||
if (strpos($html, '/*__FARMER_INJECTION__*/') !== false) {
|
||||
$html = str_replace('/*__FARMER_INJECTION__*/', $injection, $html);
|
||||
} else {
|
||||
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
||||
}
|
||||
|
||||
// Asset-Pfade auf BASE_PATH umbiegen
|
||||
$baseSim = BASE_PATH . '/sims/farmer/';
|
||||
$html = preg_replace(
|
||||
"/(['\"])assets\/(img|data|js|css)\//",
|
||||
"$1{$baseSim}assets/$2/",
|
||||
$html
|
||||
);
|
||||
|
||||
// Engine.js relativ → absolut
|
||||
$html = str_replace('src="engine.js"', 'src="' . $baseSim . 'engine.js"', $html);
|
||||
|
||||
// Cockpit-Link absolut
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'farmer');
|
||||
echo $html;
|
||||
+4
-1
@@ -113,6 +113,8 @@ if ($html === false) {
|
||||
$bp = BASE_PATH;
|
||||
$baseTag = '<base href="' . htmlspecialchars($bp . '/sims/fluss/', ENT_QUOTES) . '">';
|
||||
$ctxJs = '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';</script>';
|
||||
// Plattform-Live-Client: Heartbeat + Pause-Overlay + Spectator-Mode für ?view=teacher
|
||||
$liveJs = '<script src="' . htmlspecialchars($bp . '/assets/js/live-client.js', ENT_QUOTES) . '" defer></script>';
|
||||
|
||||
// <base>-Tag direkt nach <head>, damit relative Pfade aus /sims/fluss/ aufloesen
|
||||
$html = preg_replace('/<head>/i', '<head>' . "\n" . $baseTag, $html, 1);
|
||||
@@ -122,7 +124,8 @@ $html = preg_replace('/<head>/i', '<head>' . "\n" . $baseTag, $html, 1);
|
||||
// das </script> darin wuerde den umgebenden Script-Block vorzeitig schliessen.
|
||||
$pos = strrpos($html, '</body>');
|
||||
if ($pos !== false) {
|
||||
$html = substr($html, 0, $pos) . $ctxJs . "\n" . substr($html, $pos);
|
||||
$html = substr($html, 0, $pos) . $ctxJs . "\n" . $liveJs . "\n" . substr($html, $pos);
|
||||
}
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
echo $html;
|
||||
|
||||
@@ -58,7 +58,7 @@ 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 . '/sim';
|
||||
$cockpit = BASE_PATH . '/schueler';
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html><html lang="de"><head>
|
||||
<meta charset="utf-8"><title>Gesperrt · Heli-Navigation</title>
|
||||
@@ -143,5 +143,7 @@ $html = strtr($html, [
|
||||
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js' => $leafletJs,
|
||||
"'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'" => "'{$tileProxy}?z={z}&x={x}&y={y}&p=osm'",
|
||||
]);
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'heli');
|
||||
echo $html;
|
||||
|
||||
+24
-2
@@ -21,6 +21,7 @@ $classId = null;
|
||||
$simName = 'Klimawächter 2D';
|
||||
$simIcon = '🌍';
|
||||
|
||||
$skipResume = false;
|
||||
try {
|
||||
$db = Database::get();
|
||||
if ($sessionId) {
|
||||
@@ -31,6 +32,23 @@ try {
|
||||
if ($row) {
|
||||
$studentName = $row['display_name'] ?: 'Schüler*in';
|
||||
$classId = (int)$row['class_id'];
|
||||
// Aktiver, noch nicht erledigter Lehrer-Auftrag? Dann frisch starten,
|
||||
// damit der Schüler nicht aus alter Free-Play-Session resumed.
|
||||
if ($classId) {
|
||||
$cm = $db->fetchOne(
|
||||
'SELECT mode, started_at, current_level FROM class_modules WHERE class_id = ? AND module_id = ?',
|
||||
[$classId, 'klima']
|
||||
);
|
||||
if ($cm && $cm['mode'] === 'teacher_started' && $cm['started_at']) {
|
||||
$done = $db->fetchOne(
|
||||
'SELECT 1 FROM assessments WHERE session_id = ? AND sim_id = ? AND submitted_at > ? LIMIT 1',
|
||||
[$sessionId, 'klima', $cm['started_at']]
|
||||
);
|
||||
if (!$done) $skipResume = true;
|
||||
$level = (int)($cm['current_level'] ?? $level);
|
||||
if ($level < 1 || $level > 3) $level = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Modul-Info aus DB (Atlas-verwaltet). Defaults greifen, wenn Tabelle
|
||||
@@ -91,6 +109,7 @@ $ctx = [
|
||||
'simIcon' => $simIcon,
|
||||
'level' => $level,
|
||||
'levelConfig' => $levelConfigs[$level],
|
||||
'skipResume' => $skipResume,
|
||||
'baseUrl' => BASE_URL,
|
||||
'basePath' => BASE_PATH,
|
||||
'apiUrl' => BASE_URL . '/php/api',
|
||||
@@ -106,10 +125,13 @@ if ($html === false) {
|
||||
$bp = BASE_PATH;
|
||||
$baseTag = '<base href="' . htmlspecialchars($bp . '/sims/klima/', ENT_QUOTES) . '">';
|
||||
$ctxJs = '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';</script>';
|
||||
// Plattform-Live-Client: Heartbeat + Pause-Overlay + Spectator-Mode für ?view=teacher
|
||||
$liveJs = '<script src="' . htmlspecialchars($bp . '/assets/js/live-client.js', ENT_QUOTES) . '" defer></script>';
|
||||
|
||||
// <base>-Tag direkt nach <head> einfügen, damit relative Pfade aus /sims/klima/ heraus auflösen
|
||||
$html = preg_replace('/<head>/i', '<head>' . "\n" . $baseTag, $html, 1);
|
||||
// Session-Kontext vor </body>
|
||||
$html = str_replace('</body>', $ctxJs . "\n</body>", $html);
|
||||
// Session-Kontext + Live-Client vor </body>
|
||||
$html = str_replace('</body>', $ctxJs . "\n" . $liveJs . "\n</body>", $html);
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
echo $html;
|
||||
|
||||
@@ -62,7 +62,7 @@ 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 . '/sim';
|
||||
$cockpit = BASE_PATH . '/schueler';
|
||||
echo <<<HTML
|
||||
<!DOCTYPE html><html lang="de"><head>
|
||||
<meta charset="utf-8"><title>Gesperrt · Logistik Europa</title>
|
||||
@@ -143,14 +143,18 @@ $html = strtr($html, [
|
||||
'href="../../favicon-96x96.png"' => 'href="' . BASE_PATH . '/favicon-96x96.png"',
|
||||
'src="../../assets/img/bildLogo.png"' => 'src="' . BASE_PATH . '/assets/img/bildLogo.png"',
|
||||
'src="../../assets/img/textlogo_geograsim.svg"' => 'src="' . BASE_PATH . '/assets/img/textlogo_geograsim.svg"',
|
||||
'href="../../sim"' => 'href="' . BASE_PATH . '/sim"',
|
||||
'href="../../schueler"' => 'href="' . cockpit_href() . '"',
|
||||
'href="../../"' => 'href="' . BASE_PATH . '/"',
|
||||
'src="engine.js"' => 'src="' . $base . 'engine.js"',
|
||||
'src="headless-runner.js"' => 'src="' . $base . 'headless-runner.js"',
|
||||
'src="assets/vendor/three/three.min.js"' => 'src="' . $base . 'assets/vendor/three/three.min.js"',
|
||||
'src="assets/vendor/autobahn-game/autobahn-game.js"' => 'src="' . $base . 'assets/vendor/autobahn-game/autobahn-game.js"',
|
||||
// Leaflet lokal + Tile-Proxy (DSGVO-sicher)
|
||||
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css' => BASE_PATH . '/assets/vendor/leaflet/leaflet.css',
|
||||
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js' => BASE_PATH . '/assets/vendor/leaflet/leaflet.js',
|
||||
"'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png'" => "'{$tileProxy}?z={z}&x={x}&y={y}&p=osm-de'",
|
||||
]);
|
||||
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
||||
|
||||
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'logistik');
|
||||
echo $html;
|
||||
|
||||
@@ -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;
|
||||
@@ -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