forked from ScoDoc/ScoDoc
Compare commits
2 Commits
832a25f7dc
...
f04265c78e
Author | SHA1 | Date | |
---|---|---|---|
|
f04265c78e | ||
|
36bfd9ecad |
@ -583,7 +583,7 @@ def etat_evals(formsemestre_id: int):
|
||||
).all()
|
||||
|
||||
# Si il y a plus d'une note saisie pour l'évaluation
|
||||
if len(notes) > 1:
|
||||
if len(notes) >= 1:
|
||||
# Trie des notes en fonction de leurs dates
|
||||
notes_sorted = sorted(notes, key=lambda note: note.date)
|
||||
|
||||
@ -592,7 +592,11 @@ def etat_evals(formsemestre_id: int):
|
||||
|
||||
# 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)
|
||||
|
||||
# Ici si la longueur est paire on prend, on prend le +1 car un indice ne peux pas avoir de nombre floatant
|
||||
id_mediane = list_id_notes_sorted[
|
||||
int((len(list_id_notes_sorted)) / 2)
|
||||
]
|
||||
|
||||
date_mediane = ""
|
||||
for n in notes_sorted:
|
||||
|
@ -40,15 +40,3 @@ def get_last_instance_etud_from_etudid_or_nip_or_ine(
|
||||
|
||||
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)]
|
||||
|
@ -131,3 +131,41 @@ def test_formsemestre_programme(api_headers):
|
||||
assert verify_fields(modules[0], MODIMPL_FIELDS)
|
||||
assert verify_fields(ressource, MODIMPL_FIELDS)
|
||||
assert verify_fields(sae, MODIMPL_FIELDS)
|
||||
|
||||
|
||||
# def test_formsemestre_etudiants(api_headers):
|
||||
# """
|
||||
# Route: /formsemestre/<int:formsemestre_id>/etudiants, /formsemestre/<int:formsemestre_id>/etudiants/demissionnaires, /formsemestre/<int:formsemestre_id>/etudiants/defaillants
|
||||
# """
|
||||
# r = requests.get(
|
||||
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants",
|
||||
# headers=api_headers,
|
||||
# verify=CHECK_CERTIFICATE,
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
#
|
||||
# r = requests.get(
|
||||
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
|
||||
# headers=api_headers,
|
||||
# verify=CHECK_CERTIFICATE,
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
#
|
||||
# r = requests.get(
|
||||
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
|
||||
# headers=api_headers,
|
||||
# verify=CHECK_CERTIFICATE,
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
|
||||
|
||||
def test_etat_evals(api_headers):
|
||||
"""
|
||||
Route : /formsemestre/<int:formsemestre_id>/etat_evals
|
||||
"""
|
||||
r = requests.get(
|
||||
API_URL + "/formsemestre/1/etat_evals",
|
||||
headers=api_headers,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
|
@ -28,7 +28,7 @@ import sys
|
||||
|
||||
from app.auth.models import Role, User
|
||||
from app import models
|
||||
from app.models import Departement, Formation, FormSemestre, Identite
|
||||
from app.models import Departement, Formation, FormSemestre, Identite, ModuleImpl
|
||||
from app import db
|
||||
from app.scodoc import (
|
||||
sco_cache,
|
||||
@ -38,6 +38,7 @@ from app.scodoc import (
|
||||
sco_groups,
|
||||
)
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_saisie_notes import notes_add
|
||||
from tools.fakeportal.gen_nomprenoms import nomprenom
|
||||
|
||||
random.seed(12345678) # tests reproductibles
|
||||
@ -188,6 +189,29 @@ def create_evaluations(formsemestre: FormSemestre):
|
||||
evaluation_id = sco_evaluation_db.do_evaluation_create(**args)
|
||||
|
||||
|
||||
def saisie_note_evaluations(formsemestre: FormSemestre, user: User):
|
||||
"""
|
||||
Saisie les notes des evaluations d'un semestre
|
||||
"""
|
||||
# Récupération des id des étudiants du semestre
|
||||
list_etudids = [etud.id for etud in formsemestre.etuds]
|
||||
list_ues = formsemestre.query_ues()
|
||||
|
||||
def create_list_etudid_random_notes():
|
||||
"""
|
||||
Retourne une liste de tuple (etudid, note_random)
|
||||
"""
|
||||
return [(etudid, random.uniform(0.0, 20.0)) for etudid in list_etudids]
|
||||
|
||||
for ue in list_ues:
|
||||
mods = ue.modules
|
||||
for mod in mods:
|
||||
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
|
||||
for evaluation in moduleimpl.evaluations:
|
||||
notes = create_list_etudid_random_notes()
|
||||
notes_add(user, evaluation.id, notes)
|
||||
|
||||
|
||||
def init_test_database():
|
||||
"""Appelé par la commande `flask init-test-database`
|
||||
|
||||
@ -201,6 +225,7 @@ def init_test_database():
|
||||
formsemestre = create_formsemestre(formation, user_lecteur)
|
||||
create_evaluations(formsemestre)
|
||||
inscrit_etudiants(etuds, formsemestre)
|
||||
saisie_note_evaluations(formsemestre, user_lecteur)
|
||||
# à compléter
|
||||
# - groupes
|
||||
# - absences
|
||||
|
Loading…
Reference in New Issue
Block a user