forked from ScoDoc/ScoDoc
route etat_evals fini, reste à faire tests unitaires
This commit is contained in:
parent
73fd6bfde5
commit
95fc21fd5a
@ -1,14 +1,18 @@
|
|||||||
########################################## Formsemestres ##############################################################
|
########################################## Formsemestres ##############################################################
|
||||||
|
import statistics
|
||||||
|
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app import models
|
from app import models
|
||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.auth import token_auth, token_permission_required
|
from app.api.auth import token_auth, token_permission_required
|
||||||
|
from app.api.tools import calculate_median
|
||||||
from app.comp import res_sem
|
from app.comp import res_sem
|
||||||
from app.comp.moy_mod import ModuleImplResults
|
from app.comp.moy_mod import ModuleImplResults
|
||||||
from app.comp.res_compat import NotesTableCompat
|
from app.comp.res_compat import NotesTableCompat
|
||||||
from app.models import Departement, FormSemestre, FormSemestreEtape, Module, ModuleImpl
|
from app.models import Departement, FormSemestre, FormSemestreEtape, Module, ModuleImpl
|
||||||
|
from app.scodoc import sco_evaluation_db
|
||||||
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
|
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_evaluation_recap import evaluations_recap_table
|
||||||
from app.scodoc.sco_evaluations import do_evaluation_etat_in_sem, do_evaluation_etat
|
from app.scodoc.sco_evaluations import do_evaluation_etat_in_sem, do_evaluation_etat
|
||||||
@ -481,12 +485,14 @@ def etat_evals(formsemestre_id: int):
|
|||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
# Récupération du semestre
|
||||||
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
|
|
||||||
|
# Set du dept
|
||||||
dept = Departement.query.get(formsemestre.dept_id)
|
dept = Departement.query.get(formsemestre.dept_id)
|
||||||
|
|
||||||
app.set_sco_dept(dept.acronym)
|
app.set_sco_dept(dept.acronym)
|
||||||
|
|
||||||
|
# Récupération des Ues
|
||||||
list_ues = formsemestre.query_ues()
|
list_ues = formsemestre.query_ues()
|
||||||
|
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
@ -527,10 +533,37 @@ def etat_evals(formsemestre_id: int):
|
|||||||
eval["EXC"] = sum(
|
eval["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
|
||||||
|
notes = models.NotesNotes.query.filter_by(
|
||||||
|
evaluation_id=evaluation.id
|
||||||
|
).all()
|
||||||
|
|
||||||
|
# Si il y a plus d'une note saisie pour l'évaluation
|
||||||
|
if len(notes) > 1:
|
||||||
|
# Trie des notes en fonction de leurs dates
|
||||||
|
notes_sorted = sorted(notes, key=lambda note: note.date)
|
||||||
|
|
||||||
|
date_debut = notes_sorted[0].date
|
||||||
|
date_fin = notes_sorted[-1].date
|
||||||
|
|
||||||
|
# Récupération de l'id de la note médiane
|
||||||
|
list_id_notes_sorted = [note.id for note in notes_sorted]
|
||||||
|
id_mediane = calculate_median(list_id_notes_sorted)
|
||||||
|
|
||||||
|
date_mediane = ""
|
||||||
|
for n in notes_sorted:
|
||||||
|
if n.id == id_mediane:
|
||||||
|
date_mediane = n.date
|
||||||
|
else:
|
||||||
|
date_debut = None
|
||||||
|
date_fin = None
|
||||||
|
date_mediane = None
|
||||||
|
|
||||||
eval["saisie_notes"] = {
|
eval["saisie_notes"] = {
|
||||||
"datetime_debut": "",
|
"datetime_debut": date_debut,
|
||||||
"datetime_fin": "",
|
"datetime_fin": date_fin,
|
||||||
"datetime_mediane": "",
|
"datetime_mediane": date_mediane,
|
||||||
}
|
}
|
||||||
|
|
||||||
list_eval.append(eval)
|
list_eval.append(eval)
|
||||||
|
@ -39,3 +39,16 @@ def get_last_instance_etud_from_etudid_or_nip_or_ine(
|
|||||||
etud = query.first()
|
etud = query.first()
|
||||||
|
|
||||||
return etud
|
return etud
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_median_list_notes(list):
|
||||||
|
"""
|
||||||
|
Retourne la mediane d'une liste de notes
|
||||||
|
list : une liste préalablement sorted de préférence
|
||||||
|
"""
|
||||||
|
list_len = len(list)
|
||||||
|
if list_len < 1:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Ici si la longueur est paire on prend, on prend le +1 car un indice ne peux pas avoir de nombre floatant
|
||||||
|
return list[int((list_len) / 2)]
|
||||||
|
Loading…
Reference in New Issue
Block a user