From 62feba8f3387e66b679fac34546eb02a8b671ef0 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 23 Mar 2022 23:02:10 +0100 Subject: [PATCH] Liste notes BUT: ajout moyennes des moyennes d'UE --- app/scodoc/sco_liste_notes.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 29de5158..8818abf4 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -27,6 +27,8 @@ """Liste des notes d'une évaluation """ +from collections import defaultdict +import numpy as np import flask from flask import url_for, g, request @@ -848,15 +850,8 @@ def _add_apc_columns( nt: NotesTableCompat = res_sem.load_formsemestre_results(modimpl.formsemestre) modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl.id] - # XXX A ENLEVER TODO - # modimpl = ModuleImpl.query.get(moduleimpl_id) - - # evals_notes, evaluations, evaluations_completes = moy_mod.df_load_modimpl_notes( - # moduleimpl_id - # ) - # etuds_moy_module = moy_mod.compute_module_moy( - # evals_notes, evals_poids, evaluations, evaluations_completes - # ) + sum_by_ue = defaultdict(float) + nb_notes_by_ue = defaultdict(int) if is_conforme: # valeur des moyennes vers les UEs: for row in rows: @@ -864,6 +859,9 @@ def _add_apc_columns( moy_ue = modimpl_results.etuds_moy_module[ue.id].get(row["etudid"], "?") row[f"moy_ue_{ue.id}"] = scu.fmt_note(moy_ue, keep_numeric=keep_numeric) row[f"_moy_ue_{ue.id}_class"] = "moy_ue" + if isinstance(moy_ue, float) and not np.isnan(moy_ue): + sum_by_ue[ue.id] += moy_ue + nb_notes_by_ue[ue.id] += 1 # Nom et coefs des UE (lignes titres): ue_coefs = modimpl.module.ue_coefs if is_conforme: @@ -878,3 +876,9 @@ def _add_apc_columns( if coefs: row_coefs[f"moy_ue_{ue.id}"] = coefs[0].coef row_coefs[f"_moy_ue_{ue.id}_td_attrs"] = f' class="{coef_class}" ' + modimpl_results.etuds_moy_module[ue.id] + if nb_notes_by_ue[ue.id] > 0: + row_moys[col_id] = "%.3g" % (sum_by_ue[ue.id] / nb_notes_by_ue[ue.id]) + row_moys["_" + col_id + "_help"] = "moyenne des moyennes" + else: + row_moys[col_id] = ""