From c3952c111830110f47adca21ebda054ad74a2f2e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 23 Jul 2022 08:46:00 +0200 Subject: [PATCH] API: modif /formsemestre/resultat: nombres ne chaines, respect JSON sans NaN --- app/api/formsemestres.py | 10 ++++++++-- scodoc.py | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 2f25b28c90..2e455166e7 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -13,6 +13,7 @@ import app from app import models from app.api import bp from app.api.auth import permission_required_api +from app.api.errors import error_response from app.comp import res_sem from app.comp.moy_mod import ModuleImplResults from app.comp.res_compat import NotesTableCompat @@ -336,7 +337,7 @@ def etat_evals(formsemestre_id: int): # Si il y a plus d'une note saisie pour l'évaluation if len(notes) >= 1: - # Trie des notes en fonction de leurs dates + # Tri des notes en fonction de leurs dates notes_sorted = sorted(notes, key=lambda note: note.date) date_debut = notes_sorted[0].date @@ -369,11 +370,16 @@ def formsemestre_resultat(formsemestre_id: int): """Tableau récapitulatif des résultats Pour chaque étudiant, son état, ses groupes, ses moyennes d'UE et de modules. """ + format_spec = request.args.get("format", None) + if format_spec is not None and format_spec != "raw": + return error_response(404, "invalid format specification") + convert_values = format_spec != "raw" + formsemestre = FormSemestre.query.get_or_404(formsemestre_id) app.set_sco_dept(formsemestre.departement.acronym) res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) rows, footer_rows, titles, column_ids = res.get_table_recap( - convert_values=False, + convert_values=convert_values, include_evaluations=False, mode_jury=False, allow_html=False, diff --git a/scodoc.py b/scodoc.py index f488347e88..0b7f353139 100755 --- a/scodoc.py +++ b/scodoc.py @@ -45,11 +45,12 @@ cli.register(app) @app.shell_context_processor def make_shell_context(): - from app.scodoc import notesdb as ndb - from app.scodoc import sco_utils as scu - import app as mapp # le package app import numpy as np import pandas as pd + import app as mapp # le package app + from app.scodoc import notesdb as ndb + from app.comp import res_sem + from app.scodoc import sco_utils as scu return { "ctx": app.test_request_context(), @@ -77,6 +78,7 @@ def make_shell_context(): "Permission": Permission, "pp": pp, "Role": Role, + "res_sem": res_sem, "scolar": scolar, "ScolarNews": models.ScolarNews, "scu": scu,