forked from ScoDoc/ScoDoc
Fix #24 (tri tables étudiants)
This commit is contained in:
parent
fb89823c7b
commit
d828be6be7
@ -205,6 +205,18 @@ def pivot_year(y):
|
||||
return y
|
||||
|
||||
|
||||
def etud_sort_key(etud: dict) -> tuple:
|
||||
"""Clé de tri pour les étudiants représentés par des dict (anciens codes).
|
||||
Equivalent moderne: identite.sort_key
|
||||
"""
|
||||
return (
|
||||
scu.sanitize_string(
|
||||
etud["nom_usuel"] or etud["nom"] or "", remove_spaces=False
|
||||
).lower(),
|
||||
scu.sanitize_string(etud["prenom"] or "", remove_spaces=False).lower(),
|
||||
)
|
||||
|
||||
|
||||
_identiteEditor = ndb.EditableTable(
|
||||
"identite",
|
||||
"etudid",
|
||||
|
@ -60,6 +60,7 @@ from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_codes_parcours
|
||||
from app.scodoc import sco_cursus
|
||||
from app.scodoc import sco_etud
|
||||
from app.scodoc.sco_etud import etud_sort_key
|
||||
from app.scodoc import sco_permissions_check
|
||||
from app.scodoc import sco_xml
|
||||
from app.scodoc.sco_exceptions import ScoException, AccessDenied, ScoValueError
|
||||
@ -283,7 +284,8 @@ def get_group_members(group_id, etat=None):
|
||||
for etud in r:
|
||||
sco_etud.format_etud_ident(etud)
|
||||
|
||||
r.sort(key=operator.itemgetter("nom_disp", "prenom")) # tri selon nom_usuel ou nom
|
||||
# tri selon nom_usuel ou nom, sans accents
|
||||
r.sort(key=etud_sort_key)
|
||||
|
||||
if scu.CONFIG.ALLOW_NULL_PRENOM:
|
||||
for x in r:
|
||||
|
@ -53,6 +53,7 @@ from app.scodoc import sco_cursus
|
||||
from app.scodoc import sco_portal_apogee
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc import sco_etud
|
||||
from app.scodoc.sco_etud import etud_sort_key
|
||||
from app.scodoc.gen_tables import GenTable
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
@ -398,12 +399,11 @@ class DisplayedGroupsInfos(object):
|
||||
self.partitions.append(partition)
|
||||
|
||||
def sortuniq(self):
|
||||
"Trie les étudiants (de plusieurs groupes) et elimine les doublons"
|
||||
"Trie les étudiants (de plusieurs groupes) et élimine les doublons"
|
||||
if (len(self.group_ids) <= 1) or len(self.members) <= 1:
|
||||
return # on suppose que les etudiants d'un groupe sont deja triés
|
||||
self.members.sort(
|
||||
key=operator.itemgetter("nom_disp", "prenom")
|
||||
) # tri selon nom_usuel ou nom
|
||||
# tri selon nom_usuel ou nom, sans accents
|
||||
self.members.sort(key=etud_sort_key)
|
||||
to_remove = []
|
||||
T = self.members
|
||||
for i in range(len(T) - 1, 0, -1):
|
||||
@ -422,7 +422,7 @@ class DisplayedGroupsInfos(object):
|
||||
|
||||
# Ancien ZScolar.group_list renommé ici en group_table
|
||||
def groups_table(
|
||||
groups_infos=None, # instance of DisplayedGroupsInfos
|
||||
groups_infos: DisplayedGroupsInfos = None,
|
||||
with_codes=0,
|
||||
etat=None,
|
||||
format="html",
|
||||
@ -520,6 +520,7 @@ def groups_table(
|
||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"]
|
||||
)
|
||||
etud["_nom_disp_target"] = fiche_url
|
||||
etud["_nom_disp_order"] = etud_sort_key(etud)
|
||||
etud["_prenom_target"] = fiche_url
|
||||
|
||||
etud["_nom_disp_td_attrs"] = 'id="%s" class="etudinfo"' % (etud["etudid"])
|
||||
|
@ -44,10 +44,10 @@ from app.models import FormSemestre
|
||||
from app.models.etudiants import Identite
|
||||
from app.models.evaluations import Evaluation
|
||||
from app.models.moduleimpls import ModuleImpl
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
||||
|
||||
from app.scodoc.sco_etud import etud_sort_key
|
||||
from app.scodoc import sco_evaluations
|
||||
from app.scodoc import sco_evaluation_db
|
||||
from app.scodoc import sco_formsemestre
|
||||
@ -55,6 +55,7 @@ from app.scodoc import sco_groups
|
||||
from app.scodoc import sco_moduleimpl
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc import sco_users
|
||||
import app.scodoc.sco_utils as scu
|
||||
import sco_version
|
||||
from app.scodoc.gen_tables import GenTable
|
||||
from app.scodoc.htmlutils import histogram_notes
|
||||
@ -352,6 +353,7 @@ def _make_table_notes(
|
||||
),
|
||||
"_nomprenom_td_attrs": f"""id="{etudid}" class="etudinfo" data-sort="{etud.sort_key}" """,
|
||||
"prenom": etud.prenom.lower().capitalize(),
|
||||
"nom_usuel": etud.nom_usuel,
|
||||
"nomprenom": etud.nomprenom,
|
||||
"group": grc,
|
||||
"_group_td_attrs": 'class="group"',
|
||||
@ -420,9 +422,8 @@ def _make_table_notes(
|
||||
if anonymous_listing:
|
||||
rows.sort(key=lambda x: x["code"] or "")
|
||||
else:
|
||||
rows.sort(
|
||||
key=lambda x: (x["nom"] or "", x["prenom"] or "")
|
||||
) # sort by nom, prenom
|
||||
# sort by nom, prenom, sans accents
|
||||
rows.sort(key=etud_sort_key)
|
||||
|
||||
# Si module, ajoute la (les) "moyenne(s) du module:
|
||||
if mode == "module":
|
||||
|
Loading…
Reference in New Issue
Block a user