Fix: alle heutigen Leistungen zaehlen (Ben) + Live-Session started_at bei Modulwechsel (Clara)
- live.php: ON DUPLICATE KEY UPDATE-Reihenfolge korrigiert (started_at VOR module_id), sonst wird der Modulwechsel nie erkannt -> Balken behielt alten Startzeitpunkt (Clara EU-Werkstatt seit 14:30). - results.php view=today: liefert todayScores (Pro-Schueler-Aggregat aus student_results, zuverlaessig). - teacher.html HEUTE-Triage: fertige Laeufe aus student_results + laufende aus Summary zusammengefuehrt; Totalversagen heute (<40) -> Foerdern. Ben (klima 36) erscheint jetzt korrekt in Foerdern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+29
-11
@@ -2827,7 +2827,7 @@ function _todayHelpReason(simId, st){
|
||||
}
|
||||
return 'stockt · braucht evtl. Hilfe';
|
||||
}
|
||||
function ivBuildOverview(cockpit, weeks, studentsCount, matrix, todaySummary){
|
||||
function ivBuildOverview(cockpit, weeks, studentsCount, matrix, todaySummary, today){
|
||||
ivInjectCss();
|
||||
var cs = (cockpit && cockpit.students) || [];
|
||||
var sc = (cockpit && cockpit.statusCounts) || {};
|
||||
@@ -2895,15 +2895,30 @@ function ivBuildOverview(cockpit, weeks, studentsCount, matrix, todaySummary){
|
||||
h+='<div class="iv-stat"><span class="iv-lab">Simulationen</span><div class="iv-gfx"><span class="iv-bign num">'+simTotal+'</span></div><span class="iv-exp">Durchläufe insgesamt</span></div>';
|
||||
h+='</div>';
|
||||
// Triage
|
||||
// === HEUTE-Triage: gleiche Logik, aber nur auf die HEUTIGEN Läufe bezogen ===
|
||||
var todayErfById={}, todayPlaysById={};
|
||||
// === HEUTE-Triage: ALLE heutigen Läufe. Quelle 1 = student_results (fertige
|
||||
// Läufe, zuverlässig mit student_id); Quelle 2 = Summary NUR für laufende
|
||||
// Sessions (die stehen noch nicht in student_results) → kein Doppelzählen. ===
|
||||
var _tScore={}, _tPlays={}, _tMin={};
|
||||
var _tsrc=(today&&today.todayScores)||{};
|
||||
Object.keys(_tsrc).forEach(function(sid){
|
||||
var t=_tsrc[sid]; _tPlays[sid]=(_tPlays[sid]||0)+(t.plays||0);
|
||||
_tScore[sid]=(_tScore[sid]||0)+(t.avgScore||0)*(t.plays||0);
|
||||
if(t.minScore!=null) _tMin[sid]=Math.min(_tMin[sid]==null?100:_tMin[sid], t.minScore);
|
||||
});
|
||||
((todaySummary&&todaySummary.students)||[]).forEach(function(su){
|
||||
var sess=(su.sessions||[]).filter(function(x){ return x.startMs; });
|
||||
if(!sess.length) return;
|
||||
var sco=[];
|
||||
sess.forEach(function(x){ var v=(x.score!=null)?x.score:(x.stars!=null?Math.round(x.stars/5*100):null); if(v!=null) sco.push(v); });
|
||||
todayPlaysById[su.studentId]=sess.length;
|
||||
todayErfById[su.studentId]= sco.length? Math.round(sco.reduce(function(a,b){return a+b;},0)/sco.length) : null;
|
||||
(su.sessions||[]).forEach(function(x){
|
||||
if(!x.startMs || !(x.isLive||x.success==='running')) return; // nur laufende
|
||||
var v=(x.score!=null)?x.score:(x.stars!=null?Math.round(x.stars/5*100):null); if(v==null) return;
|
||||
var sid=su.studentId;
|
||||
_tPlays[sid]=(_tPlays[sid]||0)+1; _tScore[sid]=(_tScore[sid]||0)+v;
|
||||
_tMin[sid]=Math.min(_tMin[sid]==null?100:_tMin[sid], v);
|
||||
});
|
||||
});
|
||||
var todayErfById={}, todayPlaysById={}, todayMinById={};
|
||||
Object.keys(_tPlays).forEach(function(sid){
|
||||
todayPlaysById[sid]=_tPlays[sid];
|
||||
todayErfById[sid]=Math.round(_tScore[sid]/Math.max(1,_tPlays[sid]));
|
||||
todayMinById[sid]=_tMin[sid];
|
||||
});
|
||||
var heuteGroups={support:[],more:[],work:[],good:[],calm:[],idle:[]};
|
||||
cs.forEach(function(s){
|
||||
@@ -2912,7 +2927,10 @@ function ivBuildOverview(cockpit, weeks, studentsCount, matrix, todaySummary){
|
||||
var tErf=todayErfById[sid];
|
||||
var w2=wById[sid], secs2=w2?w2.buckets.map(function(b){return Math.min(IV_WEEK_CAP, b.sum||0);}):[];
|
||||
while(secs2.length<10) secs2.unshift(0);
|
||||
var g2 = !played ? 'idle' : ivTriage(tErf, 0, todayPlaysById[sid], false);
|
||||
// Totalversagen heute (ein Lauf < 40) → immer Fördern, egal wie der Schnitt ist.
|
||||
var g2 = !played ? 'idle'
|
||||
: (todayMinById[sid]!=null && todayMinById[sid] < 40) ? 'support'
|
||||
: ivTriage(tErf, 0, todayPlaysById[sid], false);
|
||||
var row2={sid:sid, name:s.displayName, erf:played?tErf:null, status:s.status, secs:secs2, days:played?0:(s.daysSince!=null?s.daysSince:null)};
|
||||
if(g2) heuteGroups[g2].push(row2); else heuteGroups.calm.push(row2);
|
||||
});
|
||||
@@ -3302,7 +3320,7 @@ async function loadOverview() {
|
||||
var html = '';
|
||||
|
||||
// === NEU: Interventions-Übersicht (Erfolg · Aktiv · Verlauf + Triage) ===
|
||||
html += ivBuildOverview(cockpit, weeks, students.length, matrix, todaySum);
|
||||
html += ivBuildOverview(cockpit, weeks, students.length, matrix, todaySum, today);
|
||||
|
||||
// === Sektion B: Aktive Klassen-Simulationen ===
|
||||
var active = (assignments || []).filter(function(a){return a.active;});
|
||||
|
||||
Reference in New Issue
Block a user