ébauche etat_evals ticket #387

This commit is contained in:
leonard_montalbano 2022-05-30 16:08:04 +02:00
parent 248e78a188
commit 2db5e04a59

View File

@ -7,6 +7,8 @@ from app.api import bp
from app.api.auth import token_auth, token_permission_required
from app.models import Departement, FormSemestre, FormSemestreEtape
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
from app.scodoc.sco_evaluation_recap import evaluations_recap_table
from app.scodoc.sco_evaluations import do_evaluation_etat_in_sem, do_evaluation_etat
from app.scodoc.sco_groups import get_etud_groups
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_utils import ModuleType
@ -461,3 +463,60 @@ def formsemestre_etudiants(formsemestre_id: int, etat: str):
etu["groups"] = get_etud_groups(etu["id"], formsemestre_id)
return jsonify(res)
@bp.route("/formsemestre/<int:formsemestre_id>/etat_evals", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def etat_evals(formsemestre_id: int):
"""
Retourne les informations sur l'état des évaluations d'un semestre donnée
formsemestre_id : l'id d'un semestre
Exemple de résultat :
"""
# fonction utilisé : do_evaluation_etat()
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
dept = Departement.query.get(formsemestre.dept_id)
app.set_sco_dept(dept.acronym)
list_ues = formsemestre.query_ues()
moduleimpls = formsemestre.modimpls
res = []
ues = {}
modules = []
for moduleimpl in moduleimpls:
x = {}
module = models.Module.query.filter_by(id=moduleimpl.id).first_or_404()
x["id"] = module.id
x["titre"] = module.titre
list_eval = []
for eval in moduleimpl.evaluations:
list_eval.append(do_evaluation_etat(eval.id))
x["evaluations"] = list_eval
print(list_eval)
modules.append(x)
for ue in list_ues:
ues[ue.acronyme] = modules
# print(ues)
print(
"###############################################################################"
)
# print(modules)
return jsonify(do_evaluation_etat_in_sem(formsemestre_id))