2022-06-23 06:33:03 +02:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 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-27 18:41:54 +02:00
|
|
|
import numpy as np
|
2022-06-23 06:33:03 +02:00
|
|
|
from flask import g, url_for
|
|
|
|
|
2023-02-12 23:03:12 +01:00
|
|
|
from app.but import cursus_but
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.but import jury_but
|
2024-03-22 17:39:48 +01:00
|
|
|
from app.but.jury_but import DecisionsProposeesRCUE
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
from app.comp.res_compat import NotesTableCompat
|
2023-02-12 23:03:12 +01:00
|
|
|
from app.models import ApcNiveau, UniteEns
|
2022-06-23 06:33:03 +02:00
|
|
|
from app.models.etudiants import Identite
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc.codes_cursus import (
|
2022-06-23 08:40:33 +02:00
|
|
|
BUT_BARRE_RCUE,
|
|
|
|
BUT_RCUE_SUFFISANT,
|
|
|
|
)
|
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:
|
2023-02-06 13:17:57 +01:00
|
|
|
if self.rows: # non vide
|
|
|
|
if self.res.is_apc:
|
2023-02-12 23:03:12 +01:00
|
|
|
self.add_but_competences()
|
2023-02-06 13:17:57 +01:00
|
|
|
self.add_rcues()
|
|
|
|
self.add_jury()
|
|
|
|
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:
|
|
|
|
deca = row.deca
|
|
|
|
if deca.code_valide:
|
|
|
|
self.freq_codes_annuels[deca.code_valide] += 1
|
|
|
|
row.add_nb_rcues_cell()
|
|
|
|
# --- Les RCUEs
|
2023-06-28 21:25:38 +02:00
|
|
|
for dec_rcue in deca.get_decisions_rcues_annee():
|
|
|
|
if dec_rcue.rcue.complete:
|
2023-02-05 18:38:52 +01:00
|
|
|
row.add_rcue_cols(dec_rcue)
|
2023-06-20 12:14:16 +02:00
|
|
|
self.freq_codes_annuels["total"] = len(self.rows)
|
2023-02-05 18:38:52 +01:00
|
|
|
|
|
|
|
def add_jury(self):
|
|
|
|
"""Ajoute la colonne code jury et le lien.
|
2023-06-18 21:20:02 +02:00
|
|
|
- Le code jury est celui du semestre: cette colonne n'est montrée
|
2023-02-05 18:38:52 +01:00
|
|
|
que pour les formations classiques, ce code n'est pas utilisé en BUT.
|
2023-06-18 21:20:02 +02:00
|
|
|
- En BUT, on donne la décision de jury annuelle.
|
2023-02-05 18:38:52 +01:00
|
|
|
"""
|
|
|
|
res = self.res
|
2023-02-12 02:21:31 +01:00
|
|
|
autorisations = res.get_autorisations_inscription()
|
2023-06-18 21:20:02 +02:00
|
|
|
if res.is_apc:
|
|
|
|
validations_annee = res.get_validations_annee()
|
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-06 18:59:51 +01:00
|
|
|
"jury_code_sem",
|
|
|
|
"Jury",
|
2023-02-06 22:43:07 +01:00
|
|
|
jury_code_sem or "",
|
2023-02-06 18:59:51 +01:00
|
|
|
group="jury_code_sem",
|
2023-02-06 22:43:07 +01:00
|
|
|
classes=[] if jury_code_sem else ["empty_code"],
|
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"""
|
2023-02-12 02:21:31 +01:00
|
|
|
# Autorisations inscription
|
|
|
|
row.add_cell(
|
|
|
|
"autorisations_inscription",
|
|
|
|
"Passage",
|
2024-03-22 17:39:48 +01:00
|
|
|
(
|
|
|
|
", ".join("S" + str(i) for i in sorted(autorisations[etud.id]))
|
|
|
|
if etud.id in autorisations
|
|
|
|
else ""
|
|
|
|
),
|
2023-02-12 02:21:31 +01:00
|
|
|
group="jury_code_sem",
|
|
|
|
classes=["recorded_code"],
|
|
|
|
)
|
2023-06-18 21:20:02 +02:00
|
|
|
if res.is_apc: # BUT
|
|
|
|
validation_annee = validations_annee.get(etud.id, None)
|
|
|
|
row.add_cell(
|
|
|
|
"decision_annuelle",
|
|
|
|
"Année",
|
|
|
|
validation_annee.code if validation_annee else "",
|
|
|
|
group="jury_code_sem",
|
|
|
|
classes=["recorded_code"],
|
|
|
|
)
|
2023-02-12 02:21:31 +01:00
|
|
|
# Lien saisie ou visu jury
|
2023-02-06 22:43:07 +01:00
|
|
|
a_saisir = (not res.validations) or (not res.validations.has_decision(etud))
|
2023-02-05 23:15:50 +01:00
|
|
|
row.add_cell(
|
|
|
|
"jury_link",
|
|
|
|
"",
|
2023-02-06 22:43:07 +01:00
|
|
|
f"""{("➨ saisir" if a_saisir else "modifier")
|
2023-02-12 01:13:43 +01:00
|
|
|
if not self.read_only else "voir"} décisions""",
|
2023-02-05 23:15:50 +01:00
|
|
|
group="col_jury_link",
|
2023-02-06 22:43:07 +01:00
|
|
|
classes=["fontred"] if a_saisir else [],
|
2024-03-22 17:39:48 +01:00
|
|
|
no_excel=True,
|
2023-02-05 23:15:50 +01:00
|
|
|
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-12 23:03:12 +01:00
|
|
|
def add_but_competences(self):
|
|
|
|
"Ajoute les colonnes résultats BUT (niveaux de compétences des 3 années)"
|
|
|
|
prev_group = "cursus"
|
|
|
|
for annee in ("BUT1", "BUT2", "BUT3"):
|
|
|
|
group = f"cursus_{annee}"
|
|
|
|
self.insert_group(group, after=prev_group)
|
|
|
|
prev_group = group
|
|
|
|
self.group_titles[group] = f"Compétences {annee}"
|
|
|
|
for row in self.rows:
|
|
|
|
etud = row.etud
|
|
|
|
cursus_dict = cursus_but.EtudCursusBUT(
|
|
|
|
etud, self.res.formsemestre.formation
|
|
|
|
).to_dict()
|
|
|
|
first = True
|
|
|
|
for competence_id in cursus_dict:
|
|
|
|
for annee in ("BUT1", "BUT2", "BUT3"):
|
|
|
|
validation_rcue = cursus_dict[competence_id][annee]
|
|
|
|
if validation_rcue:
|
|
|
|
niveau: ApcNiveau = validation_rcue.niveau()
|
|
|
|
titre = f"C{niveau.competence.numero}" # à voir (nommer les compétences...)
|
|
|
|
row.add_cell(
|
2023-03-27 23:57:10 +02:00
|
|
|
f"c_{competence_id}_{annee}",
|
2023-02-12 23:03:12 +01:00
|
|
|
titre,
|
|
|
|
validation_rcue.code,
|
|
|
|
group="cursus_" + annee,
|
2023-02-19 23:06:44 +01:00
|
|
|
classes=[],
|
2023-02-12 23:03:12 +01:00
|
|
|
column_classes=["cursus_but" + (" first" if first else "")],
|
|
|
|
target_attrs={
|
|
|
|
"title": f"{niveau.competence.titre} niveau {niveau.ordre}"
|
|
|
|
},
|
|
|
|
)
|
|
|
|
first = False
|
|
|
|
|
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-23 21:49:09 +01:00
|
|
|
if self.table.res.get_etud_etat(self.id) != scu.INSCRIT:
|
|
|
|
return # rien pour DEM et DEF
|
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")
|
|
|
|
|
2023-06-28 21:25:38 +02:00
|
|
|
if len(deca.get_decisions_rcues_annee()) > 0:
|
2023-02-03 15:58:52 +01:00
|
|
|
# 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}"
|
|
|
|
|
2023-02-23 21:49:09 +01:00
|
|
|
# RCUE pouvant être validés
|
2023-02-03 15:58:52 +01:00
|
|
|
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-19 23:06:44 +01:00
|
|
|
dues = self.table.res.get_etud_decisions_ue(self.etud.id)
|
2023-02-09 16:01:56 +01:00
|
|
|
due = dues.get(ue.id) if dues else None
|
|
|
|
|
2023-02-05 18:38:52 +01:00
|
|
|
col_id = f"moy_ue_{ue.id}_code"
|
2023-02-09 16:01:56 +01:00
|
|
|
title = (
|
|
|
|
f"""{ue.acronyme} enregistrée le {due['event_date']}, {
|
|
|
|
(due["ects"] or 0):.3g} ECTS."""
|
|
|
|
if due
|
|
|
|
else """pas de décision"""
|
|
|
|
)
|
2023-02-05 18:38:52 +01:00
|
|
|
self.add_cell(
|
|
|
|
col_id,
|
|
|
|
"", # titre vide
|
2023-02-09 16:01:56 +01:00
|
|
|
due["code"] if due else "",
|
|
|
|
raw_content=due["code"] if due else "",
|
2023-02-05 18:38:52 +01:00
|
|
|
group="col_ue",
|
|
|
|
classes=["recorded_code"],
|
|
|
|
column_classes={"col_jury", "col_ue_code"},
|
2023-02-09 16:01:56 +01:00
|
|
|
target_attrs={"title": title},
|
2023-02-05 18:38:52 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def add_rcue_cols(self, dec_rcue: DecisionsProposeesRCUE):
|
|
|
|
"2 cells: moyenne du RCUE, code enregistré"
|
|
|
|
rcue = dec_rcue.rcue
|
2023-06-28 21:25:38 +02:00
|
|
|
if not rcue.complete:
|
|
|
|
return
|
|
|
|
col_id = f"moy_rcue_{rcue.niveau.id}" # le niveau_id
|
|
|
|
self.table.group_titles["rcue"] = "RCUEs en cours"
|
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,
|
2024-03-22 17:39:48 +01:00
|
|
|
raw_title=f"{rcue.ue_1.acronyme}-{rcue.ue_2.acronyme}",
|
2023-02-05 18:38:52 +01:00
|
|
|
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>",
|
2023-02-06 22:43:07 +01:00
|
|
|
dec_rcue.code_valide or "",
|
2023-02-05 18:38:52 +01:00
|
|
|
group="rcue",
|
2023-02-06 22:43:07 +01:00
|
|
|
classes=[
|
|
|
|
"col_rcue_code",
|
|
|
|
"recorded_code",
|
|
|
|
"empty_code" if not dec_rcue.code_valide else "",
|
|
|
|
],
|
2023-02-05 18:38:52 +01:00
|
|
|
column_classes={"col_rcue"},
|
2024-03-22 17:39:48 +01:00
|
|
|
raw_title=f"{rcue.ue_1.acronyme}-{rcue.ue_2.acronyme}",
|
2023-02-03 15:58:52 +01:00
|
|
|
)
|
2022-06-23 06:33:03 +02:00
|
|
|
|
2023-02-06 13:05:39 +01: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",
|
|
|
|
# )
|