1
0
forked from ScoDoc/ScoDoc

initialisation poids formulaire prenant en compte les coefs module

This commit is contained in:
Emmanuel Viennet 2021-12-08 23:42:19 +01:00
parent 857c3007a5
commit ab1898b185

View File

@ -40,6 +40,7 @@ from app import db
from app import log
from app import models
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
@ -62,9 +63,11 @@ def evaluation_create_form(
evaluation = models.Evaluation.query.get(evaluation_id)
moduleimpl_id = evaluation.moduleimpl_id
#
modimpl = sco_moduleimpl.moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
mod = modimpl["module"]
formsemestre_id = modimpl["formsemestre_id"]
modimpl_o = sco_moduleimpl.moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[
0
]
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()
is_malus = mod["module_type"] == ModuleType.MALUS
@ -141,6 +144,7 @@ def evaluation_create_form(
vals["visibulletinlist"] = []
#
if is_apc: # BUT: poids vers les UE
ue_coef_dict = ModuleImpl.query.get(moduleimpl_id).module.get_ue_coef_dict()
for ue in sem_ues:
if edit:
existing_poids = models.EvaluationUEPoids.query.filter_by(
@ -151,7 +155,11 @@ def evaluation_create_form(
if existing_poids:
poids = existing_poids.poids
else:
poids = 1.0 # par defaut au départ
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
else:
poids = 0.0
initvalues[f"poids_{ue.id}"] = poids
#
form = [
@ -297,7 +305,7 @@ def evaluation_create_form(
readonly=False,
)
dest_url = "moduleimpl_status?moduleimpl_id=%s" % modimpl["moduleimpl_id"]
dest_url = "moduleimpl_status?moduleimpl_id=%s" % modimpl_o["moduleimpl_id"]
if tf[0] == 0:
head = html_sco_header.sco_header(page_title=page_title)
return (