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, 'wal']); $cmRow = $cm->fetch(PDO::FETCH_ASSOC); if ($cmRow) { $mode = $cmRow['mode']; if ($mode === 'teacher_started') $forcedLevel = (int)($cmRow['current_level'] ?? 3); } else { $mode = 'locked'; } // Schüler-Override $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'], 'wal']); $soRow = $so->fetch(PDO::FETCH_ASSOC); if ($soRow) $mode = $soRow['mode']; // Easy-Flag $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']); } } // Welt-Variante aus forcedLevel ableiten. null = Sim fragt im Intro. $forcedEra = null; if ($forcedLevel !== null) { $forcedEra = ($forcedLevel === 1) ? 1850 : (($forcedLevel === 2) ? 1990 : 2026); } // 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 << Gesperrt · Wal

🔒 Wal ist gesperrt.

Deine Lehrperson hat dieses Modul für eure Klasse noch nicht freigegeben.

Im Cockpit findest du die derzeit freigegebenen Module.

HTML; exit; } // ---- Sim-Datei laden ---- $gamePath = __DIR__ . '/../sims/wal/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 << In Vorbereitung · Wal

🐋 Die große Wanderung wird gerade gebaut.

Diese Simulation ist in Vorbereitung. Schau im Cockpit in die anderen Module.

HTML; exit; } $html = file_get_contents($gamePath); $modeJs = json_encode($mode); $forcedLevelJs = json_encode($forcedLevel); $forcedEraJs = json_encode($forcedEra); $easyJs = $easy ? 'true' : 'false'; $sessionIdJs = json_encode($sessionId); $baseSim = BASE_PATH . '/sims/wal/'; $injection = "window.WAL_BASE = '$baseSim';\n" . "window.WAL_SESSION_MODE = {$modeJs};\n" . "window.WAL_FORCED_LEVEL = {$forcedLevelJs};\n" . "window.WAL_FORCED_ERA = {$forcedEraJs};\n" . // 1850 | 1990 | 2026 | null "window.WAL_SESSION_ID = {$sessionIdJs};\n" . "window.STUDENT_EASY = {$easyJs};\n" . "window.WAL_API_BASE = '" . BASE_PATH . "/php/api';"; if (strpos($html, '/*__WAL_INJECTION__*/') !== false) { $html = str_replace('/*__WAL_INJECTION__*/', $injection, $html); } else { $html = str_replace('', "\n", $html); } // Asset-Pfade umbiegen $html = preg_replace("/(['\"])assets\//", "$1{$baseSim}assets/", $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, 'wal'); echo $html;