From a2f07cea645c0e0ecb8dc796e0d4c63660afffa4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 24 Jun 2024 02:07:34 +0200 Subject: [PATCH] =?UTF-8?q?Export=20Apog=C3=A9e:=20n'exporte=20rien=20sur?= =?UTF-8?q?=20les=20UEs=20dispens=C3=A9es.=20Closes=20#626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_apogee_csv.py | 68 +++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index 05707705a..c56f497f0 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -327,34 +327,9 @@ class ApoEtud(dict): return VOID_APO_RES # Elements UE - decisions_ue = res.get_etud_decisions_ue(etudid) - for ue in res.get_ues_stat_dict(): - 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 - ) or self.export_res_sdj: - ue_status = res.get_etud_ue_status(etudid, ue["ue_id"]) - if decisions_ue and ue["ue_id"] in decisions_ue: - code_decision_ue = decisions_ue[ue["ue_id"]]["code"] - code_decision_ue_apo = ScoDocSiteConfig.get_code_apo( - code_decision_ue - ) - else: - code_decision_ue_apo = "" - return dict( - N=self.fmt_note(ue_status["moy"] if ue_status else ""), - B=20, - J="", - R=code_decision_ue_apo, - M="", - ) - else: - return VOID_APO_RES - else: - return VOID_APO_RES + res_ue = self.search_elt_ue(code, res) + if res_ue != {}: + return res_ue # Elements Modules modimpls = res.get_modimpls_dict() @@ -391,6 +366,43 @@ class ApoEtud(dict): # return None # element Apogee non trouvé dans ce semestre + def search_elt_ue(self, code: str, res: NotesTableCompat) -> dict: + """Cherche un résultat d'UE pour ce code Apogée. + dict vide si pas de résultat trouvé pour ce code. + """ + decisions_ue = res.get_etud_decisions_ue(self.etud.id) + for ue in res.get_ues_stat_dict(): + 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 + ) or self.export_res_sdj: + # Si dispensé de cette UE, n'exporte rien + if (self.etud.id, ue["ue_id"]) in res.dispense_ues: + return VOID_APO_RES + ue_status = res.get_etud_ue_status(self.etud.id, ue["ue_id"]) + if decisions_ue and ue["ue_id"] in decisions_ue: + code_decision_ue = decisions_ue[ue["ue_id"]]["code"] + code_decision_ue_apo = ScoDocSiteConfig.get_code_apo( + code_decision_ue + ) + else: + code_decision_ue_apo = "" + return dict( + N=self.fmt_note(ue_status["moy"] if ue_status else ""), + B=20, + J="", + R=code_decision_ue_apo, + M="", + ) + else: + return VOID_APO_RES + else: + return VOID_APO_RES + return {} # no UE result found for this code + def comp_elt_semestre(self, nt: NotesTableCompat, decision: dict, etudid: int): """Calcul résultat apo semestre. Toujours vide pour en BUT/APC.