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
|
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(
|
_identiteEditor = ndb.EditableTable(
|
||||||
"identite",
|
"identite",
|
||||||
"etudid",
|
"etudid",
|
||||||
|
@ -60,6 +60,7 @@ from app.scodoc import sco_cache
|
|||||||
from app.scodoc import sco_codes_parcours
|
from app.scodoc import sco_codes_parcours
|
||||||
from app.scodoc import sco_cursus
|
from app.scodoc import sco_cursus
|
||||||
from app.scodoc import sco_etud
|
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_permissions_check
|
||||||
from app.scodoc import sco_xml
|
from app.scodoc import sco_xml
|
||||||
from app.scodoc.sco_exceptions import ScoException, AccessDenied, ScoValueError
|
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:
|
for etud in r:
|
||||||
sco_etud.format_etud_ident(etud)
|
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:
|
if scu.CONFIG.ALLOW_NULL_PRENOM:
|
||||||
for x in r:
|
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_portal_apogee
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_etud
|
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.gen_tables import GenTable
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
@ -398,12 +399,11 @@ class DisplayedGroupsInfos(object):
|
|||||||
self.partitions.append(partition)
|
self.partitions.append(partition)
|
||||||
|
|
||||||
def sortuniq(self):
|
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:
|
if (len(self.group_ids) <= 1) or len(self.members) <= 1:
|
||||||
return # on suppose que les etudiants d'un groupe sont deja triés
|
return # on suppose que les etudiants d'un groupe sont deja triés
|
||||||
self.members.sort(
|
# tri selon nom_usuel ou nom, sans accents
|
||||||
key=operator.itemgetter("nom_disp", "prenom")
|
self.members.sort(key=etud_sort_key)
|
||||||
) # tri selon nom_usuel ou nom
|
|
||||||
to_remove = []
|
to_remove = []
|
||||||
T = self.members
|
T = self.members
|
||||||
for i in range(len(T) - 1, 0, -1):
|
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
|
# Ancien ZScolar.group_list renommé ici en group_table
|
||||||
def groups_table(
|
def groups_table(
|
||||||
groups_infos=None, # instance of DisplayedGroupsInfos
|
groups_infos: DisplayedGroupsInfos = None,
|
||||||
with_codes=0,
|
with_codes=0,
|
||||||
etat=None,
|
etat=None,
|
||||||
format="html",
|
format="html",
|
||||||
@ -520,6 +520,7 @@ def groups_table(
|
|||||||
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"]
|
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"]
|
||||||
)
|
)
|
||||||
etud["_nom_disp_target"] = fiche_url
|
etud["_nom_disp_target"] = fiche_url
|
||||||
|
etud["_nom_disp_order"] = etud_sort_key(etud)
|
||||||
etud["_prenom_target"] = fiche_url
|
etud["_prenom_target"] = fiche_url
|
||||||
|
|
||||||
etud["_nom_disp_td_attrs"] = 'id="%s" class="etudinfo"' % (etud["etudid"])
|
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.etudiants import Identite
|
||||||
from app.models.evaluations import Evaluation
|
from app.models.evaluations import Evaluation
|
||||||
from app.models.moduleimpls import ModuleImpl
|
from app.models.moduleimpls import ModuleImpl
|
||||||
import app.scodoc.sco_utils as scu
|
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
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_evaluations
|
||||||
from app.scodoc import sco_evaluation_db
|
from app.scodoc import sco_evaluation_db
|
||||||
from app.scodoc import sco_formsemestre
|
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_moduleimpl
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_users
|
from app.scodoc import sco_users
|
||||||
|
import app.scodoc.sco_utils as scu
|
||||||
import sco_version
|
import sco_version
|
||||||
from app.scodoc.gen_tables import GenTable
|
from app.scodoc.gen_tables import GenTable
|
||||||
from app.scodoc.htmlutils import histogram_notes
|
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}" """,
|
"_nomprenom_td_attrs": f"""id="{etudid}" class="etudinfo" data-sort="{etud.sort_key}" """,
|
||||||
"prenom": etud.prenom.lower().capitalize(),
|
"prenom": etud.prenom.lower().capitalize(),
|
||||||
|
"nom_usuel": etud.nom_usuel,
|
||||||
"nomprenom": etud.nomprenom,
|
"nomprenom": etud.nomprenom,
|
||||||
"group": grc,
|
"group": grc,
|
||||||
"_group_td_attrs": 'class="group"',
|
"_group_td_attrs": 'class="group"',
|
||||||
@ -420,9 +422,8 @@ def _make_table_notes(
|
|||||||
if anonymous_listing:
|
if anonymous_listing:
|
||||||
rows.sort(key=lambda x: x["code"] or "")
|
rows.sort(key=lambda x: x["code"] or "")
|
||||||
else:
|
else:
|
||||||
rows.sort(
|
# sort by nom, prenom, sans accents
|
||||||
key=lambda x: (x["nom"] or "", x["prenom"] or "")
|
rows.sort(key=etud_sort_key)
|
||||||
) # sort by nom, prenom
|
|
||||||
|
|
||||||
# Si module, ajoute la (les) "moyenne(s) du module:
|
# Si module, ajoute la (les) "moyenne(s) du module:
|
||||||
if mode == "module":
|
if mode == "module":
|
||||||
|
Loading…
Reference in New Issue
Block a user