diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index e7597735..b7a6acc4 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -38,7 +38,7 @@ from flask_login import current_user from app.comp import res_sem from app.comp.res_compat import NotesTableCompat -from app.models import FormSemestre +from app.models import Evaluation, FormSemestre from app.models import ScolarNews import app.scodoc.sco_utils as scu from app.scodoc.sco_utils import ModuleType @@ -83,9 +83,6 @@ def convert_note_from_string( """converti une valeur (chaine saisie) vers une note numérique (float) Les listes absents, tosuppress et invalids sont modifiées """ - absents = absents or [] - tosuppress = tosuppress or [] - invalids = invalids or [] invalid = False note_value = None note = note.replace(",", ".") @@ -104,7 +101,7 @@ def convert_note_from_string( note_value = float(note) if (note_value < note_min) or (note_value > note_max): raise ValueError - except: + except ValueError: invalids.append(etudid) invalid = True @@ -157,7 +154,7 @@ def _check_notes(notes, evaluation, mod): try: etudid = int(etudid) # except ValueError as exc: - raise ScoValueError(f"Code étudiant ({etudid}) invalide") + raise ScoValueError(f"Code étudiant ({etudid}) invalide") from exc if note[:3] == "DEM": continue # skip ! if note: @@ -174,7 +171,6 @@ def _check_notes(notes, evaluation, mod): L.append((etudid, value)) else: withoutnotes.append(etudid) - return L, invalids, withoutnotes, absents, tosuppress @@ -306,13 +302,15 @@ def do_evaluation_upload_xls(): def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False): """Initialisation des notes manquantes""" - E = sco_evaluation_db.do_evaluation_list({"evaluation_id": evaluation_id})[0] - M = sco_moduleimpl.moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[0] + # XXX E = sco_evaluation_db.do_evaluation_list({"evaluation_id": evaluation_id})[0] + # XXX M = sco_moduleimpl.moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[0] + evaluation = Evaluation.query.get_or_404(evaluation_id) + modimpl = evaluation.moduleimpl + # Check access # (admin, respformation, and responsable_id) - if not sco_permissions_check.can_edit_notes(current_user, E["moduleimpl_id"]): - # XXX imaginer un redirect + msg erreur - raise AccessDenied("Modification des notes impossible pour %s" % current_user) + if not sco_permissions_check.can_edit_notes(current_user, modimpl.id): + raise AccessDenied(f"Modification des notes impossible pour {current_user}") # notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id) etudid_etats = sco_groups.do_evaluation_listeetuds_groups( @@ -323,30 +321,36 @@ def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False): if etudid not in notes_db: # pas de note notes.append((etudid, value)) # Check value - L, invalids, _, _, _ = _check_notes(notes, E, M["module"]) + L, invalids, _, _, _ = _check_notes( + notes, evaluation.to_dict(), modimpl.module.to_dict() + ) + dest_url = url_for( + "notes.saisie_notes", scodoc_dept=g.scodoc_dept, evaluation_id=evaluation_id + ) diag = "" - if len(invalids): - diag = "Valeur %s invalide" % value + if len(invalids) > 0: + diag = f"Valeur {value} invalide ou hors barème" if diag: - return ( - html_sco_header.sco_header() - + '

%s

Recommencer' - % (diag, evaluation_id) - + html_sco_header.sco_footer() - ) + return f""" + {html_sco_header.sco_header()} +

{diag}

+

+ Recommencer +

+ {html_sco_header.sco_footer()} + """ # Confirm action if not dialog_confirmed: return scu.confirm_dialog( - """

Mettre toutes les notes manquantes de l'évaluation - à la valeur %s ?

+ f"""

Mettre toutes les notes manquantes de l'évaluation + à la valeur {value} ?

Seuls les étudiants pour lesquels aucune note (ni valeur, ni ABS, ni EXC) n'a été rentrée seront affectés.

-

%d étudiants concernés par ce changement de note.

+

{len(L)} étudiants concernés par ce changement de note.

Attention, les étudiants sans notes de tous les groupes de ce semestre seront affectés.

- """ - % (value, len(L)), + """, dest_url="", - cancel_url="saisie_notes?evaluation_id=%s" % evaluation_id, + cancel_url=dest_url, parameters={"evaluation_id": evaluation_id, "value": value}, ) # ok @@ -368,27 +372,23 @@ def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False): url=mod["url"], max_frequency=30 * 60, ) - return ( - html_sco_header.sco_header() - + f""" + return f""" + { html_sco_header.sco_header() }

{nb_changed} notes changées

+ { html_sco_header.sco_footer() } """ - + html_sco_header.sco_footer() - ) def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False): diff --git a/app/static/js/saisie_notes.js b/app/static/js/saisie_notes.js index 5fc09a12..43997ab0 100644 --- a/app/static/js/saisie_notes.js +++ b/app/static/js/saisie_notes.js @@ -34,6 +34,7 @@ function valid_note(e) { } else { /* Saisie invalide */ this.className = "note_invalid"; + sco_message("valeur invalide ou hors barème"); } }