From 5bbdc567f348298b2785fd92535a0afcc7c87c9d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 2 Feb 2024 18:45:58 +0100 Subject: [PATCH] retrait API + fix --- app/api/formsemestres.py | 189 +++++++++++++++-------------- app/comp/res_common.py | 4 +- sco_version.py | 2 +- tests/api/test_api_formsemestre.py | 5 +- 4 files changed, 103 insertions(+), 97 deletions(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 662ddd4dc..28837aca1 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -374,114 +374,115 @@ def formsemestre_etudiants( return sorted(etuds, key=itemgetter("sort_key")) -@bp.route("/formsemestre//etat_evals") -@api_web_bp.route("/formsemestre//etat_evals") -@login_required -@scodoc -@permission_required(Permission.ScoView) -@as_json -def etat_evals(formsemestre_id: int): - """ - Informations sur l'état des évaluations d'un formsemestre. +# retrait (temporaire ? à discuter) +# @bp.route("/formsemestre//etat_evals") +# @api_web_bp.route("/formsemestre//etat_evals") +# @login_required +# @scodoc +# @permission_required(Permission.ScoView) +# @as_json +# def etat_evals(formsemestre_id: int): +# """ +# 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 : - [ - { - "id": 1, // moduleimpl_id - "titre": "Initiation aux réseaux informatiques", - "evaluations": [ - { - "id": 1, - "description": null, - "datetime_epreuve": null, - "heure_fin": "09:00:00", - "coefficient": "02.00" - "is_complete": true, - "nb_inscrits": 16, - "nb_manquantes": 0, - "ABS": 0, - "ATT": 0, - "EXC": 0, - "saisie_notes": { - "datetime_debut": "2021-09-11T00:00:00+02:00", - "datetime_fin": "2022-08-25T00:00:00+02:00", - "datetime_mediane": "2022-03-19T00:00:00+01:00" - } - }, - ... - ] - }, - ] - """ - query = FormSemestre.query.filter_by(id=formsemestre_id) - if g.scodoc_dept: - query = query.filter_by(dept_id=g.scodoc_dept_id) - formsemestre: FormSemestre = query.first_or_404(formsemestre_id) - app.set_sco_dept(formsemestre.departement.acronym) - nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) +# Exemple de résultat : +# [ +# { +# "id": 1, // moduleimpl_id +# "titre": "Initiation aux réseaux informatiques", +# "evaluations": [ +# { +# "id": 1, +# "description": null, +# "datetime_epreuve": null, +# "heure_fin": "09:00:00", +# "coefficient": "02.00" +# "is_complete": true, +# "nb_inscrits": 16, +# "nb_manquantes": 0, +# "ABS": 0, +# "ATT": 0, +# "EXC": 0, +# "saisie_notes": { +# "datetime_debut": "2021-09-11T00:00:00+02:00", +# "datetime_fin": "2022-08-25T00:00:00+02:00", +# "datetime_mediane": "2022-03-19T00:00:00+01:00" +# } +# }, +# ... +# ] +# }, +# ] +# """ +# query = FormSemestre.query.filter_by(id=formsemestre_id) +# if g.scodoc_dept: +# query = query.filter_by(dept_id=g.scodoc_dept_id) +# formsemestre: FormSemestre = query.first_or_404(formsemestre_id) +# app.set_sco_dept(formsemestre.departement.acronym) +# nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) - result = [] - for modimpl_id in nt.modimpls_results: - modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id] - modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id) - modimpl_dict = modimpl.to_dict(convert_objects=True) +# result = [] +# for modimpl_id in nt.modimpls_results: +# modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id] +# modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id) +# modimpl_dict = modimpl.to_dict(convert_objects=True) - list_eval = [] - for evaluation_id in modimpl_results.evaluations_etat: - eval_etat = modimpl_results.evaluations_etat[evaluation_id] - evaluation = Evaluation.query.get_or_404(evaluation_id) - eval_dict = evaluation.to_dict_api() - eval_dict["etat"] = eval_etat.to_dict() +# list_eval = [] +# for evaluation_id in modimpl_results.evaluations_etat: +# eval_etat = modimpl_results.evaluations_etat[evaluation_id] +# evaluation = Evaluation.query.get_or_404(evaluation_id) +# eval_dict = evaluation.to_dict_api() +# eval_dict["etat"] = eval_etat.to_dict() - eval_dict["nb_inscrits"] = modimpl_results.nb_inscrits_module - eval_dict["nb_notes_manquantes"] = len( - modimpl_results.evals_etudids_sans_note[evaluation.id] - ) - eval_dict["nb_notes_abs"] = sum( - modimpl_results.evals_notes[evaluation.id] == scu.NOTES_ABSENCE - ) - eval_dict["nb_notes_att"] = eval_etat.nb_attente - eval_dict["nb_notes_exc"] = sum( - modimpl_results.evals_notes[evaluation.id] == scu.NOTES_NEUTRALISE - ) +# eval_dict["nb_inscrits"] = modimpl_results.nb_inscrits_module +# eval_dict["nb_notes_manquantes"] = len( +# modimpl_results.evals_etudids_sans_note[evaluation.id] +# ) +# eval_dict["nb_notes_abs"] = sum( +# modimpl_results.evals_notes[evaluation.id] == scu.NOTES_ABSENCE +# ) +# eval_dict["nb_notes_att"] = eval_etat.nb_attente +# eval_dict["nb_notes_exc"] = sum( +# modimpl_results.evals_notes[evaluation.id] == scu.NOTES_NEUTRALISE +# ) - # Récupération de toutes les notes de l'évaluation - # eval["notes"] = modimpl_results.get_eval_notes_dict(evaluation_id) +# # Récupération de toutes les notes de l'évaluation +# # 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_fin = None - date_mediane = None +# date_debut = None +# date_fin = None +# date_mediane = None - # Si il y a plus d'une note saisie pour l'évaluation - if len(notes) >= 1: - # Tri des notes en fonction de leurs dates - notes_sorted = sorted(notes, key=attrgetter("date")) +# # Si il y a plus d'une note saisie pour l'évaluation +# if len(notes) >= 1: +# # Tri des notes en fonction de leurs dates +# notes_sorted = sorted(notes, key=attrgetter("date")) - date_debut = notes_sorted[0].date - date_fin = notes_sorted[-1].date +# date_debut = notes_sorted[0].date +# date_fin = notes_sorted[-1].date - # Note médiane - date_mediane = notes_sorted[len(notes_sorted) // 2].date +# # Note médiane +# date_mediane = notes_sorted[len(notes_sorted) // 2].date - eval_dict["saisie_notes"] = { - "datetime_debut": date_debut.isoformat() - if date_debut is not None - else None, - "datetime_fin": date_fin.isoformat() if date_fin is not None else None, - "datetime_mediane": date_mediane.isoformat() - if date_mediane is not None - else None, - } +# eval_dict["saisie_notes"] = { +# "datetime_debut": date_debut.isoformat() +# if date_debut is not None +# else None, +# "datetime_fin": date_fin.isoformat() if date_fin is not None else None, +# "datetime_mediane": date_mediane.isoformat() +# if date_mediane is not None +# else None, +# } - list_eval.append(eval_dict) +# list_eval.append(eval_dict) - modimpl_dict["evaluations"] = list_eval - result.append(modimpl_dict) - return result +# modimpl_dict["evaluations"] = list_eval +# result.append(modimpl_dict) +# return result @bp.route("/formsemestre//resultats") diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 9553381b3..c4bc908ff 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -209,6 +209,7 @@ class ResultatsSemestre(ResultatsCache): "last_modif" : datetime.datetime | None, # saisie de note la plus récente "nb_notes" : int, # nb notes d'étudiants inscrits }, + "evaluatiuon_id" : int, "jour" : datetime.datetime, # e.date_debut or datetime.datetime(1900, 1, 1) "publish_incomplete" : bool, } @@ -231,13 +232,14 @@ class ResultatsSemestre(ResultatsCache): return { "coefficient": evaluation.coefficient or 0.0, "description": evaluation.description or "", + "evaluation_id": evaluation.id, "jour": evaluation.date_debut or datetime.datetime(1900, 1, 1), - "publish_incomplete": evaluation.publish_incomplete, "etat": { "evalcomplete": etat.is_complete, "nb_notes": etat.nb_notes, "last_modif": last_modif, }, + "publish_incomplete": evaluation.publish_incomplete, } def get_mod_evaluation_etat_list(self, modimpl: ModuleImpl) -> list[dict]: diff --git a/sco_version.py b/sco_version.py index 5f1bebf2b..c079c96dc 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.91" +SCOVERSION = "9.6.92" SCONAME = "ScoDoc" diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index f02842dd7..23b0f4990 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -20,6 +20,8 @@ import json import requests from types import NoneType +import pytest + from app.scodoc import sco_utils as scu from tests.api.setup_test_api import ( @@ -617,7 +619,8 @@ def test_formsemestre_programme(api_headers): 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//etat_evals """