Saisie excel multi-eval: améliore message log

This commit is contained in:
Emmanuel Viennet 2024-07-19 19:03:39 +02:00
parent a3394bd779
commit b80d8fb454

View File

@ -603,14 +603,20 @@ def do_evaluations_upload_xls(
# -- Enregistre les notes de chaque évaluation # -- Enregistre les notes de chaque évaluation
with sco_cache.DeferredSemCacheManager(): with sco_cache.DeferredSemCacheManager():
messages_by_eval, etudids_with_decisions = _record_notes_evaluations( messages_by_eval, etudids_with_decisions, modimpl_ids_changed = (
evaluations, notes_by_eval, comment, diag, rows=rows _record_notes_evaluations(
evaluations, notes_by_eval, comment, diag, rows=rows
)
) )
# -- News # -- News
if len(evaluations) > 1: if len(evaluations) > 1:
modules_str = ", ".join( modules_str = ", ".join(
[evaluation.moduleimpl.module.code for evaluation in evaluations] {
evaluation.moduleimpl.module.code
for evaluation in evaluations
if evaluation.moduleimpl_id in modimpl_ids_changed
}
) )
status_url = ( status_url = (
url_for( url_for(
@ -647,7 +653,7 @@ def do_evaluations_upload_xls(
obj=obj_id, obj=obj_id,
text=f"""Chargement notes dans <a href="{status_url}">{modules_str}</a>""", text=f"""Chargement notes dans <a href="{status_url}">{modules_str}</a>""",
url=status_url, url=status_url,
max_frequency=30 * 60, # 30 minutes max_frequency=10 * 60, # 10 minutes
) )
msg = "<div>" + "\n".join(messages_by_eval.values()) + "</div>" msg = "<div>" + "\n".join(messages_by_eval.values()) + "</div>"
@ -709,9 +715,12 @@ def _read_notes_from_rows(
def _record_notes_evaluations( def _record_notes_evaluations(
evaluations, notes_by_eval, comment, diag, rows: list[list[str]] | None = None evaluations, notes_by_eval, comment, diag, rows: list[list[str]] | None = None
) -> tuple[dict[int, str], set[int]]: ) -> tuple[dict[int, str], set[int], set[int]]:
"""Enregistre les notes dans les évaluations """Enregistre les notes dans les évaluations
Return: messages_by_eval, etudids_with_decisions Return:
messages_by_eval : dict { evaluation_id : message }
etudids_with_decisions : set of etudids with decision and mark changed
modimpl_ids_changed : set of ModuleImplId where at least one mark changed
""" """
# -- Check values de chaque évaluation # -- Check values de chaque évaluation
valid_notes_by_eval, etudids_without_notes_by_eval, etudids_absents_by_eval = ( valid_notes_by_eval, etudids_without_notes_by_eval, etudids_absents_by_eval = (
@ -720,6 +729,7 @@ def _record_notes_evaluations(
messages_by_eval: dict[int, str] = {} messages_by_eval: dict[int, str] = {}
etudids_with_decisions = set() etudids_with_decisions = set()
modimpl_ids_changed = set()
for evaluation in evaluations: for evaluation in evaluations:
valid_notes = valid_notes_by_eval.get(evaluation.id) valid_notes = valid_notes_by_eval.get(evaluation.id)
if not valid_notes: if not valid_notes:
@ -730,6 +740,8 @@ def _record_notes_evaluations(
) )
) )
etudids_with_decisions |= set(etudids_with_decisions_eval) etudids_with_decisions |= set(etudids_with_decisions_eval)
if etudids_changed:
modimpl_ids_changed.add(evaluation.moduleimpl_id)
msg = f"""<div class="diag-evaluation"> msg = f"""<div class="diag-evaluation">
<ul> <ul>
<li><div class="{'diag-change' if etudids_changed else 'diag-nochange'}"> <li><div class="{'diag-change' if etudids_changed else 'diag-nochange'}">
@ -761,7 +773,7 @@ def _record_notes_evaluations(
</div>""" </div>"""
msg += """</div>""" msg += """</div>"""
messages_by_eval[evaluation.id] = msg messages_by_eval[evaluation.id] = msg
return messages_by_eval, etudids_with_decisions return messages_by_eval, etudids_with_decisions, modimpl_ids_changed
def _check_notes_evaluations( def _check_notes_evaluations(