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']; // Klassen-Default $cm = $db->prepare('SELECT mode, current_level FROM class_modules WHERE class_id = ? AND module_id = ?'); $cm->execute([$classId, 'heli']); $cmRow = $cm->fetch(PDO::FETCH_ASSOC); if ($cmRow) { $mode = $cmRow['mode']; if ($mode === 'teacher_started') $forcedLevel = (int)($cmRow['current_level'] ?? 1); } else { $mode = 'locked'; // kein Klassen-Eintrag = explizit gesperrt } // Override auf Schueler-Ebene $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'], 'heli']); $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']); } // Session ohne class_id = Autodidakt -> bleibt 'free' } // 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 · Heli-Navigation

🔒 Heli-Navigation ist gesperrt.

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

Im Cockpit findest du die derzeit freigegebenen Module.

HTML; exit; } // ---- Waypoints aus DB laden ---- $rows = $db->query("SELECT wp_key, name, lat, lon, wp_type, info FROM geo_waypoints")->fetchAll(PDO::FETCH_ASSOC); // Facts pro Waypoint (geo + kids) — falls Tabelle existiert $factsByKey = []; try { $factRows = $db->query("SELECT wp_key, kind, text_de FROM geo_waypoint_facts ORDER BY wp_key, kind, display_order")->fetchAll(PDO::FETCH_ASSOC); foreach ($factRows as $f) { $factsByKey[$f['wp_key']][$f['kind']][] = $f['text_de']; } } catch (Exception $e) { /* Tabelle fehlt -> weitermachen */ } $factsJson = json_encode($factsByKey, JSON_UNESCAPED_UNICODE); $wpJs = "{\n"; foreach ($rows as $w) { $key = $w['wp_key']; $name = addslashes($w['name']); $wpJs .= " '$key':{lat:{$w['lat']},lon:{$w['lon']},name:'$name'},\n"; } $wpJs .= "}"; // POIs fuer die Karte (Basen, Staedte, Gipfel) $poisJs = "[\n"; foreach ($rows as $w) { if (in_array($w['wp_type'], ['base','city','peak'])) { $name = addslashes($w['name']); $info = addslashes($w['info'] ?? ''); $poisJs .= " {key:'{$w['wp_key']}',name:'$name',lat:{$w['lat']},lon:{$w['lon']},type:'{$w['wp_type']}',info:'$info'},\n"; } } $poisJs .= "]"; // ---- game.html laden ---- $html = file_get_contents(__DIR__ . '/../sims/heli/game.html'); // Session-Werte fuer JS $modeJs = json_encode($mode); $forcedLevelJs = json_encode($forcedLevel); $easyJs = $easy ? 'true' : 'false'; $sessionIdJs = json_encode($sessionId); $base = BASE_PATH . '/sims/heli/'; // === Heli-Stationen + Pool-Kennzeichen aus zentraler JSON === // (rechtssichere Anzeige ohne Markennamen, siehe docs/konzept-heli-kennzeichen.md) $stationsPath = __DIR__ . '/../sims/heli/data/heli-stations.json'; $stationsJson = file_exists($stationsPath) ? file_get_contents($stationsPath) : '{}'; // === Mission-Briefings (Phase 1.5) aus zentraler JSON === $briefingsPath = __DIR__ . '/../sims/heli/data/briefings.json'; $briefingsJson = file_exists($briefingsPath) ? file_get_contents($briefingsPath) : '{}'; $injection = "window.HELI_BASE = '$base';\n" . "window.HELI_SESSION_MODE = {$modeJs};\n" . "window.HELI_FORCED_LEVEL = {$forcedLevelJs};\n" . "window.HELI_SESSION_ID = {$sessionIdJs};\n" . "window.STUDENT_EASY = {$easyJs};\n" . "window.HELI_API_BASE = '" . BASE_PATH . "/api';\n" . "window.HELI_STATIONS = $stationsJson;\n" . "window.HELI_BRIEFINGS = $briefingsJson;\n" . "window.HELI_FORCED_MISSION = " . json_encode($forcedMission) . ";\n" . "var WP = $wpJs;\nvar wpLoaded = true;\nvar DB_POIS = $poisJs;\nvar HELI_FACTS = $factsJson;"; $html = str_replace('/*__DB_WAYPOINTS__*/', $injection, $html); // Head-Asset-Pfade auf BASE_PATH umbiegen (relative ../../ greift unter /heli-game-Route falsch) $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); // Leaflet lokal + Tile-Proxy (DSGVO-sicher) $leafletCss = BASE_PATH . '/assets/vendor/leaflet/leaflet.css'; $leafletJs = BASE_PATH . '/assets/vendor/leaflet/leaflet.js'; $tileProxy = BASE_PATH . '/php/tile-proxy.php'; $html = strtr($html, [ 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css' => $leafletCss, '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;