Remplissage notes manquantes par groupes. closes #534
This commit is contained in:
parent
ec632dd43c
commit
18aed44644
@ -321,20 +321,31 @@ def do_evaluation_set_etud_note(evaluation: Evaluation, etud: Identite, value) -
|
||||
return False # error
|
||||
|
||||
|
||||
def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
|
||||
def do_evaluation_set_missing(
|
||||
evaluation_id, value, dialog_confirmed=False, group_ids_str: str = ""
|
||||
):
|
||||
"""Initialisation des notes manquantes"""
|
||||
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, modimpl.id):
|
||||
raise AccessDenied(f"Modification des notes impossible pour {current_user}")
|
||||
#
|
||||
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id)
|
||||
if not group_ids_str:
|
||||
groups = None
|
||||
else:
|
||||
group_ids = [int(x) for x in str(group_ids_str).split(",")]
|
||||
groups = sco_groups.listgroups(group_ids)
|
||||
|
||||
etudid_etats = sco_groups.do_evaluation_listeetuds_groups(
|
||||
evaluation_id, getallstudents=True, include_demdef=False
|
||||
evaluation_id,
|
||||
getallstudents=groups is None,
|
||||
groups=groups,
|
||||
include_demdef=False,
|
||||
)
|
||||
|
||||
notes = []
|
||||
for etudid, _ in etudid_etats: # pour tous les inscrits
|
||||
if etudid not in notes_db: # pas de note
|
||||
@ -360,17 +371,23 @@ def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
|
||||
"""
|
||||
# Confirm action
|
||||
if not dialog_confirmed:
|
||||
plural = len(L) > 1
|
||||
return scu.confirm_dialog(
|
||||
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>{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><b>{len(L)} étudiant{"s" if plural else ""} concerné{"s" if plural else ""}
|
||||
par ce changement de note.</b>
|
||||
</p>
|
||||
""",
|
||||
dest_url="",
|
||||
cancel_url=dest_url,
|
||||
parameters={"evaluation_id": evaluation_id, "value": value},
|
||||
parameters={
|
||||
"evaluation_id": evaluation_id,
|
||||
"value": value,
|
||||
"group_ids_str": group_ids_str,
|
||||
},
|
||||
)
|
||||
# ok
|
||||
comment = "Initialisation notes manquantes"
|
||||
@ -792,7 +809,7 @@ def saisie_notes_tableur(evaluation_id, group_ids=()):
|
||||
H.append(
|
||||
f"""
|
||||
<li>
|
||||
<form action="do_evaluation_set_missing" method="GET">
|
||||
<form action="do_evaluation_set_missing" method="POST">
|
||||
Mettre toutes les notes manquantes à <input type="text" size="5" name="value"/>
|
||||
<input type="submit" value="OK"/>
|
||||
<input type="hidden" name="evaluation_id" value="{evaluation_id}"/>
|
||||
@ -1041,7 +1058,7 @@ def saisie_notes(evaluation_id, group_ids=[]):
|
||||
moduleimpl_id=E["moduleimpl_id"],
|
||||
)
|
||||
|
||||
form = _form_saisie_notes(E, M, groups_infos.group_ids, destination=destination)
|
||||
form = _form_saisie_notes(E, M, groups_infos, destination=destination)
|
||||
if form is None:
|
||||
log(f"redirecting to {destination}")
|
||||
return flask.redirect(destination)
|
||||
@ -1131,7 +1148,7 @@ def _get_sorted_etuds(eval_dict: dict, etudids: list, formsemestre_id: int):
|
||||
return etuds
|
||||
|
||||
|
||||
def _form_saisie_notes(E, M, group_ids, destination=""):
|
||||
def _form_saisie_notes(E, M, groups_infos, destination=""):
|
||||
"""Formulaire HTML saisie des notes dans l'évaluation E du moduleimpl M
|
||||
pour les groupes indiqués.
|
||||
|
||||
@ -1161,7 +1178,10 @@ def _form_saisie_notes(E, M, group_ids, destination=""):
|
||||
descr = [
|
||||
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),
|
||||
("formsemestre_id", {"default": formsemestre_id, "input_type": "hidden"}),
|
||||
("group_ids", {"default": group_ids, "input_type": "hidden", "type": "list"}),
|
||||
(
|
||||
"group_ids",
|
||||
{"default": groups_infos.group_ids, "input_type": "hidden", "type": "list"},
|
||||
),
|
||||
# ('note_method', { 'default' : note_method, 'input_type' : 'hidden'}),
|
||||
("comment", {"size": 44, "title": "Commentaire", "return_focus_next": True}),
|
||||
("changed", {"default": "0", "input_type": "hidden"}), # changed in JS
|
||||
@ -1271,12 +1291,11 @@ def _form_saisie_notes(E, M, group_ids, destination=""):
|
||||
H.append(
|
||||
"""<div class="saisie_warn">
|
||||
<ul class="tf-msg">
|
||||
<li class="tf-msg">Attention: il y a déjà des <b>décisions de jury</b> enregistrées pour %d étudiants. Après changement des notes, vérifiez la situation !</li>
|
||||
<li class="tf-msg">Attention: il y a déjà des <b>décisions de jury</b> enregistrées pour
|
||||
{nb_decisions} étudiants. Après changement des notes, vérifiez la situation !</li>
|
||||
</ul>
|
||||
</div>"""
|
||||
% nb_decisions
|
||||
)
|
||||
# H.append('''<div id="sco_msg" class="head_message"></div>''')
|
||||
|
||||
tf = TF(
|
||||
destination,
|
||||
@ -1299,17 +1318,20 @@ def _form_saisie_notes(E, M, group_ids, destination=""):
|
||||
elif (not tf.submitted()) or not tf.result:
|
||||
# ajout formulaire saisie notes manquantes
|
||||
H.append(
|
||||
"""
|
||||
f"""
|
||||
<div>
|
||||
<form action="do_evaluation_set_missing" method="GET">
|
||||
Mettre <em>toutes</em> les notes manquantes à <input type="text" size="5" name="value"/>
|
||||
<form id="do_evaluation_set_missing" action="do_evaluation_set_missing" method="POST">
|
||||
Mettre les notes manquantes à
|
||||
<input type="text" size="5" name="value"/>
|
||||
<input type="submit" value="OK"/>
|
||||
<input type="hidden" name="evaluation_id" value="%s"/>
|
||||
<em>affecte tous les groupes. ABS indique "absent" (zéro), EXC "excusé" (neutralisées), ATT "attente"</em>
|
||||
<input type="hidden" name="evaluation_id" value="{evaluation_id}"/>
|
||||
<input class="group_ids_str" type="hidden" name="group_ids_str" value="{
|
||||
",".join([str(x) for x in groups_infos.group_ids])
|
||||
}"/>
|
||||
<em>ABS indique "absent" (zéro), EXC "excusé" (neutralisées), ATT "attente"</em>
|
||||
</form>
|
||||
</div>
|
||||
"""
|
||||
% evaluation_id
|
||||
)
|
||||
# affiche formulaire
|
||||
return "\n".join(H)
|
||||
|
@ -99,6 +99,13 @@ function toggle_visible_etuds() {
|
||||
// lien feuille excel:
|
||||
$("#lnk_feuille_saisie").attr("href", "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs);
|
||||
}
|
||||
// Update champs form group_ids_str
|
||||
let group_ids_str = Array.from(
|
||||
document.querySelectorAll("#group_ids_sel option:checked")
|
||||
).map(
|
||||
function (elem) { return elem.value; }
|
||||
).join();
|
||||
document.querySelectorAll("input.group_ids_str").forEach(elem => elem.value = group_ids_str);
|
||||
}
|
||||
|
||||
$().ready(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user