Clonage semestre avec poids des évaluation. Closes #221

This commit is contained in:
Emmanuel Viennet 2021-12-16 22:54:24 +01:00
parent 40b31602d2
commit 78c7c1a763
3 changed files with 29 additions and 27 deletions

View File

@ -56,24 +56,25 @@ class Evaluation(db.Model):
e["numero"] = ndb.int_null_is_zero(e["numero"]) e["numero"] = ndb.int_null_is_zero(e["numero"])
return sco_evaluation_db.evaluation_enrich_dict(e) return sco_evaluation_db.evaluation_enrich_dict(e)
# def from_dict(self, data): def from_dict(self, data):
# """Set evaluation attributes from given dict values.""" """Set evaluation attributes from given dict values."""
# sco_evaluation_db._check_evaluation_args(data) sco_evaluation_db._check_evaluation_args(data)
# for field in [ for k in self.__dict__.keys():
# "moduleimpl_id", if k != "_sa_instance_state" and k != "id" and k in data:
# "jour", setattr(self, k, data[k])
# "heure_debut",
# "heure_fin", def clone(self, not_copying=()):
# "description", """Clone, not copying the given attrs
# "note_max", Attention: la copie n'a pas d'id avant le prochain commit
# "coefficient", """
# "visibulletin", d = dict(self.__dict__)
# "publish_incomplete", d.pop("id") # get rid of id
# "evaluation_type", d.pop("_sa_instance_state") # get rid of SQLAlchemy special attr
# "numero", for k in not_copying:
# ]: d.pop(k)
# if field in data: copy = self.__class__(**d)
# setattr(self, field, data[field] or None) db.session.add(copy)
return copy
def set_ue_poids(self, ue, poids: float): def set_ue_poids(self, ue, poids: float):
"""Set poids évaluation vers cette UE""" """Set poids évaluation vers cette UE"""

View File

@ -1033,14 +1033,15 @@ def do_formsemestre_clone(
sco_moduleimpl.do_ens_create(args) sco_moduleimpl.do_ens_create(args)
# optionally, copy evaluations # optionally, copy evaluations
if clone_evaluations: if clone_evaluations:
evals = sco_evaluation_db.do_evaluation_list( for e in Evaluation.query.filter_by(
args={"moduleimpl_id": mod_orig["moduleimpl_id"]} moduleimpl_id=mod_orig["moduleimpl_id"]
) ):
for e in evals: # copie en enlevant la date
args = e.copy() new_eval = e.clone(not_copying=("jour", "moduleimpl_id"))
del args["jour"] # erase date new_eval.moduleimpl_id = mid
args["moduleimpl_id"] = mid # Copie les poids APC de l'évaluation
_ = sco_evaluation_db.do_evaluation_create(**args) new_eval.set_ue_poids_dict(e.get_ue_poids_dict())
db.session.commit()
# 3- copy uecoefs # 3- copy uecoefs
objs = sco_formsemestre.formsemestre_uecoef_list( objs = sco_formsemestre.formsemestre_uecoef_list(

View File

@ -45,7 +45,7 @@ import flask
from flask import g, request from flask import g, request
from flask import url_for, make_response from flask import url_for, make_response
from app.models import Partition from app.models.groups import Partition
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
from app import log, cache from app import log, cache