2022-06-30 23:49:39 +02:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2022-06-30 23:49:39 +02:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Jury BUT: table synthèse résultats semestre / PV
|
|
|
|
"""
|
|
|
|
from flask import g, request, url_for
|
|
|
|
|
2024-06-26 22:24:10 +02:00
|
|
|
from openpyxl.styles import Alignment
|
2022-06-30 23:49:39 +02:00
|
|
|
|
|
|
|
from app import log
|
|
|
|
from app.but import jury_but
|
2023-06-30 22:33:07 +02:00
|
|
|
from app.but.cursus_but import but_ects_valides
|
2024-07-07 22:07:27 +02:00
|
|
|
from app.models.but_validations import ValidationDUT120
|
2022-06-30 23:49:39 +02:00
|
|
|
from app.models.etudiants import Identite
|
|
|
|
from app.models.formsemestre import FormSemestre
|
|
|
|
from app.scodoc.gen_tables import GenTable
|
|
|
|
from app.scodoc import sco_excel
|
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
|
|
|
from app.scodoc import sco_preferences
|
|
|
|
from app.scodoc import sco_utils as scu
|
|
|
|
|
|
|
|
|
|
|
|
def _descr_cursus_but(etud: Identite) -> str:
|
|
|
|
"description de la liste des semestres BUT suivis"
|
|
|
|
# prend simplement tous les semestre de type APC, ce qui sera faux si
|
|
|
|
# l'étudiant change de spécialité au sein du même département
|
|
|
|
# (ce qui ne peut normalement pas se produire)
|
2023-03-06 22:12:30 +01:00
|
|
|
inscriptions = sorted(
|
2022-07-01 00:15:55 +02:00
|
|
|
[
|
2023-03-06 22:12:30 +01:00
|
|
|
ins
|
2022-07-01 00:15:55 +02:00
|
|
|
for ins in etud.formsemestre_inscriptions
|
|
|
|
if ins.formsemestre.formation.is_apc()
|
2023-03-06 22:12:30 +01:00
|
|
|
],
|
|
|
|
key=lambda i: i.formsemestre.date_debut,
|
2022-07-01 00:15:55 +02:00
|
|
|
)
|
2023-03-06 22:12:30 +01:00
|
|
|
indices = [
|
|
|
|
ins.formsemestre.semestre_id if ins.formsemestre.semestre_id is not None else -1
|
|
|
|
for ins in inscriptions
|
|
|
|
]
|
|
|
|
|
2022-06-30 23:49:39 +02:00
|
|
|
return ", ".join(f"S{indice}" for indice in indices)
|
|
|
|
|
|
|
|
|
2023-02-18 18:49:52 +01:00
|
|
|
def pvjury_page_but(formsemestre_id: int, fmt="html"):
|
2022-06-30 23:49:39 +02:00
|
|
|
"""Page récapitulant les décisions de jury BUT
|
|
|
|
formsemestre peut être pair ou impair
|
|
|
|
"""
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2022-06-30 23:49:39 +02:00
|
|
|
assert formsemestre.formation.is_apc()
|
2023-02-19 02:54:29 +01:00
|
|
|
title = "Procès-verbal de jury BUT"
|
2023-02-18 18:49:52 +01:00
|
|
|
if fmt == "html":
|
2022-10-02 23:43:29 +02:00
|
|
|
line_sep = "<br>"
|
2022-06-30 23:49:39 +02:00
|
|
|
else:
|
|
|
|
line_sep = "\n"
|
2023-02-18 18:49:52 +01:00
|
|
|
rows, titles = pvjury_table_but(formsemestre, line_sep=line_sep)
|
2024-04-02 16:53:04 +02:00
|
|
|
if fmt.startswith("xls"):
|
2024-04-02 17:11:07 +02:00
|
|
|
titles.update(
|
|
|
|
{
|
|
|
|
"etudid": "etudid",
|
|
|
|
"code_nip": "nip",
|
|
|
|
"code_ine": "ine",
|
|
|
|
"ects_but": "Total ECTS BUT",
|
|
|
|
"civilite": "Civ.",
|
|
|
|
"nom": "Nom",
|
|
|
|
"prenom": "Prénom",
|
|
|
|
}
|
|
|
|
)
|
2023-02-18 18:49:52 +01:00
|
|
|
# Style excel... passages à la ligne sur \n
|
|
|
|
xls_style_base = sco_excel.excel_make_style()
|
|
|
|
xls_style_base["alignment"] = Alignment(wrapText=True, vertical="top")
|
|
|
|
tab = GenTable(
|
|
|
|
base_url=f"{request.base_url}?formsemestre_id={formsemestre_id}",
|
|
|
|
caption=title,
|
|
|
|
columns_ids=titles.keys(),
|
|
|
|
html_caption=title,
|
|
|
|
html_class="pvjury_table_but table_leftalign",
|
2023-03-20 11:17:38 +01:00
|
|
|
html_title=f"""<div style="margin-bottom: 8px;"><span
|
|
|
|
style="font-size: 120%; font-weight: bold;">{title}</span>
|
2023-02-18 18:49:52 +01:00
|
|
|
<span style="padding-left: 20px;">
|
2023-12-31 23:04:06 +01:00
|
|
|
<a href="{url_for("notes.pvjury_page_but",
|
2023-02-18 18:49:52 +01:00
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, fmt="xlsx")}"
|
|
|
|
class="stdlink">version excel</a></span></div>
|
|
|
|
|
|
|
|
""",
|
|
|
|
html_with_td_classes=True,
|
|
|
|
origin=f"Généré par {scu.sco_version.SCONAME} le {scu.timedate_human_repr()}",
|
|
|
|
page_title=title,
|
|
|
|
pdf_title=title,
|
|
|
|
preferences=sco_preferences.SemPreferences(),
|
|
|
|
rows=rows,
|
|
|
|
table_id="formation_table_recap",
|
|
|
|
titles=titles,
|
|
|
|
xls_columns_width={
|
|
|
|
"nom": 32,
|
|
|
|
"cursus": 12,
|
|
|
|
"ues": 32,
|
|
|
|
"niveaux": 32,
|
|
|
|
"decision_but": 14,
|
|
|
|
"diplome": 17,
|
|
|
|
"devenir": 8,
|
|
|
|
"observations": 12,
|
|
|
|
},
|
|
|
|
xls_style_base=xls_style_base,
|
|
|
|
)
|
2024-07-28 17:40:40 +02:00
|
|
|
return tab.make_page(fmt=fmt, javascripts=["js/etud_info.js"])
|
2023-02-18 18:49:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
def pvjury_table_but(
|
2023-02-21 02:30:48 +01:00
|
|
|
formsemestre: FormSemestre,
|
|
|
|
etudids: list[int] = None,
|
|
|
|
line_sep: str = "\n",
|
|
|
|
only_diplome=False,
|
|
|
|
anonymous=False,
|
|
|
|
with_paragraph_nom=False,
|
2023-02-18 18:49:52 +01:00
|
|
|
) -> tuple[list[dict], dict]:
|
2023-02-19 02:54:29 +01:00
|
|
|
"""Table avec résultats jury BUT pour PV.
|
|
|
|
Si etudids est None, prend tous les étudiants inscrits.
|
|
|
|
"""
|
2023-02-19 15:45:27 +01:00
|
|
|
# remplace pour le BUT la fonction sco_pv_forms.pvjury_table
|
2022-06-30 23:49:39 +02:00
|
|
|
annee_but = (formsemestre.semestre_id + 1) // 2
|
2023-06-30 22:33:07 +02:00
|
|
|
referentiel_competence_id = formsemestre.formation.referentiel_competence_id
|
|
|
|
if referentiel_competence_id is None:
|
|
|
|
raise ScoValueError(
|
|
|
|
"pas de référentiel de compétences associé à la formation de ce semestre !"
|
|
|
|
)
|
2022-06-30 23:49:39 +02:00
|
|
|
titles = {
|
2024-04-02 17:11:07 +02:00
|
|
|
"nom_pv": "Code" if anonymous else "Nom",
|
2022-06-30 23:49:39 +02:00
|
|
|
"cursus": "Cursus",
|
2023-02-18 18:49:52 +01:00
|
|
|
"ects": "ECTS",
|
2022-07-01 22:29:19 +02:00
|
|
|
"ues": "UE validées",
|
2022-06-30 23:49:39 +02:00
|
|
|
"niveaux": "Niveaux de compétences validés",
|
|
|
|
"decision_but": f"Décision BUT{annee_but}",
|
|
|
|
"diplome": "Résultat au diplôme",
|
|
|
|
"devenir": "Devenir",
|
|
|
|
"observations": "Observations",
|
|
|
|
}
|
|
|
|
rows = []
|
2023-02-19 02:54:29 +01:00
|
|
|
formsemestre_etudids = formsemestre.etuds_inscriptions.keys()
|
|
|
|
if etudids is None:
|
|
|
|
etudids = formsemestre_etudids
|
|
|
|
for etudid in etudids:
|
|
|
|
if not etudid in formsemestre_etudids:
|
|
|
|
continue # garde fou
|
2023-03-20 11:17:38 +01:00
|
|
|
etud = Identite.get_etud(etudid)
|
2022-06-30 23:49:39 +02:00
|
|
|
try:
|
|
|
|
deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre)
|
|
|
|
if deca.annee_but != annee_but: # wtf ?
|
|
|
|
log(
|
|
|
|
f"pvjury_table_but: inconsistent annee_but {deca.annee_but} != {annee_but}"
|
|
|
|
)
|
|
|
|
continue
|
|
|
|
except ScoValueError:
|
|
|
|
deca = None
|
2023-02-21 02:30:48 +01:00
|
|
|
|
2024-04-02 16:53:04 +02:00
|
|
|
ects_but_valides = but_ects_valides(etud, referentiel_competence_id)
|
2024-07-12 16:21:27 +02:00
|
|
|
has_diplome = deca.valide_diplome() if deca else False
|
2024-07-07 22:07:27 +02:00
|
|
|
diplome_lst = ["ADM"] if has_diplome else []
|
|
|
|
validation_dut120 = ValidationDUT120.query.filter_by(
|
|
|
|
etudid=etudid, formsemestre_id=formsemestre.id
|
|
|
|
).first()
|
|
|
|
if validation_dut120:
|
|
|
|
diplome_lst.append("Diplôme de DUT validé.")
|
|
|
|
diplome_str = ". ".join(diplome_lst)
|
2022-06-30 23:49:39 +02:00
|
|
|
row = {
|
2024-04-02 17:11:07 +02:00
|
|
|
"nom_pv": (
|
2024-04-02 16:53:04 +02:00
|
|
|
etud.code_ine or etud.code_nip or etud.id
|
|
|
|
if anonymous # Mode anonyme: affiche INE ou sinon NIP, ou id
|
|
|
|
else etud.etat_civil_pv(
|
|
|
|
line_sep=line_sep, with_paragraph=with_paragraph_nom
|
|
|
|
)
|
2023-02-21 02:30:48 +01:00
|
|
|
),
|
2024-04-02 17:11:07 +02:00
|
|
|
"_nom_pv_order": etud.sort_key,
|
|
|
|
"_nom_pv_target_attrs": f'class="etudinfo" id="{etud.id}"',
|
|
|
|
"_nom_pv_td_attrs": f'id="{etud.id}" class="etudinfo"',
|
|
|
|
"_nom_pv_target": url_for(
|
2024-01-20 14:49:36 +01:00
|
|
|
"scolar.fiche_etud",
|
2022-07-01 22:29:19 +02:00
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etud.id,
|
|
|
|
),
|
2022-06-30 23:49:39 +02:00
|
|
|
"cursus": _descr_cursus_but(etud),
|
2024-07-12 16:21:27 +02:00
|
|
|
"ects": (
|
|
|
|
f"""{deca.ects_annee():g}<br><br>Tot. {ects_but_valides:g}"""
|
|
|
|
if deca
|
|
|
|
else ""
|
|
|
|
),
|
|
|
|
"_ects_xls": deca.ects_annee() if deca else "",
|
2024-04-02 16:53:04 +02:00
|
|
|
"ects_but": ects_but_valides,
|
2022-07-01 22:29:19 +02:00
|
|
|
"ues": deca.descr_ues_validation(line_sep=line_sep) if deca else "-",
|
2024-04-02 16:53:04 +02:00
|
|
|
"niveaux": (
|
|
|
|
deca.descr_niveaux_validation(line_sep=line_sep) if deca else "-"
|
|
|
|
),
|
2022-06-30 23:49:39 +02:00
|
|
|
"decision_but": deca.code_valide if deca else "",
|
2024-04-02 16:53:04 +02:00
|
|
|
"devenir": (
|
2024-06-19 18:28:23 +02:00
|
|
|
"Diplôme obtenu"
|
|
|
|
if has_diplome
|
|
|
|
else (
|
|
|
|
", ".join([f"S{i}" for i in deca.get_autorisations_passage()])
|
|
|
|
if deca
|
|
|
|
else ""
|
|
|
|
)
|
2024-04-02 16:53:04 +02:00
|
|
|
),
|
2024-07-07 22:07:27 +02:00
|
|
|
"diplome": diplome_str,
|
2024-04-02 17:11:07 +02:00
|
|
|
# pour exports excel seulement:
|
|
|
|
"civilite": etud.civilite_etat_civil_str,
|
|
|
|
"nom": etud.nom,
|
|
|
|
"prenom": etud.prenom_etat_civil or etud.prenom or "",
|
|
|
|
"etudid": etud.id,
|
|
|
|
"code_nip": etud.code_nip,
|
|
|
|
"code_ine": etud.code_ine,
|
2022-06-30 23:49:39 +02:00
|
|
|
}
|
2024-07-12 16:21:27 +02:00
|
|
|
if (deca and deca.valide_diplome()) or not only_diplome:
|
2023-02-21 02:30:48 +01:00
|
|
|
rows.append(row)
|
2022-06-30 23:49:39 +02:00
|
|
|
|
2024-04-02 17:11:07 +02:00
|
|
|
rows.sort(key=lambda x: x["_nom_pv_order"])
|
2023-02-18 18:49:52 +01:00
|
|
|
return rows, titles
|