1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
144 lines
5.9 KiB
PHP
144 lines
5.9 KiB
PHP
<?php
|
|
/**
|
|
* Kofferdetektiv 2D — Plattform-Wrapper (Slot, wartet auf Sim-Lieferung)
|
|
*
|
|
* Identisches Plattform-Pattern wie kofferdetektiv-3d.php, lädt aber
|
|
* sims/kofferdetektiv/game-2d.html. Solange diese Datei fehlt, zeigt
|
|
* der Wrapper eine „in Vorbereitung"-Seite.
|
|
*
|
|
* Stufenmapping identisch zu 3D (1 → Klasse A, 2 → B, 3 → C).
|
|
*/
|
|
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;
|
|
$studentName = 'Gast';
|
|
$classId = null;
|
|
|
|
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'];
|
|
$studentName = $sess['display_name'] ?: 'Schüler:in';
|
|
$cm = $db->prepare('SELECT mode, current_level FROM class_modules WHERE class_id = ? AND module_id = ?');
|
|
$cm->execute([$classId, 'kofferdetektiv']);
|
|
$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'], 'kofferdetektiv']);
|
|
$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 · Kofferdetektiv 2D</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>🔒 Kofferdetektiv 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;
|
|
}
|
|
|
|
// 2D-Sim-Datei prüfen — fehlt aktuell noch.
|
|
$gamePath = __DIR__ . '/../sims/kofferdetektiv/game-2d.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';
|
|
$play3d = BASE_PATH . '/kofferdetektiv-3d';
|
|
echo <<<HTML
|
|
<!DOCTYPE html><html lang="de"><head>
|
|
<meta charset="utf-8"><title>In Vorbereitung · Kofferdetektiv 2D</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}
|
|
a.btn{display:inline-block;padding:10px 18px;background:#1f4b37;color:white;text-decoration:none;border-radius:6px;margin-top:12px}</style>
|
|
</head><body>
|
|
<div class="wip-card">
|
|
<h1>🕵️ 2D-Version in Vorbereitung.</h1>
|
|
<p>Die 2D-Version des Kofferdetektivs wird gerade gebaut. Die 3D-Version ist verfügbar:</p>
|
|
<p><a class="btn" href="{$play3d}">▶ 3D-Version starten</a></p>
|
|
<p style="margin-top:18px"><a href="{$cockpit}">Zurück zum Cockpit</a></p>
|
|
</div>
|
|
</body></html>
|
|
HTML;
|
|
exit;
|
|
}
|
|
|
|
// Identisches Boot-Pattern zu 3D-Variante.
|
|
$html = file_get_contents($gamePath);
|
|
$base = BASE_PATH . '/sims/kofferdetektiv/';
|
|
$ggs = [
|
|
'sessionId' => $sessionId ?: '',
|
|
'studentId' => null,
|
|
'studentName' => $studentName,
|
|
'classId' => $classId,
|
|
'simId' => 'kofferdetektiv',
|
|
'simName' => 'Kofferdetektiv',
|
|
'mode' => $mode,
|
|
'forcedLevel' => $forcedLevel,
|
|
'easy' => $easy,
|
|
'baseUrl' => defined('BASE_URL') ? BASE_URL : '',
|
|
'basePath' => BASE_PATH,
|
|
'apiUrl' => BASE_PATH . '/php/api',
|
|
];
|
|
$injection = '<script>'
|
|
. 'window.KD_BASE = ' . json_encode($base) . ';'
|
|
. 'window.__GGS__ = ' . json_encode($ggs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ';'
|
|
. '</script>';
|
|
$html = preg_replace(
|
|
"/(href|src)=([\"'])(assets\/|data\.js|engine\.js|engine-2d\.js)/",
|
|
"$1=$2{$base}$3",
|
|
$html
|
|
);
|
|
$html = str_replace('</head>', $injection . "\n</head>", $html);
|
|
$html = str_replace('href="/schueler"', 'href="' . cockpit_href() . '"', $html);
|
|
$liveScript = '<script src="' . BASE_PATH . '/assets/js/live-client.js" defer></script>';
|
|
$glossarScript = '<script src="' . BASE_PATH . '/assets/js/glossar-tooltip.js" defer></script>'
|
|
. '<script>window.addEventListener("DOMContentLoaded",function(){'
|
|
. 'if(window.GlossarTooltip)GlossarTooltip.init({apiBase:' . json_encode(BASE_PATH . '/php/api') . ',moduleId:"kofferdetektiv"});'
|
|
. '});</script>';
|
|
$html = str_replace('</body>', $liveScript . "\n" . $glossarScript . "\n</body>", $html);
|
|
|
|
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'kofferdetektiv');
|
|
|
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
|
header('Content-Type: text/html; charset=UTF-8');
|
|
echo $html;
|