Fix: robustifie get_evals_in_mod

This commit is contained in:
Emmanuel Viennet 2022-02-13 22:25:51 +01:00
parent f3d2420117
commit 129a39f7f0

View File

@ -9,6 +9,7 @@ from functools import cached_property
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from app import log
from app.comp.aux_stats import StatsMoyenne from app.comp.aux_stats import StatsMoyenne
from app.comp import moy_sem from app.comp import moy_sem
from app.comp.res_cache import ResultatsCache from app.comp.res_cache import ResultatsCache
@ -19,8 +20,7 @@ from app.models import FormSemestreUECoef
from app.models.ues import UniteEns from app.models.ues import UniteEns
from app.scodoc import sco_utils as scu from app.scodoc import sco_utils as scu
from app.scodoc.sco_cache import ResultatsSemestreCache from app.scodoc.sco_cache import ResultatsSemestreCache
from app.scodoc.sco_codes_parcours import UE_SPORT, ATT, DEF from app.scodoc.sco_codes_parcours import UE_SPORT, DEF
from app.scodoc.sco_exceptions import ScoValueError
# Il faut bien distinguer # Il faut bien distinguer
# - ce qui est caché de façon persistente (via redis): # - ce qui est caché de façon persistente (via redis):
@ -554,25 +554,32 @@ class NotesTableCompat(ResultatsSemestre):
Évaluation "complete" ssi toutes notes saisies ou en attente. Évaluation "complete" ssi toutes notes saisies ou en attente.
""" """
modimpl = ModuleImpl.query.get(moduleimpl_id) modimpl = ModuleImpl.query.get(moduleimpl_id)
modimpl_results = self.modimpls_results.get(moduleimpl_id)
if not modimpl_results:
return [] # safeguard
evals_results = [] evals_results = []
for e in modimpl.evaluations: for e in modimpl.evaluations:
if self.modimpls_results[moduleimpl_id].evaluations_completes_dict[e.id]: if modimpl_results.evaluations_completes_dict.get(e.id, False):
d = e.to_dict() d = e.to_dict()
moduleimpl_results = self.modimpls_results[e.moduleimpl_id]
d["heure_debut"] = e.heure_debut # datetime.time d["heure_debut"] = e.heure_debut # datetime.time
d["heure_fin"] = e.heure_fin d["heure_fin"] = e.heure_fin
d["jour"] = e.jour # datetime d["jour"] = e.jour # datetime
d["notes"] = { d["notes"] = {
etud.id: { etud.id: {
"etudid": etud.id, "etudid": etud.id,
"value": moduleimpl_results.evals_notes[e.id][etud.id], "value": modimpl_results.evals_notes[e.id][etud.id],
} }
for etud in self.etuds for etud in self.etuds
} }
d["etat"] = { d["etat"] = {
"evalattente": moduleimpl_results.evaluations_etat[e.id].nb_attente, "evalattente": modimpl_results.evaluations_etat[e.id].nb_attente,
} }
evals_results.append(d) evals_results.append(d)
elif e.id not in modimpl_results.evaluations_completes_dict:
# ne devrait pas arriver ? XXX
log(
f"Warning: 220213 get_evals_in_mod {e.id} not in mod {moduleimpl_id} ?"
)
return evals_results return evals_results
def get_evaluations_etats(self): def get_evaluations_etats(self):