Refactoring / année BUT sur fiche étudiant (montage provoisoire)

This commit is contained in:
Emmanuel Viennet 2022-06-29 18:16:37 +02:00
parent b0e78b67ea
commit 16b3221daa
4 changed files with 48 additions and 144 deletions

View File

@ -200,6 +200,7 @@ class DecisionsProposeesAnnee(DecisionsProposees):
formsemestre: FormSemestre,
):
super().__init__(etud=etud)
self.formsemestre_id = formsemestre.id
formsemestre_impair, formsemestre_pair = self.comp_formsemestres(formsemestre)
assert (
(formsemestre_pair is None)

View File

@ -36,6 +36,7 @@ from flask_login import current_user
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app import log
from app.but import jury_but_view
from app.models.etudiants import make_etud_args
from app.scodoc import html_sco_header
from app.scodoc import htmlutils
@ -445,6 +446,10 @@ def ficheEtud(etudid=None):
else:
info["groupes_row"] = ""
info["menus_etud"] = menus_etud(etudid)
# raccordement provisoire pour juillet 2022, avant refonte complète de cette fiche...
info["but_infos_mkup"] = jury_but_view.infos_fiche_etud_html(etudid)
tmpl = """<div class="menus_etud">%(menus_etud)s</div>
<div class="ficheEtud" id="ficheEtud"><table>
<tr><td>
@ -477,6 +482,8 @@ def ficheEtud(etudid=None):
%(inscriptions_mkup)s
%(but_infos_mkup)s
<div class="ficheadmission">
%(adm_data)s
@ -513,7 +520,7 @@ def ficheEtud(etudid=None):
"""
header = html_sco_header.sco_header(
page_title="Fiche étudiant %(prenom)s %(nom)s" % info,
cssstyles=["libjs/jQuery-tagEditor/jquery.tag-editor.css"],
cssstyles=["libjs/jQuery-tagEditor/jquery.tag-editor.css", "css/jury_but.css"],
javascripts=[
"libjs/jinplace-1.2.1.min.js",
"js/ue_list.js",

View File

@ -65,11 +65,17 @@
font-weight: bold;
}
.but_navigation {
padding-top: 16px;
grid-column: 1 / -1;
display: flex;
justify-content: space-between;
margin-left: 50px;
margin-right: 50px;
}
.but_navigation div {
display: inline-block;
margin-left: 50px;
margin-right: 50px;
}
div.but_section_annee {

View File

@ -31,7 +31,6 @@ Module notes: issu de ScoDoc7 / ZNotes.py
Emmanuel Viennet, 2021
"""
from email.policy import default
from operator import itemgetter
import time
from xml.etree import ElementTree
@ -43,6 +42,7 @@ from flask_login import current_user
from app.but import jury_but, jury_but_validation_auto
from app.but.forms import jury_but_forms
from app.but import jury_but_view
from app.comp import res_sem
from app.comp.res_but import ResultatsSemestreBUT
from app.comp.res_compat import NotesTableCompat
@ -2281,13 +2281,7 @@ def formsemestre_validation_but(
etudid=etudid,
)
)
if deca.code_valide and not read_only:
erase_span = f"""<a href="{
url_for("notes.formsemestre_jury_but_erase",
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id,
etudid=etudid)}" class="stdlink">effacer décisions</a>"""
else:
erase_span = ""
warning = ""
if len(deca.niveaux_competences) != len(deca.decisions_rcue_by_niveau):
warning += f"""<div class="warning">Attention: {len(deca.niveaux_competences)}
@ -2305,69 +2299,10 @@ def formsemestre_validation_but(
</div>
<form method="POST">
<div class="but_section_annee">
<div>
<b>Décision de jury pour l'année :</b> {
_gen_but_select("code_annee", deca.codes, deca.code_valide,
disabled=True, klass="manual")
}
<span>({'non ' if deca.code_valide is None else ''}enregistrée)</span>
<span>{erase_span}</span>
</div>
<div class="but_explanation">{deca.explanation}</div>
</div>
<div><b>Niveaux de compétences et unités d'enseignement :</b></div>
<div class="but_annee">
<div class="titre"></div>
<div class="titre">S{1}</div>
<div class="titre">S{2}</div>
<div class="titre">RCUE</div>
"""
)
for niveau in deca.niveaux_competences:
H.append(
f"""<div class="but_niveau_titre">
<div title="{niveau.competence.titre_long}">{niveau.competence.titre}</div>
</div>"""
)
dec_rcue = deca.decisions_rcue_by_niveau.get(niveau.id)
if dec_rcue is None:
break
# Semestre impair
H.append(
_gen_but_niveau_ue(
dec_rcue.rcue.ue_1,
dec_rcue.rcue.moy_ue_1,
deca.decisions_ues[dec_rcue.rcue.ue_1.id],
disabled=read_only,
)
)
# Semestre pair
H.append(
_gen_but_niveau_ue(
dec_rcue.rcue.ue_2,
dec_rcue.rcue.moy_ue_2,
deca.decisions_ues[dec_rcue.rcue.ue_2.id],
disabled=read_only,
)
)
# RCUE
H.append(
f"""<div class="but_niveau_rcue
{'recorded' if dec_rcue.code_valide is not None else ''}
">
<div class="but_note">{scu.fmt_note(dec_rcue.rcue.moy_rcue)}</div>
<div class="but_code">{
_gen_but_select("code_rcue_"+str(niveau.id),
dec_rcue.codes,
dec_rcue.code_valide,
disabled=True, klass="manual"
)
}</div>
</div>"""
)
H.append("</div>") # but_annee
H.append(jury_but_view.show_etud(deca, read_only=read_only))
if read_only:
H.append(
@ -2389,39 +2324,36 @@ def formsemestre_validation_but(
</div>
"""
)
# --- Navigation
prev = f"""<a href="{url_for(
"notes.formsemestre_validation_but", scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id, etudid="PREV"
)} class="stdlink"">précédent</a>
"""
next = f"""<a href="{url_for(
"notes.formsemestre_validation_but", scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id, etudid="NEXT"
)} class="stdlink"">suivant</a>
"""
H.append(
f"""<div class="but_navigation">
<div class="back_list">
<a href="{url_for("notes.formsemestre_saisie_jury", scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id, selected_etudid=etud.id
)}" class="stdlink">retour à la liste</a>
f"""
<div class="but_navigation">
<div class="prev">
{prev}
</div>
</div>"""
<div class="back_list">
<a href="{url_for(
"notes.formsemestre_saisie_jury", scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id, selected_etudid=etud.id
)}" class="stdlink">retour à la liste</a>
</div>
<div class="next">
{next}
</div>
</div>
"""
)
# # --- Navigation
# prev = f"""<a href="{url_for(
# "notes.formsemestre_validation_but", scodoc_dept=g.scodoc_dept,
# formsemestre_id=formsemestre_id, etudid="PREV"
# )} class="stdlink"">précédent</a>
# """
# H.append(
# f"""
# <div class="but_navigation">
# <div class="prev">
# {prev}
# </div>
# <div class="back_list">
# <a href="{url_for(
# "notes.formsemestre_saisie_jury", scodoc_dept=g.scodoc_dept,
# formsemestre_id=formsemestre_id, selected_etudid=etud.id
# )}" class="stdlink">retour à la liste</a>
# </div>
# <div class="next">
# next TODO
# </div>
# </div>"""
# )
H.append("</form>") # but_annee
H.append("</form>")
H.append(
render_template(
@ -2436,48 +2368,6 @@ def formsemestre_validation_but(
return "\n".join(H) + html_sco_header.sco_footer()
def _gen_but_select(
name: str,
codes: list[str],
code_valide: str,
disabled: bool = False,
klass: str = "",
) -> str:
"Le menu html select avec les codes"
h = "\n".join(
[
f"""<option value="{code}"
{'selected' if code == code_valide else ''}
class="{'recorded' if code == code_valide else ''}"
>{code}</option>"""
for code in codes
]
)
return f"""<select required name="{name}"
class="but_code {klass}"
onchange="change_menu_code(this);"
{"disabled" if disabled else ""}
>{h}</select>
"""
def _gen_but_niveau_ue(
ue: UniteEns, moy_ue: float, dec_ue: jury_but.DecisionsProposeesUE, disabled=False
):
return f"""<div class="but_niveau_ue {
'recorded' if dec_ue.code_valide is not None else ''}
">
<div title="{ue.titre}">{ue.acronyme}</div>
<div class="but_note">{scu.fmt_note(moy_ue)}</div>
<div class="but_code">{
_gen_but_select("code_ue_"+str(ue.id),
dec_ue.codes,
dec_ue.code_valide, disabled=disabled
)
}</div>
</div>"""
@bp.route(
"/formsemestre_validation_auto_but/<int:formsemestre_id>", methods=["GET", "POST"]
)