diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 2f5efbc4..5b41941c 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -139,6 +139,7 @@ def evaluation_create_form( initvalues["visibulletinlist"] = ["X"] else: initvalues["visibulletinlist"] = [] + initvalues["coefficient"] = initvalues.get("coefficient", 1.0) vals = scu.get_request_args() if vals.get("tf_submitted", False) and "visibulletinlist" not in vals: vals["visibulletinlist"] = [] @@ -158,7 +159,7 @@ def evaluation_create_form( else: coef_ue = ue_coef_dict.get(ue.id, 0.0) or 0.0 if coef_ue > 0: - poids = 1.0 # par defaut au départ + poids = 1.0 # par défaut au départ else: poids = 0.0 initvalues[f"poids_{ue.id}"] = poids @@ -284,6 +285,7 @@ def evaluation_create_form( ] # Liste des UE utilisées dans des modules de ce semestre: for ue in sem_ues: + coef_ue = ue_coef_dict.get(ue.id, 0.0) form.append( ( f"poids_{ue.id}", @@ -292,10 +294,14 @@ def evaluation_create_form( "size": 2, "type": "float", "explanation": f""" - {ue_coef_dict.get(ue.id, 0.)} + ({"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, }, ), ) @@ -331,7 +337,7 @@ def evaluation_create_form( if edit: sco_evaluation_db.do_evaluation_edit(tf[2]) else: - # creation d'une evaluation + # création d'une evaluation evaluation_id = sco_evaluation_db.do_evaluation_create(**tf[2]) if is_apc: # Set poids