From 7f80b189907e4cf8c9fb63c7cfa2c1d735b63824 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 22 Apr 2022 14:35:44 +0200 Subject: [PATCH] Fix: code apo multiples par modules et UE --- app/scodoc/sco_apogee_csv.py | 43 +++++++++++++++++++++--------------- sco_version.py | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index d9c176eb..7fe9501d 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -396,7 +396,7 @@ class ApoEtud(dict): # Element etape (annuel ou non): if sco_formsemestre.sem_has_etape(sem, code) or ( - code in sem["elt_annee_apo"].split(",") + code in {x.strip() for x in sem["elt_annee_apo"].split(",")} ): export_res_etape = self.export_res_etape if (not export_res_etape) and cur_sem: @@ -412,7 +412,7 @@ class ApoEtud(dict): return VOID_APO_RES # Element semestre: - if code in sem["elt_sem_apo"].split(","): + if code in {x.strip() for x in sem["elt_sem_apo"].split(",")}: if self.export_res_sem: return self.comp_elt_semestre(nt, decision, etudid) else: @@ -421,7 +421,9 @@ class ApoEtud(dict): # Elements UE decisions_ue = nt.get_etud_decision_ues(etudid) for ue in nt.get_ues_stat_dict(): - if ue["code_apogee"] and code in ue["code_apogee"].split(","): + if ue["code_apogee"] and code in { + x.strip() for x in ue["code_apogee"].split(",") + }: if self.export_res_ues: if decisions_ue and ue["ue_id"] in decisions_ue: ue_status = nt.get_etud_ue_status(etudid, ue["ue_id"]) @@ -442,9 +444,10 @@ class ApoEtud(dict): modimpls = nt.get_modimpls_dict() module_code_found = False for modimpl in modimpls: - if modimpl["module"]["code_apogee"] and code in modimpl["module"][ - "code_apogee" - ].split(","): + module = modimpl["module"] + if module["code_apogee"] and code in { + x.strip() for x in module["code_apogee"].split(",") + }: n = nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid) if n != "NI" and self.export_res_modules: return dict(N=self.fmt_note(n), B=20, J="", R="") @@ -949,8 +952,9 @@ class ApoData(object): return maq_elems, sem_elems def get_codes_by_sem(self): - """Pour chaque semestre associé, donne l'ensemble des codes Apogée qui s'y trouvent - (dans le semestre, les UE et les modules) + """Pour chaque semestre associé, donne l'ensemble des codes de cette maquette Apogée + qui s'y trouvent (dans le semestre, les UE ou les modules). + Return: { formsemestre_id : { 'code1', 'code2', ... }} """ codes_by_sem = {} for sem in self.sems_etape: @@ -961,8 +965,8 @@ class ApoData(object): # associé à l'étape, l'année ou les semestre: if ( sco_formsemestre.sem_has_etape(sem, code) - or (code in sem["elt_sem_apo"].split(",")) - or (code in sem["elt_annee_apo"].split(",")) + or (code in {x.strip() for x in sem["elt_sem_apo"].split(",")}) + or (code in {x.strip() for x in sem["elt_annee_apo"].split(",")}) ): s.add(code) continue @@ -970,17 +974,20 @@ class ApoData(object): formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"]) nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) for ue in nt.get_ues_stat_dict(): - if ue["code_apogee"] and code in ue["code_apogee"].split(","): - s.add(code) - continue + if ue["code_apogee"]: + codes = {x.strip() for x in ue["code_apogee"].split(",")} + if code in codes: + s.add(code) + continue # associé à un module: modimpls = nt.get_modimpls_dict() for modimpl in modimpls: - if modimpl["module"]["code_apogee"] and code in modimpl["module"][ - "code_apogee" - ].split(","): - s.add(code) - continue + module = modimpl["module"] + if module["code_apogee"]: + codes = {x.strip() for x in module["code_apogee"].split(",")} + if code in codes: + s.add(code) + continue # log('codes_by_sem=%s' % pprint.pformat(codes_by_sem)) return codes_by_sem diff --git a/sco_version.py b/sco_version.py index d71de0d0..df7bcd01 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.10" +SCOVERSION = "9.2.11" SCONAME = "ScoDoc"