diff --git a/app/models/groups.py b/app/models/groups.py index bc5943a96..4a07a8753 100644 --- a/app/models/groups.py +++ b/app/models/groups.py @@ -125,7 +125,7 @@ class Partition(ScoDocModel): } return d - def get_etud_group(self, etudid: int) -> "GroupDescr": + def get_etud_group(self, etudid: int) -> "GroupDescr|None": "Le groupe de l'étudiant dans cette partition, ou None si pas présent" return ( GroupDescr.query.filter_by(partition_id=self.id) diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index eb6647256..733536c87 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -39,10 +39,8 @@ from app.comp import moy_mod from app.comp.moy_mod import ModuleImplResults from app.comp.res_but import ResultatsSemestreBUT from app.comp.res_compat import NotesTableCompat -from app.models import FormSemestre, Module -from app.models.etudiants import Identite -from app.models.evaluations import Evaluation -from app.models.moduleimpls import ModuleImpl +from app.models import Evaluation, FormSemestre, Identite, Module, ModuleImpl, Partition + from app.scodoc import ( sco_evaluations, sco_evaluation_db, @@ -258,10 +256,8 @@ def _make_table_notes( if e.moduleimpl_id != modimpl.id: raise ValueError("invalid evaluations list") - if fmt == "xls" or fmt == "json": - keep_numeric = True # pas de conversion des notes en strings - else: - keep_numeric = False + # pas de conversion des notes en strings pour certains formats: + keep_numeric = fmt in ("xls", "json") # Menu groupes group_selector = ( sco_groups_view.form_groups_choice( @@ -287,7 +283,8 @@ def _make_table_notes( columns_ids = ["etudid", "nom", "prenom"] else: columns_ids = ["nomprenom"] - partitions = [] + + partitions: list[Partition] = [] if not args["hide_groups"]: if args["split_groups"]: partitions = formsemestre.get_partitions_list( @@ -350,10 +347,13 @@ def _make_table_notes( if etat == scu.INSCRIT: # si inscrit, indique groupe groups = sco_groups.get_etud_groups(etudid, formsemestre.id) grc = sco_groups.listgroups_abbrev(groups) - groups_cols = { - f"partition_{p.id}": p.get_etud_group(etudid).group_name or "" - for p in partitions - } + groups_cols = {} + for p in partitions: + etud_group = p.get_etud_group(etudid) + groups_cols[f"partition_{p.id}"] = ( + (etud_group.group_name or "") if etud_group else "" + ) + else: if etat == scu.DEMISSION: grc = "DEM" # attention: ce code est re-ecrit plus bas, ne pas le changer (?)