fetchOne(
'SELECT class_id, display_name FROM student_sessions WHERE id = ?',
[$sessionId]
);
if ($row) {
$studentName = $row['display_name'] ?: 'Schüler*in';
$classId = (int)$row['class_id'];
}
}
} catch (Exception $e) { /* still als Demo lauffähig */ }
$gamePath = __DIR__ . '/../sims/weltkueche/game.html';
if (!file_exists($gamePath)) {
http_response_code(503);
echo '
Weltküche wird gerade vorbereitet.
Zurück
';
exit;
}
$html = file_get_contents($gamePath);
// Session-Kontext + Plattform-Basis injizieren.
// Setzt sowohl die Weltküche-eigenen WK_*-Vars (legacy) als auch das
// Plattform-Kontext-Objekt __GGS__, ohne das der Live-Client (Heartbeat
// an das Lehrer-Cockpit) still abbricht.
$base = BASE_PATH . '/sims/weltkueche/';
$ggs = [
'sessionId' => $sessionId,
'simId' => 'weltkueche',
'classId' => $classId,
'baseUrl' => BASE_URL,
'basePath' => BASE_PATH,
'apiUrl' => BASE_URL . '/php/api',
'studentName' => $studentName,
'mode' => $mode,
];
$injection = '';
// Asset-Pfade umbiegen (relativ → absolut) — NUR href= und src= Attribute,
// NICHT in JS-Strings. Sonst entstehen doppelte Pfade in fetch()-Calls,
// weil das JS bereits window.WK_BASE davor konkateniert.
$html = preg_replace(
"/(href|src)=([\"'])assets\//",
"$1=$2{$base}assets/",
$html
);
// Injection vor
$html = str_replace('', $injection . "\n", $html);
// Cockpit-Link absolut
$html = str_replace('href="../../schueler.html"', 'href="' . cockpit_href() . '"', $html);
// Live-Heartbeat-Client + Glossar-Tooltip-Standard der Plattform anhängen
$liveScript = '';
$glossarScript = ''
. '';
$html = str_replace('