diff --git a/index.html b/index.html index f7a3ec9..58ad16f 100644 --- a/index.html +++ b/index.html @@ -447,7 +447,10 @@ function save() { function blockMean(blockId) { const graded = S.courses.filter(c => c.blockId === blockId && c.grade != null && c.grade !== ''); 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'