From 5a71c406fbbf53dc5588eb9cc885c627fa5718d8 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 27 Mar 2022 10:05:12 +0200 Subject: [PATCH] Recap BUT: ajoute groupe + fix sort rang --- app/comp/res_but.py | 34 +++++++++++++++++++++-- app/scodoc/sco_groups.py | 10 +++---- app/scodoc/sco_liste_notes.py | 2 +- app/scodoc/sco_moduleimpl_inscriptions.py | 11 +++----- app/scodoc/sco_page_etud.py | 4 +-- app/scodoc/sco_recapcomplet.py | 4 +-- app/scodoc/sco_saisie_notes.py | 4 +-- app/scodoc/sco_trombino_tours.py | 4 ++- app/static/css/scodoc.css | 7 ++++- 9 files changed, 56 insertions(+), 24 deletions(-) diff --git a/app/comp/res_but.py b/app/comp/res_but.py index 9063451263..6c19c49fe1 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 48a1dbba34..2d0aec60af 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 1a4d1aa928..e12b7a54f6 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 453f63f1fc..8e2e8b2b79 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 73a355b621..3a99d2232a 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 += '
En S%d: %s
' % (sem["semestre_id"], grc) H += "" # fin partie gauche (eid_left) diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index 1dbed2bb74..3519d73d6d 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -414,7 +414,7 @@ def make_formsemestre_recapcomplet( gr_name = "Déf." is_dem[etudid] = False else: - group = sco_groups.get_etud_main_group(etudid, sem) + group = sco_groups.get_etud_main_group(etudid, formsemestre_id) gr_name = group["group_name"] or "" is_dem[etudid] = False if rank_partition_id: @@ -1020,7 +1020,7 @@ def _gen_cell(key: str, row: dict, elt="td"): "html table cell" klass = row.get(f"_{key}_class") attrs = f'class="{klass}"' if klass else "" - order = row.get("_{key}_order") + order = row.get(f"_{key}_order") if order: attrs += f' data-order="{order}"' return f'<{elt} {attrs}>{row.get(key, "")}' diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index be1b45be9d..d982b5e74a 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -847,7 +847,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]): etuds = _get_sorted_etuds(E, etudids, formsemestre_id) for e in etuds: etudid = e["etudid"] - groups = sco_groups.get_etud_groups(etudid, sem) + groups = sco_groups.get_etud_groups(etudid, formsemestre_id) grc = sco_groups.listgroups_abbrev(groups) L.append( @@ -1020,7 +1020,7 @@ def _get_sorted_etuds(E, etudids, formsemestre_id): {"etudid": etudid, "formsemestre_id": formsemestre_id} )[0] # Groupes auxquels appartient cet étudiant: - e["groups"] = sco_groups.get_etud_groups(etudid, sem) + e["groups"] = sco_groups.get_etud_groups(etudid, formsemestre_id) # Information sur absence (tenant compte de la demi-journée) jour_iso = ndb.DateDMYtoISO(E["jour"]) diff --git a/app/scodoc/sco_trombino_tours.py b/app/scodoc/sco_trombino_tours.py index 56261eb9f3..fd11da4e89 100644 --- a/app/scodoc/sco_trombino_tours.py +++ b/app/scodoc/sco_trombino_tours.py @@ -180,7 +180,9 @@ def pdf_trombino_tours( n = 1 for m in members: img = sco_trombino._get_etud_platypus_image(m, image_width=PHOTOWIDTH) - etud_main_group = sco_groups.get_etud_main_group(m["etudid"], sem) + etud_main_group = sco_groups.get_etud_main_group( + m["etudid"], sem["formsemestre_id"] + ) if group_id != etud_main_group["group_id"]: text_group = " (" + etud_main_group["group_name"] + ")" else: diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index d36cf47c4a..d731046435 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -3229,6 +3229,7 @@ span.ext_sem_moy { } /* DataTables */ + table.dataTable tr.odd td { background-color: #ecf5f4; } @@ -3250,9 +3251,13 @@ table.table_recap .rang { white-space:nowrap; text-align: right; } -table.table_recap .col_ue, table.table_recap .col_moy_gen { +table.table_recap .col_ue, table.table_recap .col_moy_gen, table.table_recap .group { border-left: 1px solid blue; } +table.table_recap .group { + border-left: 1px dashed rgb(160, 160, 160); +} + table.table_recap tfoot th, table.table_recap thead th { text-align: left; padding-left: 10px !important;