forked from ScoDoc/ScoDoc
Fix #357 (saisie notes manquantes hors barème)
This commit is contained in:
parent
a59f5136a4
commit
6766eca1d0
@ -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"])
|
||||
diag = ""
|
||||
if len(invalids):
|
||||
diag = "Valeur %s invalide" % value
|
||||
if diag:
|
||||
return (
|
||||
html_sco_header.sco_header()
|
||||
+ '<h2>%s</h2><p><a href="saisie_notes?evaluation_id=%s">Recommencer</a>'
|
||||
% (diag, evaluation_id)
|
||||
+ html_sco_header.sco_footer()
|
||||
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) > 0:
|
||||
diag = f"Valeur {value} invalide ou hors barème"
|
||||
if diag:
|
||||
return f"""
|
||||
{html_sco_header.sco_header()}
|
||||
<h2>{diag}</h2>
|
||||
<p><a href="{ dest_url }">
|
||||
Recommencer</a>
|
||||
</p>
|
||||
{html_sco_header.sco_footer()}
|
||||
"""
|
||||
# Confirm action
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
"""<h2>Mettre toutes les notes manquantes de l'évaluation
|
||||
à la valeur %s ?</h2>
|
||||
f"""<h2>Mettre toutes les notes manquantes de l'évaluation
|
||||
à la valeur {value} ?</h2>
|
||||
<p>Seuls les étudiants pour lesquels aucune note (ni valeur, ni ABS, ni EXC)
|
||||
n'a été rentrée seront affectés.</p>
|
||||
<p><b>%d étudiants concernés par ce changement de note.</b></p>
|
||||
<p><b>{len(L)} étudiants concernés par ce changement de note.</b></p>
|
||||
<p class="warning">Attention, les étudiants sans notes de tous les groupes de ce semestre seront affectés.</p>
|
||||
"""
|
||||
% (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() }
|
||||
<h2>{nb_changed} notes changées</h2>
|
||||
<ul>
|
||||
<li><a class="stdlink" href="{url_for("notes.saisie_notes",
|
||||
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation_id)
|
||||
}">
|
||||
<li><a class="stdlink" href="{dest_url}">
|
||||
Revenir au formulaire de saisie des notes</a>
|
||||
</li>
|
||||
<li><a class="stdlink" href="{
|
||||
url_for(
|
||||
"notes.moduleimpl_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
moduleimpl_id=M["moduleimpl_id"],
|
||||
moduleimpl_id=evaluation.moduleimpl_id,
|
||||
)}">Tableau de bord du module</a>
|
||||
</li>
|
||||
</ul>
|
||||
{ html_sco_header.sco_footer() }
|
||||
"""
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
|
||||
|
||||
def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False):
|
||||
|
@ -34,6 +34,7 @@ function valid_note(e) {
|
||||
} else {
|
||||
/* Saisie invalide */
|
||||
this.className = "note_invalid";
|
||||
sco_message("valeur invalide ou hors barème");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user