Jurys BUT: améliore message erreur si pas RCUE
This commit is contained in:
parent
21460df51a
commit
4f7827f8c2
@ -63,6 +63,8 @@ from operator import attrgetter
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
from flask import g, url_for
|
||||
|
||||
from app import db
|
||||
from app import log
|
||||
from app.comp.res_but import ResultatsSemestreBUT
|
||||
@ -93,6 +95,32 @@ from app.scodoc import sco_utils as scu
|
||||
from app.scodoc.sco_exceptions import ScoException, ScoValueError
|
||||
|
||||
|
||||
class NoRCUEError(ScoValueError):
|
||||
"""Erreur en cas de RCUE manquant"""
|
||||
|
||||
def __init__(self, deca: "DecisionsProposeesAnnee", ue: UniteEns):
|
||||
if all(u.niveau_competence for u in deca.ues_pair):
|
||||
warning_pair = ""
|
||||
else:
|
||||
warning_pair = """<div class="warning">certaines UE du semestre pair ne sont pas associées à un niveau de compétence</div>"""
|
||||
if all(u.niveau_competence for u in deca.ues_impair):
|
||||
warning_impair = ""
|
||||
else:
|
||||
warning_impair = """<div class="warning">certaines UE du semestre impair ne sont pas associées à un niveau de compétence</div>"""
|
||||
msg = (
|
||||
f"""<h3>Pas de RCUE pour l'UE {ue.acronyme}</h3>
|
||||
{warning_impair}
|
||||
{warning_pair}
|
||||
<div><b>UE {ue.acronyme}</b>: niveau {html.escape(str(ue.niveau_competence))}</div>
|
||||
<div><b>UEs impaires:</b> {html.escape(', '.join(str(u.niveau_competence or "pas de niveau")
|
||||
for u in deca.ues_impair))}
|
||||
</div>
|
||||
"""
|
||||
+ deca.infos()
|
||||
)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class DecisionsProposees:
|
||||
"""Une décision de jury proposé, constituée d'une liste de codes et d'une explication.
|
||||
Super-classe, spécialisée pour les UE, les RCUE, les années et le diplôme.
|
||||
@ -196,6 +224,8 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
)
|
||||
"le rang de l'année dans le BUT: 1, 2, 3"
|
||||
assert self.annee_but in (1, 2, 3)
|
||||
self.rcues_annee = []
|
||||
"RCUEs de l'année"
|
||||
if self.formsemestre_impair is not None:
|
||||
self.validation = ApcValidationAnnee.query.filter_by(
|
||||
etudid=self.etud.id,
|
||||
@ -234,7 +264,6 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
}
|
||||
)
|
||||
self.rcues_annee = self.compute_rcues_annee()
|
||||
"RCUEs de l'année"
|
||||
|
||||
formation = (
|
||||
self.formsemestre_impair.formation
|
||||
@ -295,15 +324,41 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
|
||||
def infos(self) -> str:
|
||||
"informations, for debugging purpose"
|
||||
return f"""DecisionsProposeesAnnee
|
||||
etud: {self.etud}
|
||||
formsemestre_impair: {self.formsemestre_impair}
|
||||
formsemestre_pair: {self.formsemestre_pair}
|
||||
RCUEs: {self.rcues_annee}
|
||||
nb_competences: {self.nb_competences}
|
||||
nb_nb_validables: {self.nb_validables}
|
||||
codes: {self.codes}
|
||||
explanation: {self.explanation}
|
||||
return f"""<b>DecisionsProposeesAnnee</b>
|
||||
<ul>
|
||||
<li>Etudiant: <a href="{url_for("scolar.ficheEtud",
|
||||
scodoc_dept=g.scodoc_dept, etudid=self.etud.id)
|
||||
}">{self.etud.nomprenom}</a>
|
||||
</li>
|
||||
<li>formsemestre_impair: <a href="{url_for("notes.formsemestre_status",
|
||||
scodoc_dept=g.scodoc_dept, formsemestre_id=self.formsemestre_impair.id)
|
||||
}">{html.escape(str(self.formsemestre_impair))}</a>
|
||||
<ul>
|
||||
<li>Formation: <a href="{url_for('notes.ue_table', scodoc_dept=g.scodoc_dept,
|
||||
semestre_idx=self.formsemestre_impair.semestre_id,
|
||||
formation_id=self.formsemestre_impair.formation.id)}">
|
||||
{self.formsemestre_impair.formation.to_html()} ({self.formsemestre_impair.formation.id})</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>formsemestre_pair: <a href="{url_for("notes.formsemestre_status",
|
||||
scodoc_dept=g.scodoc_dept, formsemestre_id=self.formsemestre_pair.id)
|
||||
}">{html.escape(str(self.formsemestre_pair))}</a>
|
||||
<ul>
|
||||
<li>Formation: <a href="{url_for('notes.ue_table', scodoc_dept=g.scodoc_dept,
|
||||
semestre_idx=self.formsemestre_pair.semestre_id,
|
||||
formation_id=self.formsemestre_pair.formation.id)}">
|
||||
{self.formsemestre_pair.formation.to_html()} ({self.formsemestre_pair.formation.id})</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>RCUEs: {html.escape(str(self.rcues_annee))}</li>
|
||||
<li>nb_competences: {getattr(self, "nb_competences", "-")}</li>
|
||||
<li>nb_nb_validables: {getattr(self, "nb_validables", "-")}</li>
|
||||
<li>codes: {self.codes}</li>
|
||||
<li>explanation: {self.explanation}</li>
|
||||
</ul>
|
||||
"""
|
||||
|
||||
def annee_scolaire(self) -> int:
|
||||
@ -416,11 +471,11 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
ues_impair_sans_rcue.discard(ue_impair.id)
|
||||
break
|
||||
if rcue is None:
|
||||
raise ScoValueError(f"pas de RCUE pour l'UE {ue_pair.acronyme}")
|
||||
raise NoRCUEError(deca=self, ue=ue_pair)
|
||||
rcues_annee.append(rcue)
|
||||
if len(ues_impair_sans_rcue) > 0:
|
||||
ue = UniteEns.query.get(ues_impair_sans_rcue.pop())
|
||||
raise ScoValueError(f"pas de RCUE pour l'UE {ue.acronyme}")
|
||||
raise NoRCUEError(deca=self, ue=ue)
|
||||
return rcues_annee
|
||||
|
||||
def compute_decisions_niveaux(self) -> dict[int, "DecisionsProposeesRCUE"]:
|
||||
|
@ -57,6 +57,10 @@ class Formation(db.Model):
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__name__}(id={self.id}, dept_id={self.dept_id}, acronyme='{self.acronyme!r}')>"
|
||||
|
||||
def to_html(self) -> str:
|
||||
"titre complet pour affichage"
|
||||
return f"""Formation {self.titre} ({self.acronyme}) [version {self.version}] code {self.formation_code}"""
|
||||
|
||||
def to_dict(self):
|
||||
e = dict(self.__dict__)
|
||||
e.pop("_sa_instance_state", None)
|
||||
|
@ -676,9 +676,7 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
|
||||
],
|
||||
page_title=f"Programme {formation.acronyme}",
|
||||
),
|
||||
f"""<h2>Formation {formation.titre} ({formation.acronyme})
|
||||
[version {formation.version}] code {formation.formation_code}
|
||||
{lockicon}
|
||||
f"""<h2>{formation.to_html()} {lockicon}
|
||||
</h2>
|
||||
""",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user