8047778a5b
Wellenbasierte Routen-Sim (DefensegeograSimMac) nach dem Tourismustal- Playbook integriert: Sim nach App/sims/tourismusregion (game.html, Sprites 47MB->9.5MB, ohne Eigen-Backend/Editor/Dashboard/Keys), Plattform-Hooks (GGS_LIVE_STATE mit Welle/Budget/Umwelt/Sterne/Lenkung, Submit bei Partie-Ende mit fertigem 0-100-Score, GGS_TUTORIAL, Home- Button, Musik leise). Wrapper + Modul-Detailseite. SQL: module_info (beta, Karte), Glossar-Kernbegriff Besucherlenkung (+Bild, Leichte Sprache) + 12 Zuordnungen, Lehrplan-Mapping auf tourismus- raumentwicklung (primaer) + verkehrserziehung/systemisches-denken. LEHRPLAN.md mit Schwerpunkt Besucherlenkung & Mobilitaet. Lehrer- Backend: Benchmark (Sim-Score direkt), Live-Cockpit-Spalten, needsHelp, Highlights. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
112 lines
4.4 KiB
PHP
112 lines
4.4 KiB
PHP
<?php
|
|
/**
|
|
* Tourismusregion — Wrapper
|
|
* Laedt sims/tourismusregion/game.html und injiziert Base + Session-Mode.
|
|
*
|
|
* Integrations-Vertrag §6.1: mode + easy aus der Schueler-Session.
|
|
* Die Sim ist ES-Module-basiert mit relativen Pfaden (css/, js/, assets/) —
|
|
* statt Pfad-Rewrites setzen wir einen <base>-Tag auf den Sim-Ordner; damit
|
|
* loesen sich auch die zur Laufzeit gefetchten Audio-/Musik-Pfade korrekt auf.
|
|
*
|
|
* Stand 2026-07-11: Erst-Integration (beta) — Atlas.
|
|
*/
|
|
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';
|
|
$easy = false;
|
|
$audioInfo = true; // Vorlese-Modus: Lehrer kann ihn pro Klasse sperren
|
|
|
|
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, audio_info FROM class_modules WHERE class_id = ? AND module_id = ?');
|
|
$cm->execute([$classId, 'tourismusregion']);
|
|
$cmRow = $cm->fetch(PDO::FETCH_ASSOC);
|
|
$mode = $cmRow ? $cmRow['mode'] : 'locked';
|
|
if ($cmRow !== false && array_key_exists('audio_info', (array)$cmRow)) {
|
|
$audioInfo = !empty($cmRow['audio_info']);
|
|
}
|
|
$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'], 'tourismusregion']);
|
|
$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']);
|
|
}
|
|
}
|
|
|
|
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 · Tourismusregion</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>🔒 Tourismusregion ist gesperrt.</h1>
|
|
<p>Deine Lehrperson 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/tourismusregion/game.html';
|
|
if (!is_file($gamePath)) {
|
|
http_response_code(503);
|
|
echo 'Tourismusregion ist in Vorbereitung.';
|
|
exit;
|
|
}
|
|
|
|
$html = file_get_contents($gamePath);
|
|
|
|
$modeJs = json_encode($mode);
|
|
$easyJs = $easy ? 'true' : 'false';
|
|
$sessionIdJs = json_encode($sessionId);
|
|
|
|
$audioInfoJs = $audioInfo ? 'true' : 'false';
|
|
$injection =
|
|
"window.TT_SESSION_MODE = {$modeJs};\n" .
|
|
"window.TT_SESSION_ID = {$sessionIdJs};\n" .
|
|
"window.STUDENT_EASY = {$easyJs};\n" .
|
|
"window.TT_FEATURES = { audioInfo: {$audioInfoJs} };\n" .
|
|
"window.TT_API_BASE = '" . BASE_PATH . "/php/api';";
|
|
|
|
if (strpos($html, '/*__TOURISMUSREGION_INJECTION__*/') !== false) {
|
|
$html = str_replace('/*__TOURISMUSREGION_INJECTION__*/', $injection, $html);
|
|
} else {
|
|
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
|
}
|
|
|
|
// <base> auf den Sim-Ordner: loest css/, js/ (ES-Module), assets/…
|
|
// inklusive der zur Laufzeit gesetzten Audio-Quellen korrekt auf.
|
|
$base = BASE_PATH . '/sims/tourismusregion/';
|
|
$html = preg_replace('/<head>/', "<head>\n<base href=\"{$base}\">", $html, 1);
|
|
|
|
// Home-Button: auf das gerade gueltige Cockpit umbiegen
|
|
$cockpit = cockpit_href();
|
|
$html = str_replace("window.location.href='../../schueler.html'", "window.location.href='" . $cockpit . "'", $html);
|
|
|
|
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'tourismusregion');
|
|
echo $html;
|