Fix: association à une nouvelle version de programme: rattachement des poids

This commit is contained in:
Emmanuel Viennet 2021-12-12 16:24:50 +01:00
parent d6ebb55b95
commit 567d95b61d

View File

@ -30,8 +30,10 @@
import flask import flask
from flask import url_for, g, request from flask import url_for, g, request
from flask_login import current_user from flask_login import current_user
from app.auth.models import User
from app import db
from app.auth.models import User
from app.models import ModuleImpl, Evaluation, EvaluationUEPoids
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc import sco_cache from app.scodoc import sco_cache
@ -1197,6 +1199,17 @@ def _reassociate_moduleimpls(cnx, formsemestre_id, ues_old2new, modules_old2new)
for mod in modimpls: for mod in modimpls:
mod["module_id"] = modules_old2new[mod["module_id"]] mod["module_id"] = modules_old2new[mod["module_id"]]
sco_moduleimpl.do_moduleimpl_edit(mod, formsemestre_id=formsemestre_id) sco_moduleimpl.do_moduleimpl_edit(mod, formsemestre_id=formsemestre_id)
# Update poids des évaluations
# les poids associent les évaluations aux UE (qui ont changé d'id)
for poids in EvaluationUEPoids.query.filter(
EvaluationUEPoids.evaluation_id == Evaluation.id,
Evaluation.moduleimpl_id == ModuleImpl.id,
ModuleImpl.formsemestre_id == formsemestre_id,
):
poids.ue_id = ues_old2new[poids.ue_id]
db.session.add(poids)
db.session.commit()
# update decisions: # update decisions:
events = sco_etud.scolar_events_list(cnx, args={"formsemestre_id": formsemestre_id}) events = sco_etud.scolar_events_list(cnx, args={"formsemestre_id": formsemestre_id})
for e in events: for e in events: