0a2ebf46b4
Sim nach App/sims/tourismustal umgezogen (Source of Truth), game.html mit Injection-Marker. Neu in der Sim: 5 Sommergebaeude (Bikepark mit Flowtrails, Hochseilgarten, Fahrradverleih als Verstaerker, Aussichtsplattform, Erlebnisspielplatz), Rettungsstation mit Notarzthubschrauber, Ausbau- Bauanimation, Event-Pacing, Schulden-Notbremse (Bank-Zwangsverkauf), Berater-Tipps (Ruecklagen), Sommer-Trend-Mechanik (Serfaus-Effekt) und Wissens-Bausteine mit echten DACH-Tourismusdaten (QUELLEN.md). Plattform: PHP-Wrapper mit base-Tag + Session-Mode, Modul-Detailseite, module_info (beta) + Glossar (14 Begriffe inkl. Leichter Sprache + Quellen) + Lehrplan-Anker AT/DE/CH an neuer Kompetenz tourismus-raumentwicklung. Lehrer-Backend: Benchmark-Formel, Live-Cockpit-Spalten, needsHelp-Heuristik, Modul-Highlights. Strategie-Testharness (tests/strategien.mjs) belegt: Panzer-Rush wird liquidiert, Ruecklagen zahlen sich aus. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
106 lines
4.0 KiB
PHP
106 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* Tourismustal — Wrapper
|
|
* Laedt sims/tourismustal/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;
|
|
|
|
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 FROM class_modules WHERE class_id = ? AND module_id = ?');
|
|
$cm->execute([$classId, 'tourismustal']);
|
|
$cmRow = $cm->fetch(PDO::FETCH_ASSOC);
|
|
$mode = $cmRow ? $cmRow['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'], 'tourismustal']);
|
|
$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 · Tourismustal</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>🔒 Tourismustal 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/tourismustal/game.html';
|
|
if (!is_file($gamePath)) {
|
|
http_response_code(503);
|
|
echo 'Tourismustal ist in Vorbereitung.';
|
|
exit;
|
|
}
|
|
|
|
$html = file_get_contents($gamePath);
|
|
|
|
$modeJs = json_encode($mode);
|
|
$easyJs = $easy ? 'true' : 'false';
|
|
$sessionIdJs = json_encode($sessionId);
|
|
|
|
$injection =
|
|
"window.TT_SESSION_MODE = {$modeJs};\n" .
|
|
"window.TT_SESSION_ID = {$sessionIdJs};\n" .
|
|
"window.STUDENT_EASY = {$easyJs};\n" .
|
|
"window.TT_API_BASE = '" . BASE_PATH . "/php/api';";
|
|
|
|
if (strpos($html, '/*__TOURISMUSTAL_INJECTION__*/') !== false) {
|
|
$html = str_replace('/*__TOURISMUSTAL_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/tourismustal/';
|
|
$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, 'tourismustal');
|
|
echo $html;
|