2022-06-23 06:33:03 +02:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2022-06-23 06:33:03 +02:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
"""Jury BUT et classiques: table recap annuelle et liens saisie
|
2022-06-23 06:33:03 +02:00
|
|
|
"""
|
|
|
|
|
2022-12-25 21:43:22 +01:00
|
|
|
import collections
|
2022-06-23 06:33:03 +02:00
|
|
|
import time
|
2022-06-27 18:41:54 +02:00
|
|
|
import numpy as np
|
2022-06-23 06:33:03 +02:00
|
|
|
from flask import g, url_for
|
|
|
|
|
|
|
|
from app.but import jury_but
|
2022-06-24 16:57:44 +02:00
|
|
|
from app.but.jury_but import (
|
|
|
|
DecisionsProposeesAnnee,
|
|
|
|
DecisionsProposeesRCUE,
|
|
|
|
DecisionsProposeesUE,
|
|
|
|
)
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.comp.res_but import ResultatsSemestreBUT
|
2023-02-05 18:38:52 +01:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.comp import res_sem
|
2023-02-05 18:38:52 +01:00
|
|
|
from app.models import UniteEns
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.models.etudiants import Identite
|
2023-02-03 15:58:52 +01:00
|
|
|
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.models.formsemestre import FormSemestre
|
2022-08-03 13:32:59 +02:00
|
|
|
from app.scodoc import html_sco_header
|
2022-06-23 08:40:33 +02:00
|
|
|
from app.scodoc.sco_codes_parcours import (
|
|
|
|
BUT_BARRE_RCUE,
|
|
|
|
BUT_RCUE_SUFFISANT,
|
|
|
|
)
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.scodoc import sco_formsemestre_status
|
2022-08-03 13:32:59 +02:00
|
|
|
from app.scodoc import sco_pvjury
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.scodoc import sco_utils as scu
|
2023-02-03 22:39:45 +01:00
|
|
|
from app.tables.recap import RowRecap, TableRecap
|
2023-02-03 15:58:52 +01:00
|
|
|
|
|
|
|
|
2023-02-03 22:39:45 +01:00
|
|
|
class TableJury(TableRecap):
|
2023-02-04 14:22:24 +01:00
|
|
|
"""Cette table recap reprend les colonnes du tableau recap, sauf les évaluations,
|
|
|
|
et ajoute:
|
2023-02-05 18:38:52 +01:00
|
|
|
Pour le BUT:
|
|
|
|
- les RCUEs (moyenne et code décision)
|
|
|
|
Pour toutes les formations:
|
|
|
|
- les codes de décisions jury sur les UEs
|
|
|
|
- le lien de saisie ou modif de la décision de jury
|
2023-02-04 14:22:24 +01:00
|
|
|
"""
|
2023-02-03 15:58:52 +01:00
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
def __init__(self, *args, row_class: str = None, read_only=True, **kwargs):
|
|
|
|
super().__init__(
|
|
|
|
*args, row_class=row_class or RowJury, finalize=False, **kwargs
|
|
|
|
)
|
|
|
|
# redéclare pour VSCode
|
|
|
|
self.rows: list["RowJury"] = self.rows
|
|
|
|
self.res: NotesTableCompat = self.res
|
|
|
|
self.read_only = read_only
|
|
|
|
# Stats jury: fréquence de chaque code enregistré
|
|
|
|
self.freq_codes_annuels = collections.Counter()
|
|
|
|
# Ajout colonnes spécifiques à la table jury:
|
|
|
|
|
|
|
|
if self.res.is_apc:
|
|
|
|
self.add_rcues()
|
|
|
|
self.add_jury()
|
2023-02-05 23:15:50 +01:00
|
|
|
self.add_groups_header()
|
2023-02-05 18:38:52 +01:00
|
|
|
# Termine la table
|
|
|
|
self.finalize()
|
|
|
|
|
|
|
|
def add_rcues(self):
|
|
|
|
"""Ajoute les colonnes indiquant le nb de RCUEs et chaque RCUE
|
|
|
|
pour tous les étudiants de la table.
|
|
|
|
La table contient des rows avec la clé etudid.
|
|
|
|
Les colonnes ont la classe css "rcue".
|
|
|
|
"""
|
|
|
|
self.insert_group("rcue", before="col_ues_validables")
|
|
|
|
for row in self.rows:
|
|
|
|
etud: Identite = row.etud
|
|
|
|
deca = row.deca
|
|
|
|
if deca.code_valide:
|
|
|
|
self.freq_codes_annuels[deca.code_valide] += 1
|
|
|
|
row.add_nb_rcues_cell()
|
|
|
|
# --- Les RCUEs
|
|
|
|
for rcue in deca.rcues_annee:
|
|
|
|
dec_rcue = deca.dec_rcue_by_ue.get(rcue.ue_1.id)
|
|
|
|
if dec_rcue is not None: # None si l'UE n'est pas associée à un niveau
|
|
|
|
row.add_rcue_cols(dec_rcue)
|
|
|
|
|
|
|
|
def add_jury(self):
|
|
|
|
"""Ajoute la colonne code jury et le lien.
|
|
|
|
Le code jury est celui du semestre: cette colonne n'est montrée
|
|
|
|
que pour les formations classiques, ce code n'est pas utilisé en BUT.
|
|
|
|
"""
|
|
|
|
res = self.res
|
2023-02-05 23:15:50 +01:00
|
|
|
|
|
|
|
for row in self.rows:
|
|
|
|
etud = row.etud
|
|
|
|
if not res.is_apc:
|
|
|
|
# formations classiques: code semestre
|
|
|
|
if res.validations:
|
2023-02-05 18:38:52 +01:00
|
|
|
dec_sem = res.validations.decisions_jury.get(etud.id)
|
|
|
|
jury_code_sem = dec_sem["code"] if dec_sem else ""
|
2023-02-05 23:15:50 +01:00
|
|
|
else:
|
|
|
|
jury_code_sem = ""
|
2023-02-05 18:38:52 +01:00
|
|
|
row.add_cell(
|
2023-02-05 23:15:50 +01:00
|
|
|
"jury_code_sem", "Jury", jury_code_sem, group="jury_code_sem"
|
2023-02-05 18:38:52 +01:00
|
|
|
)
|
2023-02-05 23:15:50 +01:00
|
|
|
self.foot_title_row.cells["jury_code_sem"].target_attrs[
|
|
|
|
"title"
|
|
|
|
] = """Code jury sur le semestre"""
|
|
|
|
|
|
|
|
row.add_cell(
|
|
|
|
"jury_link",
|
|
|
|
"",
|
|
|
|
f"""{("modifier" if res.validations and res.validations.has_decision(etud) else "saisir")
|
|
|
|
if res.formsemestre.etat else "voir"} décisions""",
|
|
|
|
group="col_jury_link",
|
|
|
|
target=url_for(
|
|
|
|
"notes.formsemestre_validation_etud_form",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=res.formsemestre.id,
|
|
|
|
etudid=etud.id,
|
|
|
|
),
|
|
|
|
target_attrs={"class": "stdlink"},
|
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
|
2023-02-03 15:58:52 +01:00
|
|
|
|
2023-02-03 22:39:45 +01:00
|
|
|
class RowJury(RowRecap):
|
2023-02-03 15:58:52 +01:00
|
|
|
"Ligne de la table saisie jury"
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
def __init__(self, table: TableJury, etud: Identite, *args, **kwargs):
|
|
|
|
self.table: TableJury = table
|
|
|
|
super().__init__(table, etud, *args, **kwargs)
|
2023-02-05 23:15:50 +01:00
|
|
|
if table.res.is_apc:
|
|
|
|
# Conserve le deca de cet étudiant:
|
|
|
|
self.deca = jury_but.DecisionsProposeesAnnee(
|
|
|
|
self.etud, self.table.res.formsemestre
|
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
|
|
|
|
def add_nb_rcues_cell(self):
|
2023-02-03 15:58:52 +01:00
|
|
|
"cell avec nb niveaux validables / total"
|
2023-02-05 18:38:52 +01:00
|
|
|
deca = self.deca
|
2023-02-03 15:58:52 +01:00
|
|
|
classes = ["col_rcue", "col_rcues_validables"]
|
|
|
|
if deca.nb_rcues_under_8 > 0:
|
|
|
|
classes.append("moy_ue_warning")
|
|
|
|
elif deca.nb_validables < deca.nb_competences:
|
|
|
|
classes.append("moy_ue_inf")
|
|
|
|
else:
|
|
|
|
classes.append("moy_ue_valid")
|
|
|
|
|
|
|
|
if len(deca.rcues_annee) > 0:
|
|
|
|
# permet un tri par nb de niveaux validables + moyenne gen indicative S_pair
|
|
|
|
if deca.res_pair and deca.etud.id in deca.res_pair.etud_moy_gen:
|
|
|
|
moy = deca.res_pair.etud_moy_gen[deca.etud.id]
|
|
|
|
if np.isnan(moy):
|
|
|
|
moy_gen_d = "x"
|
|
|
|
else:
|
|
|
|
moy_gen_d = f"{int(moy*1000):05}"
|
|
|
|
else:
|
|
|
|
moy_gen_d = "x"
|
|
|
|
order = f"{deca.nb_validables:04d}-{moy_gen_d}"
|
|
|
|
else:
|
|
|
|
# étudiants sans RCUE: pas de semestre impair, ...
|
|
|
|
# les classe à la fin
|
|
|
|
order = f"{deca.nb_validables:04d}-00000-{deca.etud.sort_key}"
|
|
|
|
|
|
|
|
self.add_cell(
|
|
|
|
"rcues_validables",
|
|
|
|
"RCUEs",
|
|
|
|
f"""{deca.nb_validables}/{deca.nb_competences}"""
|
|
|
|
+ ((" " + scu.EMO_WARNING) if deca.nb_rcues_under_8 > 0 else ""),
|
2023-02-05 18:38:52 +01:00
|
|
|
raw_content=f"""{deca.nb_validables}/{deca.nb_competences}""",
|
|
|
|
group="rcue",
|
2023-02-03 15:58:52 +01:00
|
|
|
classes=classes,
|
|
|
|
data={"order": order},
|
|
|
|
)
|
|
|
|
|
2023-02-05 23:15:50 +01:00
|
|
|
def add_ue_cols(self, ue: UniteEns, ue_status: dict, col_group: str = None):
|
2023-02-05 18:38:52 +01:00
|
|
|
"Ajoute 2 colonnes: moyenne d'UE et code jury"
|
2023-02-05 23:15:50 +01:00
|
|
|
# table recap standard (mais avec group différent)
|
|
|
|
super().add_ue_cols(ue, ue_status, col_group=col_group or "col_ue")
|
2023-02-05 18:38:52 +01:00
|
|
|
dues = self.table.res.get_etud_decision_ues(self.etud.id)
|
|
|
|
if not dues:
|
|
|
|
return
|
|
|
|
due = dues.get(ue.id)
|
|
|
|
if not due:
|
|
|
|
return
|
|
|
|
col_id = f"moy_ue_{ue.id}_code"
|
|
|
|
self.add_cell(
|
|
|
|
col_id,
|
|
|
|
"", # titre vide
|
|
|
|
due["code"],
|
|
|
|
raw_content=due["code"],
|
|
|
|
group="col_ue",
|
|
|
|
classes=["recorded_code"],
|
|
|
|
column_classes={"col_jury", "col_ue_code"},
|
|
|
|
target_attrs={
|
|
|
|
"title": f"""enregistrée le {due['event_date']}, {
|
|
|
|
(due["ects"] or 0):.3g} ECTS."""
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
def add_rcue_cols(self, dec_rcue: DecisionsProposeesRCUE):
|
|
|
|
"2 cells: moyenne du RCUE, code enregistré"
|
|
|
|
self.table.group_titles["rcue"] = "RCUEs en cours"
|
|
|
|
rcue = dec_rcue.rcue
|
|
|
|
col_id = f"moy_rcue_{rcue.ue_1.niveau_competence_id}" # le niveau_id
|
2023-02-03 15:58:52 +01:00
|
|
|
note_class = ""
|
2023-02-05 18:38:52 +01:00
|
|
|
val = rcue.moy_rcue
|
2023-02-03 15:58:52 +01:00
|
|
|
if isinstance(val, float):
|
2023-02-05 18:38:52 +01:00
|
|
|
if val < BUT_BARRE_RCUE:
|
|
|
|
note_class = "moy_ue_inf"
|
|
|
|
elif val >= BUT_BARRE_RCUE:
|
2023-02-03 15:58:52 +01:00
|
|
|
note_class = "moy_ue_valid"
|
2023-02-05 18:38:52 +01:00
|
|
|
if val < BUT_RCUE_SUFFISANT:
|
2023-02-03 15:58:52 +01:00
|
|
|
note_class = "moy_ue_warning" # notes très basses
|
|
|
|
self.add_cell(
|
|
|
|
col_id,
|
2023-02-05 18:38:52 +01:00
|
|
|
f"<div>{rcue.ue_1.acronyme}</div><div>{rcue.ue_2.acronyme}</div>",
|
|
|
|
self.table.fmt_note(val),
|
|
|
|
raw_content=val,
|
|
|
|
group="rcue",
|
|
|
|
classes=[note_class],
|
|
|
|
column_classes={"col_rcue"},
|
2023-02-03 15:58:52 +01:00
|
|
|
)
|
|
|
|
self.add_cell(
|
|
|
|
col_id + "_code",
|
2023-02-05 18:38:52 +01:00
|
|
|
f"<div>{rcue.ue_1.acronyme}</div><div>{rcue.ue_2.acronyme}</div>",
|
|
|
|
dec_rcue.code_valide or "",
|
|
|
|
group="rcue",
|
|
|
|
classes=["col_rcue_code", "recorded_code"],
|
|
|
|
column_classes={"col_rcue"},
|
2023-02-03 15:58:52 +01:00
|
|
|
)
|
2022-06-23 06:33:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
def formsemestre_saisie_jury_but(
|
2023-02-05 18:38:52 +01:00
|
|
|
formsemestre: FormSemestre,
|
2022-06-29 16:30:01 +02:00
|
|
|
read_only: bool = False,
|
2022-06-25 12:32:00 +02:00
|
|
|
selected_etudid: int = None,
|
|
|
|
mode="jury",
|
2022-06-23 06:33:03 +02:00
|
|
|
) -> str:
|
|
|
|
"""formsemestre est un semestre PAIR
|
|
|
|
Si readonly, ne montre pas le lien "saisir la décision"
|
|
|
|
|
|
|
|
=> page html complète
|
2022-06-25 12:32:00 +02:00
|
|
|
|
|
|
|
Si mode == "recap", table recap des codes, sans liens de saisie.
|
2022-06-23 06:33:03 +02:00
|
|
|
"""
|
|
|
|
# pour chaque etud de res2 trié
|
|
|
|
# S1: UE1, ..., UEn
|
|
|
|
# S2: UE1, ..., UEn
|
|
|
|
#
|
|
|
|
# UE1_s1, UE1_s2, moy_rcue, UE2... , Nbrcue_validables, Nbrcue<8, passage_de_droit, valide_moitie_rcue
|
|
|
|
#
|
|
|
|
# Pour chaque etud de res2 trié
|
|
|
|
# DecisionsProposeesAnnee(etud, formsemestre2)
|
|
|
|
# Pour le 1er etud, faire un check_ues_ready_jury(self) -> page d'erreur
|
|
|
|
# -> rcue .ue_1, .ue_2 -> stroe moy ues, rcue.moy_rcue, etc
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
if formsemestre.formation.referentiel_competence is None:
|
|
|
|
raise ScoNoReferentielCompetences(formation=formsemestre.formation)
|
2022-06-25 22:54:46 +02:00
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
res: ResultatsSemestreBUT = res_sem.load_formsemestre_results(formsemestre)
|
|
|
|
table = TableJury(
|
|
|
|
res,
|
|
|
|
convert_values=True,
|
|
|
|
mode_jury=True,
|
|
|
|
read_only=read_only,
|
|
|
|
classes=[
|
|
|
|
"table_jury_but_bilan" if mode == "recap" else "",
|
|
|
|
"table_recap",
|
|
|
|
"apc",
|
|
|
|
"jury table_jury_but",
|
|
|
|
],
|
|
|
|
selected_row_id=selected_etudid,
|
2022-06-25 12:32:00 +02:00
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
if table.is_empty():
|
2022-06-23 06:33:03 +02:00
|
|
|
return (
|
|
|
|
'<div class="table_recap"><div class="message">aucun étudiant !</div></div>'
|
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
table.data["filename"] = scu.sanitize_filename(
|
|
|
|
f"""jury-but-{formsemestre.titre_num()}-{time.strftime("%Y-%m-%d")}"""
|
2022-06-24 07:28:27 +02:00
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
table_html = table.html()
|
2022-06-23 06:33:03 +02:00
|
|
|
H = [
|
|
|
|
html_sco_header.sco_header(
|
2023-02-05 18:38:52 +01:00
|
|
|
page_title=f"{formsemestre.sem_modalite()}: jury BUT",
|
2022-06-23 06:33:03 +02:00
|
|
|
no_side_bar=True,
|
|
|
|
init_qtip=True,
|
|
|
|
javascripts=["js/etud_info.js", "js/table_recap.js"],
|
|
|
|
),
|
|
|
|
sco_formsemestre_status.formsemestre_status_head(
|
2023-02-05 18:38:52 +01:00
|
|
|
formsemestre_id=formsemestre.id
|
2022-06-23 06:33:03 +02:00
|
|
|
),
|
|
|
|
]
|
2022-06-25 12:32:00 +02:00
|
|
|
if mode == "recap":
|
|
|
|
H.append(
|
2022-06-30 23:49:39 +02:00
|
|
|
f"""<h3>Décisions de jury enregistrées pour les étudiants de ce semestre</h3>
|
|
|
|
<div class="table_jury_but_links">
|
|
|
|
<div>
|
2022-07-08 23:58:27 +02:00
|
|
|
<ul>
|
|
|
|
<li><a href="{url_for(
|
2022-06-30 23:49:39 +02:00
|
|
|
"notes.pvjury_table_but",
|
2023-02-05 18:38:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
|
2022-07-08 23:58:27 +02:00
|
|
|
}" class="stdlink">Tableau PV de jury</a>
|
|
|
|
</li>
|
|
|
|
<li><a href="{url_for(
|
|
|
|
"notes.formsemestre_lettres_individuelles",
|
2023-02-05 18:38:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
|
2022-07-08 23:58:27 +02:00
|
|
|
}" class="stdlink">Courriers individuels (classeur pdf)</a>
|
|
|
|
</li>
|
2022-06-30 23:49:39 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
2022-06-25 12:32:00 +02:00
|
|
|
)
|
2022-06-25 02:59:43 +02:00
|
|
|
H.append(
|
|
|
|
f"""
|
2023-02-05 18:38:52 +01:00
|
|
|
<div class="table_recap">
|
2022-06-25 02:59:43 +02:00
|
|
|
{table_html}
|
2023-02-05 18:38:52 +01:00
|
|
|
</div>
|
|
|
|
|
2022-06-25 02:59:43 +02:00
|
|
|
<div class="table_jury_but_links">
|
2022-06-25 12:32:00 +02:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2022-06-29 16:30:01 +02:00
|
|
|
if (mode == "recap") and not read_only:
|
2022-06-25 12:32:00 +02:00
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<p><a class="stdlink" href="{url_for(
|
|
|
|
"notes.formsemestre_saisie_jury",
|
2023-02-05 18:38:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
|
2022-06-25 12:32:00 +02:00
|
|
|
}">Saisie des décisions du jury</a>
|
|
|
|
</p>"""
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<p><a class="stdlink" href="{url_for(
|
2022-06-25 02:59:43 +02:00
|
|
|
"notes.formsemestre_validation_auto_but",
|
2023-02-05 18:38:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
|
2022-06-25 12:32:00 +02:00
|
|
|
}">Calcul automatique des décisions du jury</a>
|
|
|
|
</p>
|
|
|
|
<p><a class="stdlink" href="{url_for(
|
|
|
|
"notes.formsemestre_jury_but_recap",
|
2023-02-05 18:38:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
|
2022-06-25 12:32:00 +02:00
|
|
|
}">Tableau récapitulatif des décisions du jury</a>
|
|
|
|
</p>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
f"""
|
2022-06-25 02:59:43 +02:00
|
|
|
</div>
|
|
|
|
|
2022-12-25 21:43:22 +01:00
|
|
|
<div class="jury_stats">
|
|
|
|
<div>Nb d'étudiants avec décision annuelle:
|
2023-02-05 18:38:52 +01:00
|
|
|
{sum(table.freq_codes_annuels.values())} / {len(table)}
|
2022-12-25 21:43:22 +01:00
|
|
|
</div>
|
|
|
|
<div><b>Codes annuels octroyés:</b></div>
|
|
|
|
<table class="jury_stats_codes">
|
|
|
|
"""
|
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
for code in sorted(table.freq_codes_annuels.keys()):
|
2022-12-25 21:43:22 +01:00
|
|
|
H.append(
|
|
|
|
f"""<tr>
|
|
|
|
<td>{code}</td>
|
2023-02-05 18:38:52 +01:00
|
|
|
<td style="text-align:right">{table.freq_codes_annuels[code]}</td>
|
2022-12-25 21:43:22 +01:00
|
|
|
<td style="text-align:right">{
|
2023-02-05 18:38:52 +01:00
|
|
|
(100*table.freq_codes_annuels[code] / len(table)):2.1f}%
|
2022-12-25 21:43:22 +01:00
|
|
|
</td>
|
|
|
|
</tr>"""
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
</table>
|
|
|
|
</div>
|
2022-06-25 02:59:43 +02:00
|
|
|
{html_sco_header.sco_footer()}
|
|
|
|
"""
|
|
|
|
)
|
2022-06-23 06:33:03 +02:00
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2022-06-24 07:28:27 +02:00
|
|
|
def build_table_jury_but_html(
|
2022-06-25 12:32:00 +02:00
|
|
|
filename: str, rows, titles, column_ids, selected_etudid: int = None, klass=""
|
2022-06-24 07:28:27 +02:00
|
|
|
) -> str:
|
2022-06-23 06:33:03 +02:00
|
|
|
"""assemble la table html"""
|
2022-06-25 12:32:00 +02:00
|
|
|
footer_rows = [] # inutilisé pour l'instant
|
2022-06-23 06:33:03 +02:00
|
|
|
H = [
|
2022-06-25 12:32:00 +02:00
|
|
|
f"""<div class="table_recap"><table class="table_recap apc jury table_jury_but {klass}"
|
2022-06-23 06:33:03 +02:00
|
|
|
data-filename="{filename}">"""
|
|
|
|
]
|
|
|
|
# header
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<thead>
|
|
|
|
{scu.gen_row(column_ids, titles, "th")}
|
|
|
|
</thead>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
# body
|
|
|
|
H.append("<tbody>")
|
|
|
|
for row in rows:
|
|
|
|
H.append(f"{scu.gen_row(column_ids, row, selected_etudid=selected_etudid)}\n")
|
|
|
|
H.append("</tbody>\n")
|
|
|
|
# footer
|
|
|
|
H.append("<tfoot>")
|
|
|
|
idx_last = len(footer_rows) - 1
|
|
|
|
for i, row in enumerate(footer_rows):
|
|
|
|
H.append(f'{scu.gen_row(column_ids, row, "th" if i == idx_last else "td")}\n')
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
return "".join(H)
|
|
|
|
|
|
|
|
|
2022-06-23 08:40:33 +02:00
|
|
|
class RowCollector:
|
|
|
|
"""Une ligne de la table"""
|
|
|
|
|
2022-06-27 18:41:54 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
cells: dict = None,
|
|
|
|
titles: dict = None,
|
|
|
|
convert_values=True,
|
|
|
|
column_classes: dict = None,
|
|
|
|
):
|
2022-06-23 08:40:33 +02:00
|
|
|
self.titles = titles
|
|
|
|
self.row = cells or {} # col_id : str
|
2022-06-27 18:41:54 +02:00
|
|
|
self.column_classes = column_classes # col_id : str, css class
|
2022-06-23 08:40:33 +02:00
|
|
|
self.idx = 0
|
2022-06-24 08:59:09 +02:00
|
|
|
self.last_etud_cell_idx = 0
|
2022-06-23 08:40:33 +02:00
|
|
|
if convert_values:
|
|
|
|
self.fmt_note = scu.fmt_note
|
|
|
|
else:
|
|
|
|
self.fmt_note = lambda x: x
|
|
|
|
|
|
|
|
def __setitem__(self, key, value):
|
|
|
|
self.row[key] = value
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
return self.row[key]
|
|
|
|
|
2022-06-27 18:41:54 +02:00
|
|
|
def get_row_dict(self):
|
|
|
|
"La ligne, comme un dict"
|
|
|
|
# create empty cells
|
|
|
|
for col_id in self.titles:
|
|
|
|
if col_id not in self.row:
|
|
|
|
self.row[col_id] = ""
|
|
|
|
klass = self.column_classes.get(col_id)
|
|
|
|
if klass:
|
|
|
|
self.row[f"_{col_id}_class"] = klass
|
|
|
|
return self.row
|
|
|
|
|
2022-06-23 08:40:33 +02:00
|
|
|
def add_cell(
|
|
|
|
self,
|
|
|
|
col_id: str,
|
|
|
|
title: str,
|
|
|
|
content: str,
|
|
|
|
classes: str = "",
|
|
|
|
idx: int = None,
|
2022-06-27 18:41:54 +02:00
|
|
|
column_class="",
|
2022-06-23 08:40:33 +02:00
|
|
|
):
|
2022-06-27 18:41:54 +02:00
|
|
|
"""Add a row to our table. classes is a list of css class names"""
|
2022-06-23 08:40:33 +02:00
|
|
|
self.idx = idx if idx is not None else self.idx
|
|
|
|
self.row[col_id] = content
|
|
|
|
if classes:
|
|
|
|
self.row[f"_{col_id}_class"] = classes + f" c{self.idx}"
|
|
|
|
if not col_id in self.titles:
|
|
|
|
self.titles[col_id] = title
|
|
|
|
self.titles[f"_{col_id}_col_order"] = self.idx
|
|
|
|
if classes:
|
|
|
|
self.titles[f"_{col_id}_class"] = classes
|
2022-06-27 18:41:54 +02:00
|
|
|
self.column_classes[col_id] = column_class
|
2022-06-23 08:40:33 +02:00
|
|
|
self.idx += 1
|
|
|
|
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
def get_jury_but_table( # XXX A SUPPRIMER apres avoir recupéré les stats
|
2022-08-03 13:32:59 +02:00
|
|
|
formsemestre2: FormSemestre, read_only: bool = False, mode="jury", with_links=True
|
2022-12-25 21:43:22 +01:00
|
|
|
) -> tuple[list[dict], list[str], list[str], dict]:
|
|
|
|
"""Construit la table des résultats annuels pour le jury BUT
|
|
|
|
=> rows_dict, titles, column_ids, jury_stats
|
|
|
|
où jury_stats est un dict donnant des comptages sur le jury.
|
|
|
|
"""
|
2023-02-05 18:38:52 +01:00
|
|
|
|
|
|
|
# /////// XXX /////// XXX //////
|
2022-06-23 06:33:03 +02:00
|
|
|
titles = {} # column_id : title
|
2022-12-25 21:43:22 +01:00
|
|
|
jury_stats = {
|
|
|
|
"nb_etuds": len(formsemestre2.etuds_inscriptions),
|
|
|
|
"codes_annuels": collections.Counter(),
|
|
|
|
}
|
2023-02-03 15:58:52 +01:00
|
|
|
table = TableJury(res2, mode_jury=True)
|
2022-06-23 06:33:03 +02:00
|
|
|
for etudid in formsemestre2.etuds_inscriptions:
|
2022-06-23 10:13:18 +02:00
|
|
|
etud: Identite = Identite.query.get(etudid)
|
2022-06-23 06:33:03 +02:00
|
|
|
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre2)
|
2023-02-03 15:58:52 +01:00
|
|
|
# XXX row = RowCollector(titles=titles, column_classes=column_classes)
|
|
|
|
row = RowJury(table, etudid)
|
|
|
|
table.add_row(row)
|
|
|
|
row.add_etud(etud)
|
2022-06-24 08:59:09 +02:00
|
|
|
# --- Nombre de niveaux
|
|
|
|
row.add_nb_rcues_cell(deca)
|
2022-06-23 08:40:33 +02:00
|
|
|
# --- Les RCUEs
|
|
|
|
for rcue in deca.rcues_annee:
|
2022-06-28 11:18:12 +02:00
|
|
|
dec_rcue = deca.dec_rcue_by_ue.get(rcue.ue_1.id)
|
|
|
|
if dec_rcue is not None: # None si l'UE n'est pas associée à un niveau
|
|
|
|
row.add_ue_cells(deca.decisions_ues[rcue.ue_1.id])
|
|
|
|
row.add_ue_cells(deca.decisions_ues[rcue.ue_2.id])
|
|
|
|
row.add_rcue_cells(dec_rcue)
|
2022-07-18 17:48:10 +02:00
|
|
|
# --- Les ECTS validés
|
|
|
|
ects_valides = 0.0
|
|
|
|
if deca.res_impair:
|
|
|
|
ects_valides += deca.res_impair.get_etud_ects_valides(etudid)
|
|
|
|
if deca.res_pair:
|
|
|
|
ects_valides += deca.res_pair.get_etud_ects_valides(etudid)
|
|
|
|
row.add_cell(
|
|
|
|
"ects_annee",
|
|
|
|
"ECTS",
|
|
|
|
f"""{int(ects_valides)}""",
|
|
|
|
"col_code_annee",
|
|
|
|
)
|
2022-06-24 07:28:27 +02:00
|
|
|
# --- Le code annuel existant
|
|
|
|
row.add_cell(
|
|
|
|
"code_annee",
|
|
|
|
"Année",
|
|
|
|
f"""{deca.code_valide or ''}""",
|
|
|
|
"col_code_annee",
|
|
|
|
)
|
2022-12-25 21:43:22 +01:00
|
|
|
if deca.code_valide:
|
|
|
|
jury_stats["codes_annuels"][deca.code_valide] += 1
|
2022-06-23 10:13:18 +02:00
|
|
|
# --- Le lien de saisie
|
2022-08-03 13:32:59 +02:00
|
|
|
if mode != "recap" and with_links:
|
2022-06-23 08:40:33 +02:00
|
|
|
row.add_cell(
|
|
|
|
"lien_saisie",
|
|
|
|
"",
|
2022-06-24 07:28:27 +02:00
|
|
|
f"""
|
|
|
|
<a href="{url_for(
|
2022-06-23 08:40:33 +02:00
|
|
|
'notes.formsemestre_validation_but',
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etud.id,
|
|
|
|
formsemestre_id=formsemestre2.id,
|
2022-06-24 07:28:27 +02:00
|
|
|
)}" class="stdlink">
|
2022-06-29 16:30:01 +02:00
|
|
|
{"voir" if read_only else ("modif." if deca.code_valide else "saisie")}
|
2022-06-24 07:28:27 +02:00
|
|
|
décision</a>
|
2022-07-04 23:50:55 +02:00
|
|
|
"""
|
|
|
|
if deca.inscription_etat == scu.INSCRIT
|
|
|
|
else deca.inscription_etat,
|
2022-06-25 12:32:00 +02:00
|
|
|
"col_lien_saisie_but",
|
2022-06-23 08:40:33 +02:00
|
|
|
)
|
2022-06-27 18:41:54 +02:00
|
|
|
rows.append(row)
|
|
|
|
rows_dict = [row.get_row_dict() for row in rows]
|
|
|
|
if len(rows_dict) > 0:
|
2022-12-25 14:47:58 +01:00
|
|
|
col_idx = res2.recap_add_partitions(
|
|
|
|
rows_dict, titles, col_idx=row.last_etud_cell_idx + 1
|
|
|
|
)
|
|
|
|
res2.recap_add_cursus(rows_dict, titles, col_idx=col_idx + 1)
|
2022-06-23 06:33:03 +02:00
|
|
|
column_ids = [title for title in titles if not title.startswith("_")]
|
|
|
|
column_ids.sort(key=lambda col_id: titles.get("_" + col_id + "_col_order", 1000))
|
2022-06-27 18:41:54 +02:00
|
|
|
rows_dict.sort(key=lambda row: row["_nom_disp_order"])
|
2022-12-25 21:43:22 +01:00
|
|
|
return rows_dict, titles, column_ids, jury_stats
|
2022-08-03 13:32:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_jury_but_results(formsemestre: FormSemestre) -> list[dict]:
|
|
|
|
"""Liste des résultats jury BUT sous forme de dict, pour API"""
|
2022-08-17 18:15:48 +02:00
|
|
|
if formsemestre.formation.referentiel_competence is None:
|
|
|
|
# pas de ref. comp., donc pas de decisions de jury (ne lance pas d'exception)
|
|
|
|
return []
|
2022-08-03 13:32:59 +02:00
|
|
|
dpv = sco_pvjury.dict_pvjury(formsemestre.id)
|
|
|
|
rows = []
|
|
|
|
for etudid in formsemestre.etuds_inscriptions:
|
|
|
|
rows.append(get_jury_but_etud_result(formsemestre, dpv, etudid))
|
|
|
|
return rows
|
|
|
|
|
|
|
|
|
|
|
|
def get_jury_but_etud_result(
|
|
|
|
formsemestre: FormSemestre, dpv: dict, etudid: int
|
|
|
|
) -> dict:
|
|
|
|
"""Résultats de jury d'un étudiant sur un semestre pair de BUT"""
|
|
|
|
etud: Identite = Identite.query.get(etudid)
|
|
|
|
dec_etud = dpv["decisions_dict"][etudid]
|
|
|
|
if formsemestre.formation.is_apc():
|
|
|
|
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
|
|
|
|
else:
|
|
|
|
deca = None
|
|
|
|
row = {
|
|
|
|
"etudid": etud.id,
|
|
|
|
"code_nip": etud.code_nip,
|
|
|
|
"code_ine": etud.code_ine,
|
|
|
|
"is_apc": dpv["is_apc"], # BUT ou classic ?
|
|
|
|
"etat": dec_etud["etat"], # I ou D ou DEF
|
|
|
|
"nb_competences": deca.nb_competences if deca else 0,
|
|
|
|
}
|
|
|
|
# --- Les RCUEs
|
|
|
|
rcue_list = []
|
|
|
|
if deca:
|
|
|
|
for rcue in deca.rcues_annee:
|
|
|
|
dec_rcue = deca.dec_rcue_by_ue.get(rcue.ue_1.id)
|
|
|
|
if dec_rcue is not None: # None si l'UE n'est pas associée à un niveau
|
|
|
|
dec_ue1 = deca.decisions_ues[rcue.ue_1.id]
|
|
|
|
dec_ue2 = deca.decisions_ues[rcue.ue_2.id]
|
|
|
|
rcue_dict = {
|
|
|
|
"ue_1": {
|
|
|
|
"ue_id": rcue.ue_1.id,
|
2022-08-10 07:32:55 +02:00
|
|
|
"moy": None
|
|
|
|
if (dec_ue1.moy_ue is None or np.isnan(dec_ue1.moy_ue))
|
|
|
|
else dec_ue1.moy_ue,
|
2022-08-03 13:32:59 +02:00
|
|
|
"code": dec_ue1.code_valide,
|
|
|
|
},
|
|
|
|
"ue_2": {
|
|
|
|
"ue_id": rcue.ue_2.id,
|
2022-08-10 07:32:55 +02:00
|
|
|
"moy": None
|
|
|
|
if (dec_ue2.moy_ue is None or np.isnan(dec_ue2.moy_ue))
|
|
|
|
else dec_ue2.moy_ue,
|
2022-08-03 13:32:59 +02:00
|
|
|
"code": dec_ue2.code_valide,
|
|
|
|
},
|
|
|
|
"moy": rcue.moy_rcue,
|
|
|
|
"code": dec_rcue.code_valide,
|
|
|
|
}
|
|
|
|
rcue_list.append(rcue_dict)
|
|
|
|
row["rcues"] = rcue_list
|
|
|
|
# --- Les UEs
|
|
|
|
ue_list = []
|
|
|
|
if dec_etud["decisions_ue"]:
|
|
|
|
for ue_id, ue_dec in dec_etud["decisions_ue"].items():
|
|
|
|
ue_dict = {
|
|
|
|
"ue_id": ue_id,
|
|
|
|
"code": ue_dec["code"],
|
|
|
|
"ects": ue_dec["ects"],
|
|
|
|
}
|
|
|
|
ue_list.append(ue_dict)
|
|
|
|
row["ues"] = ue_list
|
|
|
|
# --- Le semestre (pour les formations classiques)
|
|
|
|
if dec_etud["decision_sem"]:
|
|
|
|
row["semestre"] = {"code": dec_etud["decision_sem"].get("code")}
|
|
|
|
else:
|
|
|
|
row["semestre"] = {} # APC, ...
|
|
|
|
# --- Autorisations
|
|
|
|
row["autorisations"] = dec_etud["autorisations"]
|
|
|
|
return row
|