changed block mean formula

This commit is contained in:
2026-05-11 23:23:09 +02:00
parent c957bc97d3
commit d61f3306ce
+4 -1
View File
@@ -447,7 +447,10 @@ function save() {
function blockMean(blockId) { function blockMean(blockId) {
const graded = S.courses.filter(c => c.blockId === blockId && c.grade != null && c.grade !== ''); const graded = S.courses.filter(c => c.blockId === blockId && c.grade != null && c.grade !== '');
if (!graded.length) return null; if (!graded.length) return null;
return graded.reduce((s, c) => s + +c.grade, 0) / graded.length; const sumWeighted = graded.reduce((s, c) => s + +c.grade * (+c.credits || 0), 0);
const sumCoef = graded.reduce((s, c) => s + (+c.credits || 0), 0);
if (sumCoef === 0) return null;
return sumWeighted / sumCoef;
} }
// status: 'pass' | 'fail' | 'prog' // status: 'pass' | 'fail' | 'prog'