From 177f23b48c8987e3218cc79757a3a5f823a2af6b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 6 Dec 2021 10:57:10 +0100 Subject: [PATCH] json: formatte notes en txt --- app/but/bulletin_but.py | 30 +++++++++++++++--------------- app/scodoc/sco_utils.py | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 20e8d4917..a56365854 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -15,7 +15,7 @@ from app.scodoc import sco_utils as scu from app.scodoc.sco_cache import ResultatsSemestreBUTCache from app.scodoc.sco_exceptions import ScoFormatError from app.scodoc import sco_preferences -from app.scodoc.sco_utils import jsnan +from app.scodoc.sco_utils import jsnan, fmt_note class ResultatsSemestreBUT: @@ -102,7 +102,7 @@ class ResultatsSemestreBUT: d[mi.module.code] = { "id": mi.id, "coef": coef, - "moyenne": jsnan( + "moyenne": fmt_note( etud_moy_module[self.modimpl_coefs_df.columns.get_loc(mi.id)][ ue_idx ] @@ -119,7 +119,7 @@ class ResultatsSemestreBUT: "total": ue.ects, }, "competence": None, # XXX TODO lien avec référentiel - "moyenne": jsnan(self.etud_moy_ue[ue.id].mean()), + "moyenne": fmt_note(self.etud_moy_ue[ue.id].mean()), "bonus": None, # XXX TODO "malus": None, # XXX TODO voir ce qui est ici "capitalise": None, # "AAAA-MM-JJ" TODO @@ -145,10 +145,10 @@ class ResultatsSemestreBUT: "titre": mi.module.titre, "code_apogee": mi.module.code_apogee, "moyenne": { - "value": jsnan(self.sem_cube[etud_idx, mod_idx].mean()), - "min": jsnan(moyennes_etuds.min()), - "max": jsnan(moyennes_etuds.max()), - "moy": jsnan(moyennes_etuds.mean()), + "value": fmt_note(self.sem_cube[etud_idx, mod_idx].mean()), + "min": fmt_note(moyennes_etuds.min()), + "max": fmt_note(moyennes_etuds.max()), + "moy": fmt_note(moyennes_etuds.mean()), }, "evaluations": [ self.etud_eval_results(etud, e) @@ -171,12 +171,12 @@ class ResultatsSemestreBUT: "coef": e.coefficient, "poids": {p.ue.acronyme: p.poids for p in e.ue_poids}, "note": { - "value": jsnan( + "value": fmt_note( self.modimpls_evals_notes[e.moduleimpl_id][str(e.id)][etud.id] ), - "min": jsnan(notes_ok.min()), - "max": jsnan(notes_ok.max()), - "moy": jsnan(notes_ok.mean()), + "min": fmt_note(notes_ok.min()), + "max": fmt_note(notes_ok.max()), + "moy": fmt_note(notes_ok.mean()), }, } return d @@ -200,10 +200,10 @@ class ResultatsSemestreBUT: "ues": {ue.acronyme: self.etud_ue_results(etud, ue) for ue in self.ues}, "semestre": { "notes": { # moyenne des moyennes générales du semestre - "value": jsnan("xxx"), # XXX TODO - "min": jsnan("0."), - "moy": jsnan("10.0"), - "max": jsnan("20.00"), + "value": fmt_note("xxx"), # XXX TODO + "min": fmt_note("0."), + "moy": fmt_note("10.0"), + "max": fmt_note("20.00"), }, "rang": { # classement wrt moyenne général, indicatif "value": None, # XXX TODO diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 9a7596c7b..ab8dad994 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -170,7 +170,7 @@ def fmt_note(val, note_max=None, keep_numeric=False): return "ATT" # attente, note neutralisee if isinstance(val, float) or isinstance(val, int): if np.isnan(val): - return "/" + return "~" if note_max != None and note_max > 0: val = val * 20.0 / note_max if keep_numeric: