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 import res_sem
|
||||||
from app.comp.res_compat import NotesTableCompat
|
from app.comp.res_compat import NotesTableCompat
|
||||||
from app.models import FormSemestre
|
from app.models import Evaluation, FormSemestre
|
||||||
from app.models import ScolarNews
|
from app.models import ScolarNews
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app.scodoc.sco_utils import ModuleType
|
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)
|
"""converti une valeur (chaine saisie) vers une note numérique (float)
|
||||||
Les listes absents, tosuppress et invalids sont modifiées
|
Les listes absents, tosuppress et invalids sont modifiées
|
||||||
"""
|
"""
|
||||||
absents = absents or []
|
|
||||||
tosuppress = tosuppress or []
|
|
||||||
invalids = invalids or []
|
|
||||||
invalid = False
|
invalid = False
|
||||||
note_value = None
|
note_value = None
|
||||||
note = note.replace(",", ".")
|
note = note.replace(",", ".")
|
||||||
@ -104,7 +101,7 @@ def convert_note_from_string(
|
|||||||
note_value = float(note)
|
note_value = float(note)
|
||||||
if (note_value < note_min) or (note_value > note_max):
|
if (note_value < note_min) or (note_value > note_max):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except:
|
except ValueError:
|
||||||
invalids.append(etudid)
|
invalids.append(etudid)
|
||||||
invalid = True
|
invalid = True
|
||||||
|
|
||||||
@ -157,7 +154,7 @@ def _check_notes(notes, evaluation, mod):
|
|||||||
try:
|
try:
|
||||||
etudid = int(etudid) #
|
etudid = int(etudid) #
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ScoValueError(f"Code étudiant ({etudid}) invalide")
|
raise ScoValueError(f"Code étudiant ({etudid}) invalide") from exc
|
||||||
if note[:3] == "DEM":
|
if note[:3] == "DEM":
|
||||||
continue # skip !
|
continue # skip !
|
||||||
if note:
|
if note:
|
||||||
@ -174,7 +171,6 @@ def _check_notes(notes, evaluation, mod):
|
|||||||
L.append((etudid, value))
|
L.append((etudid, value))
|
||||||
else:
|
else:
|
||||||
withoutnotes.append(etudid)
|
withoutnotes.append(etudid)
|
||||||
|
|
||||||
return L, invalids, withoutnotes, absents, tosuppress
|
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):
|
def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
|
||||||
"""Initialisation des notes manquantes"""
|
"""Initialisation des notes manquantes"""
|
||||||
E = sco_evaluation_db.do_evaluation_list({"evaluation_id": evaluation_id})[0]
|
# XXX 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 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
|
# Check access
|
||||||
# (admin, respformation, and responsable_id)
|
# (admin, respformation, and responsable_id)
|
||||||
if not sco_permissions_check.can_edit_notes(current_user, E["moduleimpl_id"]):
|
if not sco_permissions_check.can_edit_notes(current_user, modimpl.id):
|
||||||
# XXX imaginer un redirect + msg erreur
|
raise AccessDenied(f"Modification des notes impossible pour {current_user}")
|
||||||
raise AccessDenied("Modification des notes impossible pour %s" % current_user)
|
|
||||||
#
|
#
|
||||||
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id)
|
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id)
|
||||||
etudid_etats = sco_groups.do_evaluation_listeetuds_groups(
|
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
|
if etudid not in notes_db: # pas de note
|
||||||
notes.append((etudid, value))
|
notes.append((etudid, value))
|
||||||
# Check value
|
# Check value
|
||||||
L, invalids, _, _, _ = _check_notes(notes, E, M["module"])
|
L, invalids, _, _, _ = _check_notes(
|
||||||
diag = ""
|
notes, evaluation.to_dict(), modimpl.module.to_dict()
|
||||||
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()
|
|
||||||
)
|
)
|
||||||
|
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
|
# Confirm action
|
||||||
if not dialog_confirmed:
|
if not dialog_confirmed:
|
||||||
return scu.confirm_dialog(
|
return scu.confirm_dialog(
|
||||||
"""<h2>Mettre toutes les notes manquantes de l'évaluation
|
f"""<h2>Mettre toutes les notes manquantes de l'évaluation
|
||||||
à la valeur %s ?</h2>
|
à la valeur {value} ?</h2>
|
||||||
<p>Seuls les étudiants pour lesquels aucune note (ni valeur, ni ABS, ni EXC)
|
<p>Seuls les étudiants pour lesquels aucune note (ni valeur, ni ABS, ni EXC)
|
||||||
n'a été rentrée seront affectés.</p>
|
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>
|
<p class="warning">Attention, les étudiants sans notes de tous les groupes de ce semestre seront affectés.</p>
|
||||||
"""
|
""",
|
||||||
% (value, len(L)),
|
|
||||||
dest_url="",
|
dest_url="",
|
||||||
cancel_url="saisie_notes?evaluation_id=%s" % evaluation_id,
|
cancel_url=dest_url,
|
||||||
parameters={"evaluation_id": evaluation_id, "value": value},
|
parameters={"evaluation_id": evaluation_id, "value": value},
|
||||||
)
|
)
|
||||||
# ok
|
# ok
|
||||||
@ -368,27 +372,23 @@ def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
|
|||||||
url=mod["url"],
|
url=mod["url"],
|
||||||
max_frequency=30 * 60,
|
max_frequency=30 * 60,
|
||||||
)
|
)
|
||||||
return (
|
return f"""
|
||||||
html_sco_header.sco_header()
|
{ html_sco_header.sco_header() }
|
||||||
+ f"""
|
|
||||||
<h2>{nb_changed} notes changées</h2>
|
<h2>{nb_changed} notes changées</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class="stdlink" href="{url_for("notes.saisie_notes",
|
<li><a class="stdlink" href="{dest_url}">
|
||||||
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation_id)
|
|
||||||
}">
|
|
||||||
Revenir au formulaire de saisie des notes</a>
|
Revenir au formulaire de saisie des notes</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="stdlink" href="{
|
<li><a class="stdlink" href="{
|
||||||
url_for(
|
url_for(
|
||||||
"notes.moduleimpl_status",
|
"notes.moduleimpl_status",
|
||||||
scodoc_dept=g.scodoc_dept,
|
scodoc_dept=g.scodoc_dept,
|
||||||
moduleimpl_id=M["moduleimpl_id"],
|
moduleimpl_id=evaluation.moduleimpl_id,
|
||||||
)}">Tableau de bord du module</a>
|
)}">Tableau de bord du module</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{ html_sco_header.sco_footer() }
|
||||||
"""
|
"""
|
||||||
+ html_sco_header.sco_footer()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False):
|
def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False):
|
||||||
|
@ -34,6 +34,7 @@ function valid_note(e) {
|
|||||||
} else {
|
} else {
|
||||||
/* Saisie invalide */
|
/* Saisie invalide */
|
||||||
this.className = "note_invalid";
|
this.className = "note_invalid";
|
||||||
|
sco_message("valeur invalide ou hors barème");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user