From f69ce75b1f8ff13c0b9060014edc8a5e2e40ce27 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 2 Oct 2022 20:15:56 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20pr=C3=A9f=C3=A9rence=20pour=20emp?= =?UTF-8?q?=C3=AAcher=20l'=C3=A9dition=20des=20poids=20des=20=C3=A9valuati?= =?UTF-8?q?ons.=20Closes=20#389?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_evaluation_edit.py | 51 ++++++++++++++++--------------- app/scodoc/sco_preferences.py | 16 +++++++++- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index b4b6ba38b..440f1db19 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -43,13 +43,14 @@ from app.models.formsemestre import FormSemestre from app.models.moduleimpls import ModuleImpl import app.scodoc.sco_utils as scu from app.scodoc.sco_utils import ModuleType -from app.scodoc.sco_exceptions import AccessDenied, ScoValueError +from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc import html_sco_header from app.scodoc import sco_evaluations from app.scodoc import sco_evaluation_db from app.scodoc import sco_moduleimpl from app.scodoc import sco_permissions_check +from app.scodoc import sco_preferences def evaluation_create_form( @@ -70,24 +71,25 @@ def evaluation_create_form( ] mod = modimpl_o["module"] formsemestre_id = modimpl_o["formsemestre_id"] - sem = FormSemestre.query.get(formsemestre_id) - sem_ues = sem.query_ues(with_sport=False).all() + formsemestre = FormSemestre.query.get(formsemestre_id) + sem_ues = formsemestre.query_ues(with_sport=False).all() is_malus = mod["module_type"] == ModuleType.MALUS is_apc = mod["module_type"] in (ModuleType.RESSOURCE, ModuleType.SAE) - + preferences = sco_preferences.SemPreferences(formsemestre.id) + can_edit_poids = not preferences["but_disable_edit_poids_evaluations"] min_note_max = scu.NOTES_PRECISION # le plus petit bareme possible # if not sco_permissions_check.can_edit_evaluation(moduleimpl_id=moduleimpl_id): - return ( - html_sco_header.sco_header() - + "

Opération non autorisée

" - + "Modification évaluation impossible pour %s" - % current_user.get_nomplogin() - + "

" - + '

Revenir

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

Opération non autorisée

+

Modification évaluation impossible pour {current_user.get_nomplogin()}

+

Revenir +

+ {html_sco_header.sco_footer()} + """ if not edit: # création nouvel if moduleimpl_id is None: @@ -122,19 +124,16 @@ def evaluation_create_form( else: min_note_max_str = "0" # - mod_descr = '%s %s %s' % ( - moduleimpl_id, - mod["code"] or "module sans code", - mod["titre"], - link, - ) H = [ f"""

{action} en - {scu.MODULE_TYPE_NAMES[mod["module_type"]]} {mod_descr}

+ {scu.MODULE_TYPE_NAMES[mod["module_type"]]} {mod["code"] or "module sans code"} {mod["titre"]} {link} """ ] - heures = ["%02dh%02d" % (h, m) for h in range(8, 19) for m in (0, 30)] + heures = [f"{h:02d}h{m:02d}" for h in range(8, 19) for m in (0, 30)] # initvalues["visibulletin"] = initvalues.get("visibulletin", True) if initvalues["visibulletin"]: @@ -296,14 +295,18 @@ def evaluation_create_form( "size": 2, "type": "float", "explanation": f""" - ({"coef. mod.:" +str(coef_ue) if coef_ue else "ce module n'a pas de coef. dans cette UE"}) + ({ + "coef. mod.:" +str(coef_ue) if coef_ue + else "ce module n'a pas de coef. dans cette UE" + }) {ue.titre} """, "allow_null": False, # ok si poids nul ou coef vers l'UE nul: "validator": lambda val, field: (not val) or ue_coef_dict.get(int(field[len("poids_") :]), 0.0) != 0, - "enabled": coef_ue != 0 or initvalues[f"poids_{ue.id}"] != 0.0, + "enabled": (coef_ue != 0 or initvalues[f"poids_{ue.id}"] != 0.0) + and can_edit_poids, }, ), ) diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index a06ffb978..4e5a8a2f0 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -204,6 +204,7 @@ PREF_CATEGORIES = ( # sur page "Paramètres" ("general", {}), ("misc", {"title": "Divers"}), + ("apc", {"title": "BUT et Approches par Compétences"}), ("abs", {"title": "Suivi des absences", "related": ("bul",)}), ("portal", {"title": "Liaison avec portail (Apogée, etc)"}), ( @@ -371,6 +372,7 @@ class BasePreferences(object): "only_global": False, }, ), + # ------------------ APC / BUT ( "but_moy_skip_empty_ues", { @@ -380,7 +382,19 @@ class BasePreferences(object): Si cette option est cochée, ne prend pas en compte les UEs sans notes. Attention: changer ce réglage va modifier toutes les moyennes du semestre !. Aucun effet dans les formations non BUT.""", "input_type": "boolcheckbox", - "category": "misc", + "category": "apc", + "labels": ["non", "oui"], + "only_global": False, + }, + ), + ( + "but_disable_edit_poids_evaluations", + { + "initvalue": 0, + "title": "Interdire de modifier les poids des évaluations", + "explanation": """empêche la modification des poids des évaluations""", + "input_type": "boolcheckbox", + "category": "apc", "labels": ["non", "oui"], "only_global": False, },