From 0a1264051c2f6ed010e37c9406be90c03ca2cb84 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 9 Jan 2022 21:48:58 +0100 Subject: [PATCH] =?UTF-8?q?Bulletin=20BUT:=20n'affiche=20que=20les=20modul?= =?UTF-8?q?es=20auxquels=20l'=C3=A9tudiant=20est=20inscrit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/bulletin_but.py | 70 ++++++++++++++++++++------------------- app/models/moduleimpls.py | 3 ++ app/scodoc/sco_edit_ue.py | 8 ++++- sco_version.py | 2 +- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 54d08400f..eac6d52c1 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -107,17 +107,18 @@ class ResultatsSemestreBUT: ue_idx = self.modimpl_coefs_df.index.get_loc(ue.id) etud_moy_module = self.sem_cube[etud_idx] # module x UE for mi in modimpls: - coef = self.modimpl_coefs_df[mi.id][ue.id] - if coef > 0: - d[mi.module.code] = { - "id": mi.id, - "coef": coef, - "moyenne": fmt_note( - etud_moy_module[self.modimpl_coefs_df.columns.get_loc(mi.id)][ - ue_idx - ] - ), - } + if self.modimpl_inscr_df[str(mi.id)][etud.id]: # si inscrit + coef = self.modimpl_coefs_df[mi.id][ue.id] + if coef > 0: + d[mi.module.code] = { + "id": mi.id, + "coef": coef, + "moyenne": fmt_note( + etud_moy_module[ + self.modimpl_coefs_df.columns.get_loc(mi.id) + ][ue_idx] + ), + } return d def etud_ue_results(self, etud, ue): @@ -163,29 +164,30 @@ class ResultatsSemestreBUT: # moy_indicative_mod = np.nanmean(self.sem_cube[etud_idx, mod_idx]) # except RuntimeWarning: # all nans in np.nanmean # pass - d[mi.module.code] = { - "id": mi.id, - "titre": mi.module.titre, - "code_apogee": mi.module.code_apogee, - "url": url_for( - "notes.moduleimpl_status", - scodoc_dept=g.scodoc_dept, - moduleimpl_id=mi.id, - ), - "moyenne": { - # # moyenne indicative de module: moyenne des UE, ignorant celles sans notes (nan) - # "value": fmt_note(moy_indicative_mod), - # "min": fmt_note(moyennes_etuds.min()), - # "max": fmt_note(moyennes_etuds.max()), - # "moy": fmt_note(moyennes_etuds.mean()), - }, - "evaluations": [ - self.etud_eval_results(etud, e) - for eidx, e in enumerate(mi.evaluations) - if e.visibulletin - and self.modimpls_evaluations_complete[mi.id][eidx] - ], - } + if self.modimpl_inscr_df[str(mi.id)][etud.id]: # si inscrit + d[mi.module.code] = { + "id": mi.id, + "titre": mi.module.titre, + "code_apogee": mi.module.code_apogee, + "url": url_for( + "notes.moduleimpl_status", + scodoc_dept=g.scodoc_dept, + moduleimpl_id=mi.id, + ), + "moyenne": { + # # moyenne indicative de module: moyenne des UE, ignorant celles sans notes (nan) + # "value": fmt_note(moy_indicative_mod), + # "min": fmt_note(moyennes_etuds.min()), + # "max": fmt_note(moyennes_etuds.max()), + # "moy": fmt_note(moyennes_etuds.mean()), + }, + "evaluations": [ + self.etud_eval_results(etud, e) + for eidx, e in enumerate(mi.evaluations) + if e.visibulletin + and self.modimpls_evaluations_complete[mi.id][eidx] + ], + } return d def etud_eval_results(self, etud, e) -> dict: diff --git a/app/models/moduleimpls.py b/app/models/moduleimpls.py index 172fe0767..1b888c540 100644 --- a/app/models/moduleimpls.py +++ b/app/models/moduleimpls.py @@ -44,6 +44,9 @@ class ModuleImpl(db.Model): def __init__(self, **kwargs): super(ModuleImpl, self).__init__(**kwargs) + def __repr__(self): + return f"<{self.__class__.__name__} {self.id} module={repr(self.module)}>" + def get_evaluations_poids(self) -> pd.DataFrame: """Les poids des évaluations vers les UE (accès via cache)""" evaluations_poids = df_cache.EvaluationsPoidsCache.get(self.id) diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index abda43bd0..a52826b70 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -470,7 +470,13 @@ def ue_delete(ue_id=None, delete_validations=False, dialog_confirmed=False): if ue.modules.all(): raise ScoValueError( f"""Suppression de l'UE {ue.titre} impossible car - des modules (ou SAÉ ou ressources) lui sont rattachés.""" + des modules (ou SAÉ ou ressources) lui sont rattachés.""", + dest_url=url_for( + "notes.ue_table", + scodoc_dept=g.scodoc_dept, + formation_id=ue.formation.id, + semestre_idx=ue.semestre_idx, + ), ) if not can_delete_ue(ue): raise ScoNonEmptyFormationObject( diff --git a/sco_version.py b/sco_version.py index aabbc6cad..ace35b653 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.20" +SCOVERSION = "9.1.21" SCONAME = "ScoDoc"