Visualise poids évaluation sur tableau bord module. Closes #411.

This commit is contained in:
Emmanuel Viennet 2022-10-02 18:43:18 +02:00
parent dcf0f73c1b
commit 7bbdff67a0
3 changed files with 97 additions and 31 deletions

View File

@ -27,6 +27,7 @@
"""Tableau de bord module
"""
import math
import time
from flask import g, url_for
@ -439,8 +440,8 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
can_edit_evals=can_edit_evals,
can_edit_notes=can_edit_notes,
eval_index=eval_index,
has_expression=has_expression,
nb_evals=len(mod_evals),
is_apc=nt.is_apc,
)
)
eval_index -= 1
@ -500,8 +501,8 @@ def _ligne_evaluation(
can_edit_evals: bool = False,
can_edit_notes: bool = False,
eval_index: int = 0,
has_expression: bool = False,
nb_evals: int = 0,
is_apc=False,
) -> str:
"""Ligne <tr> décrivant une évaluation dans le tableau de bord moduleimpl."""
H = []
@ -524,6 +525,15 @@ def _ligne_evaluation(
H.append("""<tr><td colspan="8">&nbsp;</td></tr>""")
tr_class_1 += " mievr_spaced"
H.append(f"""<tr class="{tr_class_1}"><td class="mievr_tit" colspan="8">""")
coef = evaluation.coefficient
if is_apc:
coef *= sum(evaluation.get_ue_poids_dict().values())
# Avertissement si coefs x poids nuls
if coef < scu.NOTES_PRECISION:
H.append("""<span class="eval_warning_coef">coef. nul !</span>""")
elif is_apc:
# visualisation des poids
H.append(_evaluation_poids_html(evaluation))
if evaluation.jour:
H.append(
f"""Le {evaluation.jour.strftime("%d/%m/%Y")} {evaluation.descr_heure()}"""
@ -543,12 +553,6 @@ def _ligne_evaluation(
H.append(
"""<span class="mievr_rattr" title="remplace autres notes">session 2</span>"""
)
# Avertissement si coefs/poids nuls
if (
evaluation.coefficient * sum(evaluation.get_ue_poids_dict().values())
< scu.NOTES_PRECISION
):
H.append("""<span class="eval_warning_coef">coef. nul !</span>""")
#
if etat["last_modif"]:
H.append(
@ -556,25 +560,27 @@ def _ligne_evaluation(
etat["last_modif"].strftime("%d/%m/%Y à %Hh%M")})</span>"""
)
#
H.append('<span class="evalindex_cont">')
if has_expression or True:
H.append(
f"""<span class="evalindex" title="Indice dans les vecteurs (formules)">{
eval_index:2}</span>"""
)
H.append(
f"""<span class="evalindex_cont">
<span class="evalindex" title="Indice dans les vecteurs (formules)">{
eval_index:2}</span>
<span class="eval_arrows_chld">
"""
)
# Fleches:
H.append('<span class="eval_arrows_chld">')
if eval_index != (nb_evals - 1) and can_edit_evals:
H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>'
% (evaluation.id, arrow_up)
f"""<a href="{url_for("notes.module_evaluation_move",
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=0)
}" class="aud">{arrow_up}</a>"""
)
else:
H.append(arrow_none)
if (eval_index > 0) and can_edit_evals:
H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>'
% (evaluation.id, arrow_down)
f"""<a href="{url_for("notes.module_evaluation_move",
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=1)
}" class="aud">{arrow_down}</a>"""
)
else:
H.append(arrow_none)
@ -606,7 +612,7 @@ def _ligne_evaluation(
else:
etat_txt = ""
if can_edit_evals and etat_txt:
etat_txt = f"""<a href="{ url_for("notes.evaluation_edit",
etat_txt = f"""<a href="{ url_for("notes.evaluation_edit",
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id)
}" title="{etat_descr}">{etat_txt}</a>"""
@ -679,21 +685,24 @@ def _ligne_evaluation(
)
#
H.append(
"""</td>
<td class="mievr_dur">%s</td><td class="rightcell mievr_coef">%s</td>"""
% (eval_dict["duree"], "%g" % eval_dict["coefficient"])
f"""</td>
<td class="mievr_dur">{eval_dict["duree"]}</td>
<td class="rightcell mievr_coef">{eval_dict["coefficient"]:g}</td>
"""
)
H.append(
"""<td class="rightcell mievr_nbnotes">%(nb_notes)s / %(nb_inscrits)s</td>
<td class="rightcell mievr_coef">%(nb_abs)s</td>
<td class="rightcell mievr_coef">%(nb_neutre)s</td>
<td class="rightcell">"""
f"""
<td class="rightcell mievr_nbnotes">{etat["nb_notes"]} / {etat["nb_inscrits"]}</td>
<td class="rightcell mievr_coef">{etat["nb_abs"]}</td>
<td class="rightcell mievr_coef">{etat["nb_neutre"]}</td>
<td class="rightcell">"""
% etat
)
if etat["moy"]:
H.append("<b>%s / %g</b>" % (etat["moy"], eval_dict["note_max"]))
H.append(
f"""&nbsp; (<a href="{url_for('notes.evaluation_listenotes',
f"""<b>{etat["moy"]} / {eval_dict["note_max"]:g}</b>
&nbsp; (<a class="stdlink" href="{
url_for('notes.evaluation_listenotes',
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id)
}">afficher</a>)"""
)
@ -744,7 +753,8 @@ def _ligne_evaluation(
)
if gr_moyenne["gr_nb_att"] > 0:
H.append(
f""", <span class="redboldtext">{gr_moyenne["gr_nb_att"]} en attente</span>"""
f""", <span class="redboldtext">{
gr_moyenne["gr_nb_att"]} en attente</span>"""
)
H.append(""")""")
if gr_moyenne["group_id"] in etat["gr_incomplets"]:
@ -773,3 +783,30 @@ def _ligne_evaluation(
H.append("</span>")
H.append("""</td></tr>""")
return "\n".join(H)
def _evaluation_poids_html(evaluation: Evaluation) -> str:
"""graphe html montrant les poids de l'évaluation"""
ue_poids = evaluation.get_ue_poids_dict() # { ue_id : poids }
if not ue_poids:
return
max_poids = max(ue_poids.values())
if max_poids < scu.NOTES_PRECISION:
return
# style="--max:{max_poids}
H = (
"""<div class="evaluation_poids">"""
+ "\n".join(
[
f"""<div title="poids vers {ue.acronyme}: {poids:g}"><div style="--size:{math.sqrt(poids/max_poids*144)}px;
{'background-color: ' + ue.color + ';' if ue.color else ''}
"></div></div>"""
for ue, poids in (
(UniteEns.query.get(ue_id), poids)
for ue_id, poids in ue_poids.items()
)
]
)
+ "</div>"
)
return H

View File

@ -1752,6 +1752,35 @@ div#modimpl_coefs {
background-color: #9c0;
}
/* visualisation poids évaluations */
.evaluation_poids {
height: 12px;
display: inline-flex;
text-align: center;
}
.evaluation_poids>div {
display: inline-flex;
height: 12px;
width: 12px;
margin-left: 2px;
margin-right: 2px;
/* padding: 0 0px 0 0px; */
border: 1px solid rgb(180, 180, 180);
align-items: center;
justify-content: center;
}
.evaluation_poids>div>div {
/* --height: calc(12px * var(--coef) / var(--max)); */
height: var(--size);
width: var(--size);
/* padding: 0 0 0 0; */
/* var(--height) */
background: #09c;
/* box-sizing: border-box; */
}
span.moduleimpl_abs_link {
padding-right: 2em;
}

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.3.50"
SCOVERSION = "9.3.51"
SCONAME = "ScoDoc"