Aufgabe: Ab-wann + Bis-wann mit gutem Picker; neue Klasse nur Weltkueche frei

- Modal: "Ab wann" (Sofort/Zeitpunkt) + "Bis wann" (Presets + date/time statt
  datetime-local), Live-Zusammenfassung; zukuenftiger Start => vorbereitet
- assignments.php: startsAt-Param (Default NOW()), T->Space
- modules.php: neue Klasse ohne Eintrag -> nur Weltkueche frei (_defaultMode),
  Rest gesperrt; Freigabe-Matrix bleibt (getrennt von der Aufgabe)
- schueler.html: Hinweis "Deine Lehrperson kann weitere Simulationen freischalten"

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 17:39:28 +02:00
parent 7f774c7b2a
commit 405fcc2b69
4 changed files with 87 additions and 30 deletions
+14 -5
View File
@@ -50,7 +50,9 @@ if ($method === 'POST') {
$classId = (int)($body['classId'] ?? 0);
$moduleId = $body['moduleId'] ?? '';
$level = max(1, min(5, (int)($body['level'] ?? 1)));
$endsAt = !empty($body['endsAt']) ? $body['endsAt'] : null;
// datetime-local liefert 'YYYY-MM-DDTHH:MM' → 'T' für MySQL zu Leerzeichen.
$endsAt = !empty($body['endsAt']) ? str_replace('T', ' ', $body['endsAt']) : null;
$startsAt = !empty($body['startsAt']) ? str_replace('T', ' ', $body['startsAt']) : null;
if (!$classId || !$moduleId) Response::error('classId und moduleId erforderlich');
@@ -63,10 +65,17 @@ if ($method === 'POST') {
[$classId, $moduleId]
);
$db->execute(
'INSERT INTO class_assignments (class_id, teacher_id, module_id, level, starts_at, ends_at) VALUES (?, ?, ?, ?, NOW(), ?)',
[$classId, $teacherId, $moduleId, $level, $endsAt]
);
if ($startsAt) {
$db->execute(
'INSERT INTO class_assignments (class_id, teacher_id, module_id, level, starts_at, ends_at) VALUES (?, ?, ?, ?, ?, ?)',
[$classId, $teacherId, $moduleId, $level, $startsAt, $endsAt]
);
} else {
$db->execute(
'INSERT INTO class_assignments (class_id, teacher_id, module_id, level, starts_at, ends_at) VALUES (?, ?, ?, ?, NOW(), ?)',
[$classId, $teacherId, $moduleId, $level, $endsAt]
);
}
Response::ok(['id' => (int)$db->lastInsertId()]);
}