From 129a39f7f0d0f67ffefa1c06482c3439c4db4e06 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 13 Feb 2022 22:25:51 +0100 Subject: [PATCH] Fix: robustifie get_evals_in_mod --- app/comp/res_common.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 0adf82da5..09a06e796 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -9,6 +9,7 @@ from functools import cached_property import numpy as np import pandas as pd +from app import log from app.comp.aux_stats import StatsMoyenne from app.comp import moy_sem from app.comp.res_cache import ResultatsCache @@ -19,8 +20,7 @@ from app.models import FormSemestreUECoef from app.models.ues import UniteEns from app.scodoc import sco_utils as scu from app.scodoc.sco_cache import ResultatsSemestreCache -from app.scodoc.sco_codes_parcours import UE_SPORT, ATT, DEF -from app.scodoc.sco_exceptions import ScoValueError +from app.scodoc.sco_codes_parcours import UE_SPORT, DEF # Il faut bien distinguer # - 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. """ modimpl = ModuleImpl.query.get(moduleimpl_id) + modimpl_results = self.modimpls_results.get(moduleimpl_id) + if not modimpl_results: + return [] # safeguard evals_results = [] 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() - moduleimpl_results = self.modimpls_results[e.moduleimpl_id] d["heure_debut"] = e.heure_debut # datetime.time d["heure_fin"] = e.heure_fin d["jour"] = e.jour # datetime d["notes"] = { 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 } d["etat"] = { - "evalattente": moduleimpl_results.evaluations_etat[e.id].nb_attente, + "evalattente": modimpl_results.evaluations_etat[e.id].nb_attente, } 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 def get_evaluations_etats(self):