1
0
forked from ScoDoc/ScoDoc

API: modif /formsemestre/resultat: nombres ne chaines, respect JSON sans NaN

This commit is contained in:
Emmanuel Viennet 2022-07-23 08:46:00 +02:00
parent 9bd2290076
commit c3952c1118
2 changed files with 13 additions and 5 deletions

View File

@ -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,

View File

@ -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,