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>
82 lines
3.3 KiB
PHP
82 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* Vulkan — Wrapper
|
|
* Laedt sims/vulkan/game.html und injiziert Base-Path + Session-Mode.
|
|
*
|
|
* Stand 2026-06-02: Phase 1 (beta). Three.js-Sim mit Magma-Parametern,
|
|
* Eruptionen, Lava-Fluss, pyroklastischen Stroemen. Task-System
|
|
* (Quiz / Vorhersage / Maßnahmen) injiziert via window.VULKAN_TASKS.
|
|
*/
|
|
require_once __DIR__ . '/../php/config/app.php';
|
|
require_once __DIR__ . '/../php/config/db.php';
|
|
|
|
$db = getDB();
|
|
|
|
$sessionId = $_COOKIE['ggs_session'] ?? null;
|
|
$mode = 'free';
|
|
$forcedLevel = null;
|
|
$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, current_level FROM class_modules WHERE class_id = ? AND module_id = ?');
|
|
$cm->execute([$classId, 'vulkan']);
|
|
$cmRow = $cm->fetch(PDO::FETCH_ASSOC);
|
|
if ($cmRow) {
|
|
$mode = $cmRow['mode'];
|
|
if ($mode === 'teacher_started') $forcedLevel = (int)($cmRow['current_level'] ?? 1);
|
|
}
|
|
$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');
|
|
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Gesperrt · Vulkan</title></head><body style="font-family:sans-serif;padding:40px;max-width:640px;margin:auto;color:#333"><h1>🔒 Vulkan ist gesperrt.</h1><p>Deine Lehrkraft hat dieses Modul für eure Klasse noch nicht freigegeben.</p><p>Im <a href="' . BASE_PATH . '/schueler">Cockpit</a> findest du die derzeit freigegebenen Module.</p></body></html>';
|
|
exit;
|
|
}
|
|
|
|
$gamePath = __DIR__ . '/../sims/vulkan/game.html';
|
|
if (!is_file($gamePath)) {
|
|
http_response_code(503);
|
|
echo 'Vulkan-Sim noch in Vorbereitung.';
|
|
exit;
|
|
}
|
|
|
|
$html = file_get_contents($gamePath);
|
|
|
|
$modeJs = json_encode($mode);
|
|
$forcedLevelJs = json_encode($forcedLevel);
|
|
$easyJs = $easy ? 'true' : 'false';
|
|
$sessionIdJs = json_encode($sessionId);
|
|
$baseSim = BASE_PATH . '/sims/vulkan/';
|
|
$injection =
|
|
"window.VULKAN_BASE = '$baseSim';\n" .
|
|
"window.VULKAN_SESSION_MODE = {$modeJs};\n" .
|
|
"window.VULKAN_FORCED_LEVEL = {$forcedLevelJs};\n" .
|
|
"window.VULKAN_SESSION_ID = {$sessionIdJs};\n" .
|
|
"window.STUDENT_EASY = {$easyJs};\n" .
|
|
"window.VULKAN_API_BASE = '" . BASE_PATH . "/php/api';";
|
|
|
|
if (strpos($html, '/*__VULKAN_INJECTION__*/') !== false) {
|
|
$html = str_replace('/*__VULKAN_INJECTION__*/', $injection, $html);
|
|
} else {
|
|
$html = str_replace('</head>', "<script>$injection</script>\n</head>", $html);
|
|
}
|
|
|
|
// Asset-Pfade + Sim-eigene Scripts umbiegen (relative Pfade werden vom
|
|
// Wrapper-URL aus aufgeloest, was 404 ergibt — daher auf absolute Pfade rewriten)
|
|
$html = preg_replace("/(['\"])assets\//", "$1{$baseSim}assets/", $html);
|
|
$html = str_replace('src="task-overlay.js"', 'src="' . $baseSim . 'task-overlay.js"', $html);
|
|
|
|
if (function_exists('ggs_inject_live')) $html = ggs_inject_live($html, 'vulkan');
|
|
echo $html;
|