Améliore evaluation_listenotes + cosmetic

This commit is contained in:
Emmanuel Viennet 2024-08-26 08:34:15 +02:00
parent b26692f3cd
commit 0c3216e432
4 changed files with 76 additions and 41 deletions

View File

@ -63,12 +63,13 @@ def do_evaluation_listenotes(
"""
Affichage des notes d'une évaluation (si evaluation_id)
ou de toutes les évaluations d'un module (si moduleimpl_id)
"""
mode = None
evaluations: list[Evaluation] = []
if moduleimpl_id is not None:
mode = "module"
modimpl = ModuleImpl.query.get_or_404(moduleimpl_id)
modimpl = ModuleImpl.get_modimpl(moduleimpl_id)
evaluations = modimpl.evaluations.all()
elif evaluation_id is not None:
mode = "eval"
@ -76,11 +77,13 @@ def do_evaluation_listenotes(
else:
raise ValueError("missing argument: evaluation or module")
if not evaluations:
if fmt == "json":
return [], ""
return "<p>Aucune évaluation !</p>", "ScoDoc"
evaluation = evaluations[0]
modimpl = evaluation.moduleimpl # il y a au moins une evaluation
# description de l'evaluation
# description de l'évaluation
if evaluation_id is not None:
H = [sco_evaluations.evaluation_describe(evaluation_id=evaluation_id)]
page_title = f"Notes {evaluation.description or modimpl.module.code}"
@ -172,6 +175,17 @@ def do_evaluation_listenotes(
"template": "%(elem)s &nbsp;&nbsp;",
},
),
(
"split_groups",
{
"input_type": "checkbox",
"title": "",
"allowed_values": ("yes",),
"labels": ("détailler les groupes",),
"attributes": ('onclick="document.tf.submit();"',),
"template": "%(elem)s &nbsp;&nbsp;",
},
),
(
"with_emails",
{
@ -213,6 +227,7 @@ def do_evaluation_listenotes(
anonymous_listing = tf[2]["anonymous_listing"]
note_sur_20 = tf[2]["note_sur_20"]
hide_groups = tf[2]["hide_groups"]
split_groups = tf[2]["split_groups"]
with_emails = tf[2]["with_emails"]
group_ids = [x for x in tf[2]["group_ids"] if x != ""]
return (
@ -224,6 +239,7 @@ def do_evaluation_listenotes(
anonymous_listing=anonymous_listing,
group_ids=group_ids,
hide_groups=hide_groups,
split_groups=split_groups,
with_emails=with_emails,
mode=mode,
),
@ -238,6 +254,7 @@ def _make_table_notes(
note_sur_20=False,
anonymous_listing=False,
hide_groups=False,
split_groups=False,
with_emails=False,
group_ids: list[int] | None = None,
mode="module", # "eval" or "module"
@ -284,7 +301,13 @@ def _make_table_notes(
columns_ids = ["etudid", "nom", "prenom"]
else:
columns_ids = ["nomprenom"]
if not hide_groups and fmt not in {"xml", "json"}:
partitions = []
if split_groups:
partitions = formsemestre.get_partitions_list(
with_default=False, only_listed=True
)
columns_ids += [f"partition_{p.id}" for p in partitions]
elif not hide_groups and fmt not in {"xml", "json"}:
# n'indique pas les groupes en xml et json car notation "humaine" ici
columns_ids.append("group")
@ -299,6 +322,7 @@ def _make_table_notes(
"emailperso": "e-mail perso",
"signatures": "Signatures",
}
titles.update({f"partition_{p.id}": p.partition_name or "" for p in partitions})
rows = []
class KeyManager(dict):
@ -339,19 +363,23 @@ def _make_table_notes(
if etat == scu.INSCRIT: # si inscrit, indique groupe
groups = sco_groups.get_etud_groups(etudid, formsemestre.id)
grc = sco_groups.listgroups_abbrev(groups)
groups_cols = {
f"partition_{p.id}": p.get_etud_group(etudid).group_name or ""
for p in partitions
}
else:
if etat == scu.DEMISSION:
grc = "DEM" # attention: ce code est re-ecrit plus bas, ne pas le changer (?)
css_row_class = "etuddem"
else:
grc = etat
groups_cols = {f"partition_{p.id}": etat for p in partitions}
code = getattr(etud, anonymous_lst_key)
if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid
code = etudid
rows.append(
{
row = {
"code": str(code), # INE, NIP ou etudid
"_code_td_attrs": 'style="padding-left: 1em; padding-right: 2em;"',
"etudid": etudid,
@ -373,7 +401,8 @@ def _make_table_notes(
"emailperso": etud.get_first_email("emailperso"),
"_css_row_class": css_row_class or "",
}
)
row.update(groups_cols)
rows.append(row)
# Lignes en tête:
row_coefs = {
@ -517,6 +546,8 @@ def _make_table_notes(
gl = "&anonymous_listing%3Alist=yes" + gl
if hide_groups:
gl = "&hide_groups%3Alist=yes" + gl
if split_groups:
gl = "&split_groups%3Alist=yes" + gl
if with_emails:
gl = "&with_emails%3Alist=yes" + gl
if len(evaluations) == 1:
@ -573,7 +604,7 @@ def _make_table_notes(
title = f"Notes {module.type_name()} {module.code} {module.titre}"
title += f""" semestre {formsemestre.titre_mois()}"""
if gr_title and gr_title != "tous":
title += " {gr_title}"
title += f" {gr_title}"
caption = title
html_next_section = ""
if fmt == "pdf" or fmt == "bordereau":

View File

@ -446,7 +446,8 @@ textarea {
*/
@media (min-width: 769px) {
.form-group input[type="submit"] {
width: 192px;
min-width: 192px;
width: auto;
}
}

View File

@ -36,7 +36,7 @@
<label class="edition">
<input type="checkbox" autocomplete="off" id="inputModif"
{% if edit_partition %}checked{% endif %}>
Modifier les partitions et groupes
Créer ou modifier partitions et groupes
</label>
<div class="filtres"></div>
<div style="display: flex; justify-content: space-between;">

View File

@ -1755,26 +1755,29 @@ def evaluation_create(moduleimpl_id):
)
@bp.route("/evaluation_listenotes", methods=["GET", "POST"]) # API ScoDoc 7 compat
@bp.route("/evaluation_listenotes")
@scodoc
@permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func
def evaluation_listenotes():
"""Affichage des notes d'une évaluation.
Si evaluation_id non spécifié, toutes les notes des évaluations de ce modimpl.
Args:
- evaluation_id (une seule éval)
- ou moduleimpl_id (toutes les évals du module)
- group_ids: groupes à lister
- fmt : html, xls, pdf, json
"""
evaluation_id = None
moduleimpl_id = None
vals = scu.get_request_args()
# Arguments
evaluation_id = request.args.get("evaluation_id")
moduleimpl_id = request.args.get("moduleimpl_id")
try:
if "evaluation_id" in vals:
evaluation_id = int(vals["evaluation_id"])
if "moduleimpl_id" in vals and vals["moduleimpl_id"]:
moduleimpl_id = int(vals["moduleimpl_id"])
if evaluation_id is not None:
evaluation_id = int(evaluation_id)
if moduleimpl_id is not None:
moduleimpl_id = int(moduleimpl_id)
except ValueError as exc:
raise ScoValueError("evaluation_listenotes: id invalides !") from exc
fmt = vals.get("fmt", "html")
fmt = request.args.get("fmt", "html")
#
content, page_title = sco_liste_notes.do_evaluation_listenotes(
evaluation_id=evaluation_id, moduleimpl_id=moduleimpl_id, fmt=fmt
)