retrait API + fix

This commit is contained in:
Emmanuel Viennet 2024-02-02 18:45:58 +01:00
parent 027f11e494
commit 5bbdc567f3
4 changed files with 103 additions and 97 deletions

View File

@ -374,114 +374,115 @@ def formsemestre_etudiants(
return sorted(etuds, key=itemgetter("sort_key")) return sorted(etuds, key=itemgetter("sort_key"))
@bp.route("/formsemestre/<int:formsemestre_id>/etat_evals") # retrait (temporaire ? à discuter)
@api_web_bp.route("/formsemestre/<int:formsemestre_id>/etat_evals") # @bp.route("/formsemestre/<int:formsemestre_id>/etat_evals")
@login_required # @api_web_bp.route("/formsemestre/<int:formsemestre_id>/etat_evals")
@scodoc # @login_required
@permission_required(Permission.ScoView) # @scodoc
@as_json # @permission_required(Permission.ScoView)
def etat_evals(formsemestre_id: int): # @as_json
""" # def etat_evals(formsemestre_id: int):
Informations sur l'état des évaluations d'un formsemestre. # """
# Informations sur l'état des évaluations d'un formsemestre.
formsemestre_id : l'id d'un semestre # formsemestre_id : l'id d'un semestre
Exemple de résultat : # Exemple de résultat :
[ # [
{ # {
"id": 1, // moduleimpl_id # "id": 1, // moduleimpl_id
"titre": "Initiation aux réseaux informatiques", # "titre": "Initiation aux réseaux informatiques",
"evaluations": [ # "evaluations": [
{ # {
"id": 1, # "id": 1,
"description": null, # "description": null,
"datetime_epreuve": null, # "datetime_epreuve": null,
"heure_fin": "09:00:00", # "heure_fin": "09:00:00",
"coefficient": "02.00" # "coefficient": "02.00"
"is_complete": true, # "is_complete": true,
"nb_inscrits": 16, # "nb_inscrits": 16,
"nb_manquantes": 0, # "nb_manquantes": 0,
"ABS": 0, # "ABS": 0,
"ATT": 0, # "ATT": 0,
"EXC": 0, # "EXC": 0,
"saisie_notes": { # "saisie_notes": {
"datetime_debut": "2021-09-11T00:00:00+02:00", # "datetime_debut": "2021-09-11T00:00:00+02:00",
"datetime_fin": "2022-08-25T00:00:00+02:00", # "datetime_fin": "2022-08-25T00:00:00+02:00",
"datetime_mediane": "2022-03-19T00:00:00+01:00" # "datetime_mediane": "2022-03-19T00:00:00+01:00"
} # }
}, # },
... # ...
] # ]
}, # },
] # ]
""" # """
query = FormSemestre.query.filter_by(id=formsemestre_id) # query = FormSemestre.query.filter_by(id=formsemestre_id)
if g.scodoc_dept: # if g.scodoc_dept:
query = query.filter_by(dept_id=g.scodoc_dept_id) # query = query.filter_by(dept_id=g.scodoc_dept_id)
formsemestre: FormSemestre = query.first_or_404(formsemestre_id) # formsemestre: FormSemestre = query.first_or_404(formsemestre_id)
app.set_sco_dept(formsemestre.departement.acronym) # app.set_sco_dept(formsemestre.departement.acronym)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) # nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
result = [] # result = []
for modimpl_id in nt.modimpls_results: # for modimpl_id in nt.modimpls_results:
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id] # modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id]
modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id) # modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id)
modimpl_dict = modimpl.to_dict(convert_objects=True) # modimpl_dict = modimpl.to_dict(convert_objects=True)
list_eval = [] # list_eval = []
for evaluation_id in modimpl_results.evaluations_etat: # for evaluation_id in modimpl_results.evaluations_etat:
eval_etat = modimpl_results.evaluations_etat[evaluation_id] # eval_etat = modimpl_results.evaluations_etat[evaluation_id]
evaluation = Evaluation.query.get_or_404(evaluation_id) # evaluation = Evaluation.query.get_or_404(evaluation_id)
eval_dict = evaluation.to_dict_api() # eval_dict = evaluation.to_dict_api()
eval_dict["etat"] = eval_etat.to_dict() # eval_dict["etat"] = eval_etat.to_dict()
eval_dict["nb_inscrits"] = modimpl_results.nb_inscrits_module # eval_dict["nb_inscrits"] = modimpl_results.nb_inscrits_module
eval_dict["nb_notes_manquantes"] = len( # eval_dict["nb_notes_manquantes"] = len(
modimpl_results.evals_etudids_sans_note[evaluation.id] # modimpl_results.evals_etudids_sans_note[evaluation.id]
) # )
eval_dict["nb_notes_abs"] = sum( # eval_dict["nb_notes_abs"] = sum(
modimpl_results.evals_notes[evaluation.id] == scu.NOTES_ABSENCE # modimpl_results.evals_notes[evaluation.id] == scu.NOTES_ABSENCE
) # )
eval_dict["nb_notes_att"] = eval_etat.nb_attente # eval_dict["nb_notes_att"] = eval_etat.nb_attente
eval_dict["nb_notes_exc"] = sum( # eval_dict["nb_notes_exc"] = sum(
modimpl_results.evals_notes[evaluation.id] == scu.NOTES_NEUTRALISE # modimpl_results.evals_notes[evaluation.id] == scu.NOTES_NEUTRALISE
) # )
# Récupération de toutes les notes de l'évaluation # # Récupération de toutes les notes de l'évaluation
# eval["notes"] = modimpl_results.get_eval_notes_dict(evaluation_id) # # eval["notes"] = modimpl_results.get_eval_notes_dict(evaluation_id)
notes = NotesNotes.query.filter_by(evaluation_id=evaluation.id).all() # notes = NotesNotes.query.filter_by(evaluation_id=evaluation.id).all()
date_debut = None # date_debut = None
date_fin = None # date_fin = None
date_mediane = None # date_mediane = None
# Si il y a plus d'une note saisie pour l'évaluation # # Si il y a plus d'une note saisie pour l'évaluation
if len(notes) >= 1: # if len(notes) >= 1:
# Tri des notes en fonction de leurs dates # # Tri des notes en fonction de leurs dates
notes_sorted = sorted(notes, key=attrgetter("date")) # notes_sorted = sorted(notes, key=attrgetter("date"))
date_debut = notes_sorted[0].date # date_debut = notes_sorted[0].date
date_fin = notes_sorted[-1].date # date_fin = notes_sorted[-1].date
# Note médiane # # Note médiane
date_mediane = notes_sorted[len(notes_sorted) // 2].date # date_mediane = notes_sorted[len(notes_sorted) // 2].date
eval_dict["saisie_notes"] = { # eval_dict["saisie_notes"] = {
"datetime_debut": date_debut.isoformat() # "datetime_debut": date_debut.isoformat()
if date_debut is not None # if date_debut is not None
else None, # else None,
"datetime_fin": date_fin.isoformat() if date_fin is not None else None, # "datetime_fin": date_fin.isoformat() if date_fin is not None else None,
"datetime_mediane": date_mediane.isoformat() # "datetime_mediane": date_mediane.isoformat()
if date_mediane is not None # if date_mediane is not None
else None, # else None,
} # }
list_eval.append(eval_dict) # list_eval.append(eval_dict)
modimpl_dict["evaluations"] = list_eval # modimpl_dict["evaluations"] = list_eval
result.append(modimpl_dict) # result.append(modimpl_dict)
return result # return result
@bp.route("/formsemestre/<int:formsemestre_id>/resultats") @bp.route("/formsemestre/<int:formsemestre_id>/resultats")

View File

@ -209,6 +209,7 @@ class ResultatsSemestre(ResultatsCache):
"last_modif" : datetime.datetime | None, # saisie de note la plus récente "last_modif" : datetime.datetime | None, # saisie de note la plus récente
"nb_notes" : int, # nb notes d'étudiants inscrits "nb_notes" : int, # nb notes d'étudiants inscrits
}, },
"evaluatiuon_id" : int,
"jour" : datetime.datetime, # e.date_debut or datetime.datetime(1900, 1, 1) "jour" : datetime.datetime, # e.date_debut or datetime.datetime(1900, 1, 1)
"publish_incomplete" : bool, "publish_incomplete" : bool,
} }
@ -231,13 +232,14 @@ class ResultatsSemestre(ResultatsCache):
return { return {
"coefficient": evaluation.coefficient or 0.0, "coefficient": evaluation.coefficient or 0.0,
"description": evaluation.description or "", "description": evaluation.description or "",
"evaluation_id": evaluation.id,
"jour": evaluation.date_debut or datetime.datetime(1900, 1, 1), "jour": evaluation.date_debut or datetime.datetime(1900, 1, 1),
"publish_incomplete": evaluation.publish_incomplete,
"etat": { "etat": {
"evalcomplete": etat.is_complete, "evalcomplete": etat.is_complete,
"nb_notes": etat.nb_notes, "nb_notes": etat.nb_notes,
"last_modif": last_modif, "last_modif": last_modif,
}, },
"publish_incomplete": evaluation.publish_incomplete,
} }
def get_mod_evaluation_etat_list(self, modimpl: ModuleImpl) -> list[dict]: def get_mod_evaluation_etat_list(self, modimpl: ModuleImpl) -> list[dict]:

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.6.91" SCOVERSION = "9.6.92"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"

View File

@ -20,6 +20,8 @@ import json
import requests import requests
from types import NoneType from types import NoneType
import pytest
from app.scodoc import sco_utils as scu from app.scodoc import sco_utils as scu
from tests.api.setup_test_api import ( from tests.api.setup_test_api import (
@ -617,7 +619,8 @@ def test_formsemestre_programme(api_headers):
assert verify_fields(sae, MODIMPL_FIELDS) assert verify_fields(sae, MODIMPL_FIELDS)
def test_etat_evals(api_headers): @pytest.mark.skip # XXX WIP
def test_etat_evals(api_headers): # voir si on maintient cette route ?
""" """
Route : /formsemestre/<int:formsemestre_id>/etat_evals Route : /formsemestre/<int:formsemestre_id>/etat_evals
""" """