From 920aeb066ffbb161a13fe75bd19d61f96262d19e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 29 Jan 2022 23:36:07 +0100 Subject: [PATCH] =?UTF-8?q?Bul.=20BUT:=20n'affiche=20que=20les=20UE=20dans?= =?UTF-8?q?=20lesquelles=20on=20est=20inscrit=20=C3=A0=20au=20moins=20un?= =?UTF-8?q?=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/bulletin_but.py | 14 ++++++++++---- app/comp/inscr_mod.py | 2 ++ app/comp/res_common.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 14e9429d82..cc51e2a28f 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -32,7 +32,7 @@ class BulletinBUT(ResultatsSemestreBUT): ue_idx = self.modimpl_coefs_df.index.get_loc(ue.id) etud_moy_module = self.sem_cube[etud_idx] # module x UE for modimpl in modimpls: - if self.modimpl_inscr_df[str(modimpl.id)][etud.id]: # si inscrit + if self.modimpl_inscr_df[modimpl.id][etud.id]: # si inscrit if ue.type != UE_SPORT: coef = self.modimpl_coefs_df[modimpl.id][ue.id] if coef > 0: @@ -115,7 +115,7 @@ class BulletinBUT(ResultatsSemestreBUT): # except RuntimeWarning: # all nans in np.nanmean # pass modimpl_results = self.modimpls_results[modimpl.id] - if self.modimpl_inscr_df[str(modimpl.id)][etud.id]: # si inscrit + if self.modimpl_inscr_df[modimpl.id][etud.id]: # si inscrit d[modimpl.module.code] = { "id": modimpl.id, "titre": modimpl.module.titre, @@ -183,7 +183,9 @@ class BulletinBUT(ResultatsSemestreBUT): details = [ f"{fmt_note(bonus_vect[ue.id])} sur {ue.acronyme}" for ue in self.ues - if ue.id in self.bonus_ues and bonus_vect[ue.id] > 0.0 + if self.modimpls_in_ue(ue.id, etudid) + and ue.id in self.bonus_ues + and bonus_vect[ue.id] > 0.0 ] if details: return "Bonus de " + ", ".join(details) @@ -256,7 +258,11 @@ class BulletinBUT(ResultatsSemestreBUT): "ressources": self.etud_mods_results(etud, self.ressources), "saes": self.etud_mods_results(etud, self.saes), "ues": { - ue.acronyme: self.etud_ue_results(etud, ue) for ue in self.ues + ue.acronyme: self.etud_ue_results(etud, ue) + for ue in self.ues + if self.modimpls_in_ue( + ue.id, etud.id + ) # si l'UE comporte des modules auxquels on est inscrit }, "semestre": semestre_infos, }, diff --git a/app/comp/inscr_mod.py b/app/comp/inscr_mod.py index b9be1e9f02..667eacbd04 100644 --- a/app/comp/inscr_mod.py +++ b/app/comp/inscr_mod.py @@ -35,6 +35,8 @@ def df_load_modimpl_inscr(formsemestre) -> pd.DataFrame: dtype=int, ) df = df.merge(ins_df, how="left", left_index=True, right_index=True) + # Force columns names to integers (moduleimpl ids) + df.columns = pd.Int64Index([int(x) for x in df.columns], dtype="int") # les colonnes de df sont en float (Nan) quand il n'y a # aucun inscrit au module. df.fillna(0, inplace=True) # les non-inscrits diff --git a/app/comp/res_common.py b/app/comp/res_common.py index a90ce1c122..7bc2bff2c4 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -130,6 +130,16 @@ class ResultatsSemestre: """ return self.formsemestre.query_ues().filter(UniteEns.type != UE_SPORT).all() + def modimpls_in_ue(self, ue_id, etudid): + """Liste des modimpl de cet ue auxquels l'étudiant est inscrit""" + # sert pour l'affichage ou non de l'UE sur le bulletin + return [ + modimpl + for modimpl in self.formsemestre.modimpls_sorted + if modimpl.module.ue.id == ue_id + and self.modimpl_inscr_df[modimpl.id][etudid] + ] + @cached_property def ue_au_dessus(self, seuil=10.0) -> pd.DataFrame: """DataFrame columns UE, rows etudid, valeurs: bool