Weltkueche Teil A: Land pro Lehrer persistent (teachers.country) + Sim-Verdrahtung

- profil.html: Länderauswahl (AT/DE/CH/LI) im Lehrer-Profil, lädt/zeigt aktuelles Land.
- profile.php: speichert country in teachers.country; gibt country zurück.
- weltkueche.php: injiziert window.WK_COUNTRY = Country::current() (Kaskade Schüler→Klasse→Lehrer→AT) — Fundament für die konsumentenland-basierte Herkunft (Teil B).
Spalte teachers.country existierte bereits, keine Migration nötig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 12:13:27 +02:00
parent c3e61f4da7
commit a68c58ac9e
3 changed files with 13 additions and 2 deletions
+5 -1
View File
@@ -57,7 +57,7 @@ if ($method === 'GET') {
if ($teacherId) {
$teacher = $db->fetchOne(
'SELECT id, username, email, display_name, school_name, emoji_avatar, created_at FROM teachers WHERE id = ?',
'SELECT id, username, email, display_name, school_name, emoji_avatar, country, created_at FROM teachers WHERE id = ?',
[$teacherId]
);
Response::ok(['role' => 'teacher', 'profile' => $teacher]);
@@ -111,6 +111,10 @@ if ($method === 'POST') {
if ($displayName) $db->execute('UPDATE teachers SET display_name = ? WHERE id = ?', [$displayName, $teacherId]);
if ($schoolName !== '') $db->execute('UPDATE teachers SET school_name = ? WHERE id = ?', [$schoolName, $teacherId]);
if (isset($body['country'])) {
$cc = strtoupper(trim((string)$body['country']));
if (in_array($cc, ['AT','DE','CH','LI'], true)) $db->execute('UPDATE teachers SET country = ? WHERE id = ?', [$cc, $teacherId]);
}
if ($email) {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) Response::error('Ungültige E-Mail-Adresse');
$existing = $db->fetchOne('SELECT id FROM teachers WHERE email = ? AND id != ?', [$email, $teacherId]);