1
0
forked from ScoDoc/ScoDoc

Recap BUT: ajoute groupe + fix sort rang

This commit is contained in:
Emmanuel Viennet 2022-03-27 10:05:12 +02:00
parent 13f55d5190
commit 5a71c406fb
9 changed files with 56 additions and 24 deletions

View File

@ -18,7 +18,9 @@ from app.models import ScoDocSiteConfig
from app.models.etudiants import Identite from app.models.etudiants import Identite
from app.models.moduleimpls import ModuleImpl from app.models.moduleimpls import ModuleImpl
from app.models.ues import UniteEns from app.models.ues import UniteEns
from app.scodoc import sco_groups
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_codes_parcours
from app.scodoc.sco_codes_parcours import UE_SPORT from app.scodoc.sco_codes_parcours import UE_SPORT
import app.scodoc.sco_utils as scu 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, "nom_disp", "Nom", etud.nom_disp(), "identite_detail")
add_cell(row, "prenom", "Prénom", etud.prenom, "identite_detail") add_cell(row, "prenom", "Prénom", etud.prenom, "identite_detail")
add_cell(row, "nom_short", "Nom", etud.nom_short, "identite_court") add_cell(row, "nom_short", "Nom", etud.nom_short, "identite_court")
self._recap_etud_groups_infos(etudid, row, titles)
# --- Moyenne générale # --- Moyenne générale
moy_gen = self.etud_moy_gen.get(etudid, False) moy_gen = self.etud_moy_gen.get(etudid, False)
note_class = "" note_class = ""
@ -303,7 +306,7 @@ class ResultatsSemestreBUT(NotesTableCompat):
rows.sort(key=lambda e: e["_rang_order"]) rows.sort(key=lambda e: e["_rang_order"])
# INFOS POUR FOOTER # 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 [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"] = row.get("moy_gen", "")
row["_moy_gen_class"] = "col_moy_gen" row["_moy_gen_class"] = "col_moy_gen"
# titre de la ligne: # 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() row["_tr_class"] = bottom_line.lower()
footer_rows.append(row) footer_rows.append(row)
return ( return (
@ -325,7 +328,7 @@ class ResultatsSemestreBUT(NotesTableCompat):
[title for title in titles if not title.startswith("_")], [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""" """Les informations à mettre en bas de la table: min, max, moy, ECTS"""
bottom_infos = { # { key : row } avec key = min, max, moy, coef bottom_infos = { # { key : row } avec key = min, max, moy, coef
"min": {}, "min": {},
@ -376,3 +379,28 @@ class ResultatsSemestreBUT(NotesTableCompat):
bottom_infos["max"] = row_max bottom_infos["max"] = row_max
bottom_infos["moy"] = row_moy bottom_infos["moy"] = row_moy
return bottom_infos 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"

View File

@ -343,7 +343,7 @@ def get_group_other_partitions(group):
return other_partitions 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 """Infos sur groupes de l'etudiant dans ce semestre
[ group + partition_name ] [ group + partition_name ]
""" """
@ -358,18 +358,18 @@ def get_etud_groups(etudid, sem, exclude_default=False):
req += " and p.partition_name is not NULL" req += " and p.partition_name is not NULL"
groups = ndb.SimpleDictFetch( groups = ndb.SimpleDictFetch(
req + " ORDER BY p.numero", req + " ORDER BY p.numero",
{"etudid": etudid, "formsemestre_id": sem["formsemestre_id"]}, {"etudid": etudid, "formsemestre_id": formsemestre_id},
) )
return _sortgroups(groups) 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""" """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: if groups:
return groups[0] return groups[0]
else: 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): def formsemestre_get_main_partition(formsemestre_id):

View File

@ -323,7 +323,7 @@ def _make_table_notes(
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
if etat == "I": # si inscrit, indique groupe 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) grc = sco_groups.listgroups_abbrev(groups)
else: else:
if etat == "D": if etat == "D":

View File

@ -192,7 +192,7 @@ def moduleimpl_inscriptions_edit(moduleimpl_id, etuds=[], submitted=False):
) )
H.append("""</input></td>""") H.append("""</input></td>""")
groups = sco_groups.get_etud_groups(etud["etudid"], sem) groups = sco_groups.get_etud_groups(etud["etudid"], formsemestre_id)
for partition in partitions: for partition in partitions:
if partition["partition_name"]: if partition["partition_name"]:
gr_name = "" gr_name = ""
@ -303,13 +303,10 @@ def moduleimpl_inscriptions_stats(formsemestre_id):
) )
for mod in options: for mod in options:
if can_change: if can_change:
c_link = ( c_link = '<a class="discretelink" href="moduleimpl_inscriptions_edit?moduleimpl_id=%s">%s</a>' % (
'<a class="discretelink" href="moduleimpl_inscriptions_edit?moduleimpl_id=%s">%s</a>'
% (
mod["moduleimpl_id"], mod["moduleimpl_id"],
mod["descri"] or "<i>(inscrire des étudiants)</i>", mod["descri"] or "<i>(inscrire des étudiants)</i>",
) )
)
else: else:
c_link = mod["descri"] c_link = mod["descri"]
H.append( H.append(

View File

@ -235,7 +235,7 @@ def ficheEtud(etudid=None):
) )
grlink = '<span class="fontred">%s</span>' % descr["situation"] grlink = '<span class="fontred">%s</span>' % descr["situation"]
else: 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"]: if group["partition_name"]:
gr_name = group["group_name"] gr_name = group["group_name"]
else: 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 elif etud["cursem"]: # le semestre "en cours" pour l'étudiant
sem = etud["cursem"] sem = etud["cursem"]
if sem: 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) grc = sco_groups.listgroups_abbrev(groups)
H += '<div class="eid_info">En <b>S%d</b>: %s</div>' % (sem["semestre_id"], grc) H += '<div class="eid_info">En <b>S%d</b>: %s</div>' % (sem["semestre_id"], grc)
H += "</div>" # fin partie gauche (eid_left) H += "</div>" # fin partie gauche (eid_left)

View File

@ -414,7 +414,7 @@ def make_formsemestre_recapcomplet(
gr_name = "Déf." gr_name = "Déf."
is_dem[etudid] = False is_dem[etudid] = False
else: 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 "" gr_name = group["group_name"] or ""
is_dem[etudid] = False is_dem[etudid] = False
if rank_partition_id: if rank_partition_id:
@ -1020,7 +1020,7 @@ def _gen_cell(key: str, row: dict, elt="td"):
"html table cell" "html table cell"
klass = row.get(f"_{key}_class") klass = row.get(f"_{key}_class")
attrs = f'class="{klass}"' if klass else "" attrs = f'class="{klass}"' if klass else ""
order = row.get("_{key}_order") order = row.get(f"_{key}_order")
if order: if order:
attrs += f' data-order="{order}"' attrs += f' data-order="{order}"'
return f'<{elt} {attrs}>{row.get(key, "")}</{elt}>' return f'<{elt} {attrs}>{row.get(key, "")}</{elt}>'

View File

@ -847,7 +847,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
etuds = _get_sorted_etuds(E, etudids, formsemestre_id) etuds = _get_sorted_etuds(E, etudids, formsemestre_id)
for e in etuds: for e in etuds:
etudid = e["etudid"] 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) grc = sco_groups.listgroups_abbrev(groups)
L.append( L.append(
@ -1020,7 +1020,7 @@ def _get_sorted_etuds(E, etudids, formsemestre_id):
{"etudid": etudid, "formsemestre_id": formsemestre_id} {"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0] )[0]
# Groupes auxquels appartient cet étudiant: # 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) # Information sur absence (tenant compte de la demi-journée)
jour_iso = ndb.DateDMYtoISO(E["jour"]) jour_iso = ndb.DateDMYtoISO(E["jour"])

View File

@ -180,7 +180,9 @@ def pdf_trombino_tours(
n = 1 n = 1
for m in members: for m in members:
img = sco_trombino._get_etud_platypus_image(m, image_width=PHOTOWIDTH) 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"]: if group_id != etud_main_group["group_id"]:
text_group = " (" + etud_main_group["group_name"] + ")" text_group = " (" + etud_main_group["group_name"] + ")"
else: else:

View File

@ -3229,6 +3229,7 @@ span.ext_sem_moy {
} }
/* DataTables */ /* DataTables */
table.dataTable tr.odd td { table.dataTable tr.odd td {
background-color: #ecf5f4; background-color: #ecf5f4;
} }
@ -3250,9 +3251,13 @@ table.table_recap .rang {
white-space:nowrap; white-space:nowrap;
text-align: right; 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; 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 { table.table_recap tfoot th, table.table_recap thead th {
text-align: left; text-align: left;
padding-left: 10px !important; padding-left: 10px !important;