1
0
forked from ScoDoc/ScoDoc

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 """Tableau de bord module
""" """
import math
import time import time
from flask import g, url_for 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_evals=can_edit_evals,
can_edit_notes=can_edit_notes, can_edit_notes=can_edit_notes,
eval_index=eval_index, eval_index=eval_index,
has_expression=has_expression,
nb_evals=len(mod_evals), nb_evals=len(mod_evals),
is_apc=nt.is_apc,
) )
) )
eval_index -= 1 eval_index -= 1
@ -500,8 +501,8 @@ def _ligne_evaluation(
can_edit_evals: bool = False, can_edit_evals: bool = False,
can_edit_notes: bool = False, can_edit_notes: bool = False,
eval_index: int = 0, eval_index: int = 0,
has_expression: bool = False,
nb_evals: int = 0, nb_evals: int = 0,
is_apc=False,
) -> str: ) -> str:
"""Ligne <tr> décrivant une évaluation dans le tableau de bord moduleimpl.""" """Ligne <tr> décrivant une évaluation dans le tableau de bord moduleimpl."""
H = [] H = []
@ -524,6 +525,15 @@ def _ligne_evaluation(
H.append("""<tr><td colspan="8">&nbsp;</td></tr>""") H.append("""<tr><td colspan="8">&nbsp;</td></tr>""")
tr_class_1 += " mievr_spaced" tr_class_1 += " mievr_spaced"
H.append(f"""<tr class="{tr_class_1}"><td class="mievr_tit" colspan="8">""") 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: if evaluation.jour:
H.append( H.append(
f"""Le {evaluation.jour.strftime("%d/%m/%Y")} {evaluation.descr_heure()}""" f"""Le {evaluation.jour.strftime("%d/%m/%Y")} {evaluation.descr_heure()}"""
@ -543,12 +553,6 @@ def _ligne_evaluation(
H.append( H.append(
"""<span class="mievr_rattr" title="remplace autres notes">session 2</span>""" """<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"]: if etat["last_modif"]:
H.append( H.append(
@ -556,25 +560,27 @@ def _ligne_evaluation(
etat["last_modif"].strftime("%d/%m/%Y à %Hh%M")})</span>""" etat["last_modif"].strftime("%d/%m/%Y à %Hh%M")})</span>"""
) )
# #
H.append('<span class="evalindex_cont">')
if has_expression or True:
H.append( H.append(
f"""<span class="evalindex" title="Indice dans les vecteurs (formules)">{ f"""<span class="evalindex_cont">
eval_index:2}</span>""" <span class="evalindex" title="Indice dans les vecteurs (formules)">{
eval_index:2}</span>
<span class="eval_arrows_chld">
"""
) )
# Fleches: # Fleches:
H.append('<span class="eval_arrows_chld">')
if eval_index != (nb_evals - 1) and can_edit_evals: if eval_index != (nb_evals - 1) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>' f"""<a href="{url_for("notes.module_evaluation_move",
% (evaluation.id, arrow_up) scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=0)
}" class="aud">{arrow_up}</a>"""
) )
else: else:
H.append(arrow_none) H.append(arrow_none)
if (eval_index > 0) and can_edit_evals: if (eval_index > 0) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>' f"""<a href="{url_for("notes.module_evaluation_move",
% (evaluation.id, arrow_down) scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=1)
}" class="aud">{arrow_down}</a>"""
) )
else: else:
H.append(arrow_none) H.append(arrow_none)
@ -679,21 +685,24 @@ def _ligne_evaluation(
) )
# #
H.append( H.append(
"""</td> f"""</td>
<td class="mievr_dur">%s</td><td class="rightcell mievr_coef">%s</td>""" <td class="mievr_dur">{eval_dict["duree"]}</td>
% (eval_dict["duree"], "%g" % eval_dict["coefficient"]) <td class="rightcell mievr_coef">{eval_dict["coefficient"]:g}</td>
"""
) )
H.append( H.append(
"""<td class="rightcell mievr_nbnotes">%(nb_notes)s / %(nb_inscrits)s</td> f"""
<td class="rightcell mievr_coef">%(nb_abs)s</td> <td class="rightcell mievr_nbnotes">{etat["nb_notes"]} / {etat["nb_inscrits"]}</td>
<td class="rightcell mievr_coef">%(nb_neutre)s</td> <td class="rightcell mievr_coef">{etat["nb_abs"]}</td>
<td class="rightcell mievr_coef">{etat["nb_neutre"]}</td>
<td class="rightcell">""" <td class="rightcell">"""
% etat % etat
) )
if etat["moy"]: if etat["moy"]:
H.append("<b>%s / %g</b>" % (etat["moy"], eval_dict["note_max"]))
H.append( 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) scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id)
}">afficher</a>)""" }">afficher</a>)"""
) )
@ -744,7 +753,8 @@ def _ligne_evaluation(
) )
if gr_moyenne["gr_nb_att"] > 0: if gr_moyenne["gr_nb_att"] > 0:
H.append( 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(""")""") H.append(""")""")
if gr_moyenne["group_id"] in etat["gr_incomplets"]: if gr_moyenne["group_id"] in etat["gr_incomplets"]:
@ -773,3 +783,30 @@ def _ligne_evaluation(
H.append("</span>") H.append("</span>")
H.append("""</td></tr>""") H.append("""</td></tr>""")
return "\n".join(H) 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; 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 { span.moduleimpl_abs_link {
padding-right: 2em; padding-right: 2em;
} }

View File

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