From d61f3306ce88c16bee514c8b794fb369e06fe55f Mon Sep 17 00:00:00 2001 From: MatsuneMikuroi Date: Mon, 11 May 2026 23:23:09 +0200 Subject: [PATCH] changed block mean formula --- index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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'