From 8ae4e8619c2da3abd172a2aaf859dc0ff9cb140a Mon Sep 17 00:00:00 2001 From: Maxime Blot <maxime.blot.etu@univ-lille.fr> Date: Fri, 14 Feb 2025 11:52:17 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20du=20boutton=20des=20=C3=A9valuations?= =?UTF-8?q?=20du=20semestre=20(pas=20de=20fonctionnalit=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_evaluations.py | 109 +++++++++++++++++++++++++++++++++ app/scodoc/sco_saisie_notes.py | 1 + 2 files changed, 110 insertions(+) diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 9c5fad6d..6d00c241 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -514,6 +514,115 @@ def formsemestre_evaluations_cal(formsemestre_id): ) +######################################################################## +######################################################################## +######################################################################## + + +def form_eval_choice( + groups_infos, + with_selectall_butt=False, + with_deselect_butt=False, + submit_on_change=False, + default_deselect_others=False, + args: dict | None = None, + title="Evaluations additionnelles :", +): + """ + """ + default_group_id = sco_groups.get_default_group(groups_infos.formsemestre_id) + args = args or {} + args_wdg = "\n".join( + [ + f"""<input type="hidden" name="{k}" value="{v}"/>""" + for k, v in args.items() + if k not in ("formsemestre_id", "group_ids") + ] + ) + H = [ + f""" + <form id="group_selector" method="get"> + <input type="hidden" name="formsemestre_id" id="formsemestre_id" + value="{groups_infos.formsemestre_id}"/> + <input type="hidden" name="default_group_id" id="default_group_id" + value="{default_group_id}"/> + {args_wdg} + {title} + { + menu_evals_choice( + groups_infos, + submit_on_change=submit_on_change, + default_deselect_others=default_deselect_others, + ) + } + """ + ] + if with_selectall_butt: + H.append( + """<input type="button" value="sélectionner tous" onmousedown="select_groupe_tous();"/>""" + ) + if with_deselect_butt: + H.append( + """<input type="button" value="ne pas filtrer" onmousedown="remove_group_filter();"/>""" + ) + H.append("</form>") + + return "\n".join(H) + +def menu_evals_choice( + groups_infos, + submit_on_change=False, + default_deselect_others=True, +): + """ + """ + default_group_id = sco_groups.get_default_group(groups_infos.formsemestre_id) + n_members = len(sco_groups.get_group_members(default_group_id)) + + values: dict = { + # Choix : Tous (tous les groupes) + "": [ + { + "value": default_group_id, + "label": f"Tous ({n_members})", + "selected": default_group_id in groups_infos.group_ids, + "single": default_deselect_others, + } + ] + } + + for partition in groups_infos.partitions: + p_name: str = partition["partition_name"] + vals: list[tuple[str, str, bool]] = [] + # Les groupes dans cette partition: + for grp in sco_groups.get_partition_groups(partition): ############################################ + selected: bool = grp["group_id"] in groups_infos.group_ids + if grp["group_name"]: + vals.append( + { + "value": grp["group_id"], + "label": f"{grp['group_name']} ({len(sco_groups.get_group_members(grp['group_id']))})", + "selected": selected, + } + ) + + values[p_name] = vals + + multi_select: scu.MultiSelect = scu.MultiSelect( + values=values, name="group_ids", html_id="group_ids_sel" + ) + + if submit_on_change: + multi_select.change_event("submit_group_selector();") + + return multi_select.html() + + +######################################################################## +######################################################################## +######################################################################## + + def evaluation_date_first_completion(evaluation_id) -> datetime.datetime: """Première date à laquelle l'évaluation a été complète ou None si actuellement incomplète diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index cb13fccd..2aa562d1 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -678,6 +678,7 @@ def saisie_notes(evaluation: Evaluation, group_ids: list[int] | tuple[int] = ()) '<div id="saisie_notes"><span class="eval_title">Saisie des notes</span>', ] H.append("""<div id="group-tabs"><table><tr><td>""") + H.append(sco_evaluations.form_eval_choice(groups_infos, submit_on_change=True)) H.append(sco_groups_view.form_groups_choice(groups_infos, submit_on_change=True)) H.append('</td><td style="padding-left: 35px;">') H.append( -- GitLab