From fdc01a5c3b9377e17facfe610a30710d1cd65f2d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 20 Oct 2024 11:02:08 +0200 Subject: [PATCH] =?UTF-8?q?sco=5Fplacement:=20feuilles=20placement=20?= =?UTF-8?q?=C3=A9tudiants=20=C3=A9valuation:=20modernisation=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/multiselect.py | 8 +- app/scodoc/sco_placement.py | 129 ++++++++++-------------- app/templates/scodoc/forms/placement.j2 | 4 + sco_version.py | 2 +- 4 files changed, 63 insertions(+), 80 deletions(-) diff --git a/app/forms/multiselect.py b/app/forms/multiselect.py index 77b13626b..820718f9e 100644 --- a/app/forms/multiselect.py +++ b/app/forms/multiselect.py @@ -26,7 +26,8 @@ class MultiSelect: HTML : group_ids="val1"&group_ids="val2"... JS : ["val1","val2", ...] - **kwargs: Arguments supplémentaires (appliqué au multiselect en HTML ) + **kwargs: Arguments supplémentaires (appliqués au multiselect en + HTML ) """ def __init__( @@ -61,7 +62,8 @@ class MultiSelect: for value in values: selected = "selected" if value.get("selected", False) else "" single = "single" if value.get("single", False) else "" - opt = f"" + opt = f"""""" optgroup += opt optgroup += "" opts.append(optgroup) @@ -70,7 +72,7 @@ class MultiSelect: js: str = "{" + self.js + "}" export: str = "{" + self.export + "}" return f""" - list[tuple[str, str, int]]: + # tous les etudiants ? + get_all_students = None in [g["group_name"] for g in self.groups] etudid_etats = sco_groups.do_evaluation_listeetuds_groups( self.evaluation_id, self.groups, getallstudents=get_all_students, include_demdef=True, ) - listetud = [] # liste de couples (nom,prenom) + listetud = [] # liste de tuples (nom, prenom, etudid) for etudid, etat in etudid_etats: - # infos identite etudiant (xxx sous-optimal: 1/select par etudiant) - ident = sco_etud.etudident_list(ndb.GetDBConnexion(), {"etudid": etudid})[0] - if etat != "D": - nom = ident["nom"].upper() - prenom = ident["prenom"].lower().capitalize() - etudid = ident["etudid"] - listetud.append((nom, prenom, etudid)) + if etat != scu.DEMISSION: + # infos identite etudiant + etud = Identite.get_etud(etudid) + nom = etud.nom.upper() + prenom = etud.prenom.lower().capitalize() + listetud.append((nom, prenom, etud.id)) + random.shuffle(listetud) + return listetud def _affectation_places(self): @@ -328,7 +307,7 @@ class PlacementRunner: return plan def _production_xls(self): - filename = "placement_%s_%s" % (self.evalname, self.gr_title_filename) + filename = f"placement_{self.evalname}_{self.gr_title_filename}" xls = self._excel_feuille_placement() return scu.send_file(xls, filename, scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE) @@ -338,10 +317,10 @@ class PlacementRunner: if self.evaluation.date_debut else '-' } - Horaire : {self.evaluation.heure_debut()} à {self.evaluation.heure_fin() }""" - filename = "placement_%(evalname)s_%(gr_title_filename)s" % self.__dict__ + filename = f"placement_{self.evalname}_{self.gr_title_filename}" titles = { "nom": "Nom", - "prenom": "Prenom", + "prenom": "Prénom", "colonne": "Colonne", "ligne": "Ligne", "place": "Place", @@ -369,9 +348,7 @@ class PlacementRunner: columns_ids=columns_ids, rows=rows, filename=filename, - origin="Généré par %s le " % sco_version.SCONAME - + scu.timedate_human_repr() - + "", + origin=f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}", pdf_title=pdf_title, # pdf_shorttitle = '', preferences=sco_preferences.SemPreferences( @@ -476,9 +453,9 @@ class PlacementRunner: } def _titres(self, worksheet): - datetime = time.strftime("%d/%m/%Y a %Hh%M") + date_time = time.strftime(scu.DATEATIME_FMT) worksheet.append_single_cell_row( - "Feuille placement etudiants éditée le %s" % datetime, self.styles["titres"] + f"Feuille placement etudiants éditée le {date_time}", self.styles["titres"] ) for line, desceval in enumerate(self.desceval): if line in [1, 4, 7]: @@ -497,7 +474,7 @@ class PlacementRunner: # entetes colonnes - feuille0 cells = [ws0.make_cell()] for col in range(self.nb_rangs): - cells.append(ws0.make_cell("colonne %s" % (col + 1), self.styles["2b"])) + cells.append(ws0.make_cell(f"colonne {col + 1}", self.styles["2b"])) ws0.append_row(cells) # etudiants - feuille0 @@ -517,7 +494,7 @@ class PlacementRunner: if self.etiquetage == COORD: cell_c = ws0.make_cell("", self.styles["1bb"]) else: - cell_c = ws0.make_cell("place %s" % place, self.styles["1bb"]) + cell_c = ws0.make_cell(f"place {place}", self.styles["1bb"]) place = place + 1 cells_c.append(cell_c) ws0.set_row_dimension_height(row, space / 25) diff --git a/app/templates/scodoc/forms/placement.j2 b/app/templates/scodoc/forms/placement.j2 index ecfe36649..b7e6e582b 100644 --- a/app/templates/scodoc/forms/placement.j2 +++ b/app/templates/scodoc/forms/placement.j2 @@ -13,6 +13,7 @@ {% endfor %} {% endif %} + {{field.description}} {% endmacro %} @@ -60,6 +61,8 @@ + +

Explications

  • préciser les surveillants et la localisation (bâtiment et salle) et indiquer la largeur de la salle (nombre @@ -85,5 +88,6 @@
+
{% endblock %} \ No newline at end of file diff --git a/sco_version.py b/sco_version.py index d62215913..1dae32442 100644 --- a/sco_version.py +++ b/sco_version.py @@ -3,7 +3,7 @@ "Infos sur version ScoDoc" -SCOVERSION = "9.7.31" +SCOVERSION = "9.7.32" SCONAME = "ScoDoc"