diff --git a/app/comp/res_but.py b/app/comp/res_but.py index 906345126..6c19c49fe 100644 --- a/app/comp/res_but.py +++ b/app/comp/res_but.py @@ -18,7 +18,9 @@ from app.models import ScoDocSiteConfig from app.models.etudiants import Identite from app.models.moduleimpls import ModuleImpl from app.models.ues import UniteEns +from app.scodoc import sco_groups from app.scodoc import sco_preferences +from app.scodoc import sco_codes_parcours from app.scodoc.sco_codes_parcours import UE_SPORT import app.scodoc.sco_utils as scu @@ -233,6 +235,7 @@ class ResultatsSemestreBUT(NotesTableCompat): add_cell(row, "nom_disp", "Nom", etud.nom_disp(), "identite_detail") add_cell(row, "prenom", "Prénom", etud.prenom, "identite_detail") add_cell(row, "nom_short", "Nom", etud.nom_short, "identite_court") + self._recap_etud_groups_infos(etudid, row, titles) # --- Moyenne générale moy_gen = self.etud_moy_gen.get(etudid, False) note_class = "" @@ -303,7 +306,7 @@ class ResultatsSemestreBUT(NotesTableCompat): rows.sort(key=lambda e: e["_rang_order"]) # INFOS POUR FOOTER - bottom_infos = self._bottom_infos( + bottom_infos = self._recap_bottom_infos( [ue for ue in ues if ue.type != UE_SPORT], modimpl_ids, fmt_note ) @@ -315,7 +318,7 @@ class ResultatsSemestreBUT(NotesTableCompat): row["moy_gen"] = row.get("moy_gen", "") row["_moy_gen_class"] = "col_moy_gen" # titre de la ligne: - row["nom_disp"] = row["nom_short"] = bottom_line.capitalize() + row["prenom"] = row["nom_short"] = bottom_line.capitalize() row["_tr_class"] = bottom_line.lower() footer_rows.append(row) return ( @@ -325,7 +328,7 @@ class ResultatsSemestreBUT(NotesTableCompat): [title for title in titles if not title.startswith("_")], ) - def _bottom_infos(self, ues, modimpl_ids: set, fmt_note) -> dict: + def _recap_bottom_infos(self, ues, modimpl_ids: set, fmt_note) -> dict: """Les informations à mettre en bas de la table: min, max, moy, ECTS""" bottom_infos = { # { key : row } avec key = min, max, moy, coef "min": {}, @@ -376,3 +379,28 @@ class ResultatsSemestreBUT(NotesTableCompat): bottom_infos["max"] = row_max bottom_infos["moy"] = row_moy return bottom_infos + + def _recap_etud_groups_infos(self, etudid: int, row: dict, titles: dict): + """Ajoute à row les colonnes sur les groupes pour etud""" + # XXX à remonter dans res_common + # dec = self.get_etud_decision_sem(etudid) + # if dec: + # codes_nb[dec["code"]] += 1 + row_class = "" + etud_etat = self.get_etud_etat(etudid) + if etud_etat == sco_codes_parcours.DEM: + gr_name = "Dém." + row_class = "dem" + elif etud_etat == sco_codes_parcours.DEF: + gr_name = "Déf." + row_class = "def" + else: + # XXX probablement à revoir pour utiliser données cachées, + # via get_etud_groups_in_partition ou autre + group = sco_groups.get_etud_main_group(etudid, self.formsemestre.id) + gr_name = group["group_name"] or "" + row["group"] = gr_name + row["_group_class"] = "group" + if row_class: + row["_tr_class"] = " ".join([row.get("_tr_class", ""), row_class]) + titles["group"] = "Gr" diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 48a1dbba3..2d0aec60a 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -343,7 +343,7 @@ def get_group_other_partitions(group): return other_partitions -def get_etud_groups(etudid, sem, exclude_default=False): +def get_etud_groups(etudid: int, formsemestre_id: int, exclude_default=False): """Infos sur groupes de l'etudiant dans ce semestre [ group + partition_name ] """ @@ -358,18 +358,18 @@ def get_etud_groups(etudid, sem, exclude_default=False): req += " and p.partition_name is not NULL" groups = ndb.SimpleDictFetch( req + " ORDER BY p.numero", - {"etudid": etudid, "formsemestre_id": sem["formsemestre_id"]}, + {"etudid": etudid, "formsemestre_id": formsemestre_id}, ) return _sortgroups(groups) -def get_etud_main_group(etudid, sem): +def get_etud_main_group(etudid: int, formsemestre_id: int): """Return main group (the first one) for etud, or default one if no groups""" - groups = get_etud_groups(etudid, sem, exclude_default=True) + groups = get_etud_groups(etudid, formsemestre_id, exclude_default=True) if groups: return groups[0] else: - return get_group(get_default_group(sem["formsemestre_id"])) + return get_group(get_default_group(formsemestre_id)) def formsemestre_get_main_partition(formsemestre_id): diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 1a4d1aa92..e12b7a54f 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -323,7 +323,7 @@ def _make_table_notes( etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] if etat == "I": # si inscrit, indique groupe - groups = sco_groups.get_etud_groups(etudid, sem) + groups = sco_groups.get_etud_groups(etudid, modimpl_o["formsemestre_id"]) grc = sco_groups.listgroups_abbrev(groups) else: if etat == "D": diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index 453f63f1f..8e2e8b2b7 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -192,7 +192,7 @@ def moduleimpl_inscriptions_edit(moduleimpl_id, etuds=[], submitted=False): ) H.append("""""") - groups = sco_groups.get_etud_groups(etud["etudid"], sem) + groups = sco_groups.get_etud_groups(etud["etudid"], formsemestre_id) for partition in partitions: if partition["partition_name"]: gr_name = "" @@ -303,12 +303,9 @@ def moduleimpl_inscriptions_stats(formsemestre_id): ) for mod in options: if can_change: - c_link = ( - '%s' - % ( - mod["moduleimpl_id"], - mod["descri"] or "(inscrire des étudiants)", - ) + c_link = '%s' % ( + mod["moduleimpl_id"], + mod["descri"] or "(inscrire des étudiants)", ) else: c_link = mod["descri"] diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index 73a355b62..3a99d2232 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -235,7 +235,7 @@ def ficheEtud(etudid=None): ) grlink = '%s' % descr["situation"] else: - group = sco_groups.get_etud_main_group(etudid, sem) + group = sco_groups.get_etud_main_group(etudid, sem["formsemestre_id"]) if group["partition_name"]: gr_name = group["group_name"] else: @@ -584,7 +584,7 @@ def etud_info_html(etudid, with_photo="1", debug=False): elif etud["cursem"]: # le semestre "en cours" pour l'étudiant sem = etud["cursem"] if sem: - groups = sco_groups.get_etud_groups(etudid, sem) + groups = sco_groups.get_etud_groups(etudid, formsemestre_id) grc = sco_groups.listgroups_abbrev(groups) H += '