Energiemanager: Blackouts fuer Lehrer sichtbar machen
- game.html: bei Blackout sofort action:'blackout' an /progress feuern (setId/Tag/Block/Frequenz/Ursache, score:0) — Fehlversuch bleibt auch bei Set-Abbruch sichtbar, kein player_progress/Sterne. - progress.php: neuer action:'blackout' -> eigene assessments-Zeile, KEIN XP/plays/best_stars. - live.php: Blackout-Flag (event:'blackout') durch die Tag-Summary reichen (blackout/blackoutCount pro Session). - teacher.html: needsHelp energiemanager (>=2 Blackouts oder Tag <4/8); Blackout-Spalte + '🔌 neu planen'-Status in Aktuell; Tag-Balken als 🔌 Blackout kennzeichnen; Run-Karte: eigenes Blackout-Kaertchen + '🔌 N Blackouts'-Badge im fertigen Set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -211,6 +211,8 @@ if ($method === 'GET') {
|
||||
'score' => null,
|
||||
'durationMs' => 0,
|
||||
'completed' => null,
|
||||
'blackout' => false,
|
||||
'blackoutCount' => 0,
|
||||
'rowCount' => 0,
|
||||
];
|
||||
}
|
||||
@@ -224,6 +226,9 @@ if ($method === 'GET') {
|
||||
if ($dmv > $currentSess['durationMs']) $currentSess['durationMs'] = $dmv;
|
||||
$cp = $extractCompleted($row);
|
||||
if ($cp !== null) $currentSess['completed'] = $cp;
|
||||
// Blackout-Fehlversuch (Energiemanager) markieren.
|
||||
$rEvt = $row['results'] ? json_decode($row['results'], true) : [];
|
||||
if (($rEvt['event'] ?? '') === 'blackout') { $currentSess['blackout'] = true; $currentSess['blackoutCount']++; }
|
||||
$prevTs = $ts;
|
||||
}
|
||||
if ($currentSess !== null) $sessions[] = $currentSess;
|
||||
@@ -276,6 +281,8 @@ if ($method === 'GET') {
|
||||
'stars' => $s['stars'],
|
||||
'score' => $s['score'],
|
||||
'completed' => $s['completed'],
|
||||
'blackout' => $s['blackout'],
|
||||
'blackoutCount' => $s['blackoutCount'],
|
||||
'success' => $success,
|
||||
'rowCount' => $s['rowCount'],
|
||||
];
|
||||
|
||||
@@ -162,6 +162,26 @@ if ($method === 'POST') {
|
||||
}
|
||||
|
||||
// === Pre/Post-Antworten speichern ===
|
||||
// === Blackout (Energiemanager): Fehlversuch sofort protokollieren ===
|
||||
// Ein Blackout beendet das Set NICHT — die Schüler:in plant neu. Damit der
|
||||
// Fehlversuch aber auch bei Abbruch beim Lehrer sichtbar bleibt, schreiben
|
||||
// wir ihn als eigene assessments-Zeile (score:0 → roter Tag-Balken).
|
||||
// KEIN player_progress-Update: ein Blackout gibt weder Sterne noch XP.
|
||||
if ($action === 'blackout') {
|
||||
$sessionId = Session::requireStudent();
|
||||
$simId = $body['simId'] ?? '';
|
||||
if (!$simId) Response::error('simId erforderlich');
|
||||
$session = $db->fetchOne('SELECT class_id FROM student_sessions WHERE id = ?', [$sessionId]);
|
||||
if (!defined('GGS_MAX_SESSION_MS')) define('GGS_MAX_SESSION_MS', 7200000);
|
||||
$durationMs = max(0, min((int)($body['durationMs'] ?? 0), GGS_MAX_SESSION_MS));
|
||||
$data = json_encode($body['data'] ?? []);
|
||||
$db->execute(
|
||||
'INSERT INTO assessments (session_id, sim_id, class_id, results, duration_ms, submitted_at) VALUES (?, ?, ?, ?, ?, NOW())',
|
||||
[$sessionId, $simId, $session['class_id'] ?? null, $data, $durationMs]
|
||||
);
|
||||
Response::ok(['recorded' => 'blackout']);
|
||||
}
|
||||
|
||||
if ($action === 'answer') {
|
||||
$sessionId = Session::requireStudent();
|
||||
$simId = $body['simId'] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user