Liste notes BUT: ajout moyennes des moyennes d'UE

This commit is contained in:
Emmanuel Viennet 2022-03-23 23:02:10 +01:00
parent a07c2c247f
commit 62feba8f33

View File

@ -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] = ""