148 lines
5.5 KiB
Python
148 lines
5.5 KiB
Python
|
"""Test calculs moyennes de modules
|
||
|
"""
|
||
|
|
||
|
from config import TestConfig
|
||
|
from tests.unit import sco_fake_gen
|
||
|
|
||
|
from flask import g
|
||
|
|
||
|
import app
|
||
|
from app.scodoc import sco_bulletins
|
||
|
from app.scodoc import sco_cache
|
||
|
from app.scodoc import sco_moduleimpl
|
||
|
from app.scodoc import sco_utils as scu
|
||
|
|
||
|
DEPT = TestConfig.DEPT_TEST
|
||
|
|
||
|
|
||
|
def test_notes_modules(test_client):
|
||
|
"""Test quelques opérations élémentaires de ScoDoc
|
||
|
Création 1 étudiant, formation, semestre, inscription etudiant,
|
||
|
création 1 evaluation, saisie de notes.
|
||
|
Vérifie calcul moyenne avec absences (ABS), excuse (EXC), attente (ATT)
|
||
|
"""
|
||
|
app.set_sco_dept(DEPT)
|
||
|
|
||
|
G = sco_fake_gen.ScoFake(verbose=False)
|
||
|
etuds = [G.create_etud(code_nip=None)] # un seul
|
||
|
|
||
|
f = G.create_formation(acronyme="")
|
||
|
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
||
|
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
||
|
mod = G.create_module(
|
||
|
matiere_id=mat["matiere_id"],
|
||
|
code="TSM1",
|
||
|
coefficient=1.0,
|
||
|
titre="module test",
|
||
|
ue_id=ue["ue_id"],
|
||
|
formation_id=f["formation_id"],
|
||
|
)
|
||
|
|
||
|
# --- Mise place d'un semestre
|
||
|
sem = G.create_formsemestre(
|
||
|
formation_id=f["formation_id"],
|
||
|
semestre_id=1,
|
||
|
date_debut="01/01/2020",
|
||
|
date_fin="30/06/2020",
|
||
|
)
|
||
|
|
||
|
mi = G.create_moduleimpl(
|
||
|
module_id=mod["module_id"],
|
||
|
formsemestre_id=sem["formsemestre_id"],
|
||
|
)
|
||
|
|
||
|
# --- Inscription des étudiants
|
||
|
for etud in etuds:
|
||
|
G.inscrit_etudiant(sem, etud)
|
||
|
etud = etuds[0]
|
||
|
# --- Creation évaluations: e1, e2
|
||
|
coef_1 = 1.0
|
||
|
coef_2 = 2.0
|
||
|
e1 = G.create_evaluation(
|
||
|
moduleimpl_id=mi["moduleimpl_id"],
|
||
|
jour="01/01/2020",
|
||
|
description="evaluation 1",
|
||
|
coefficient=coef_1,
|
||
|
)
|
||
|
e2 = G.create_evaluation(
|
||
|
moduleimpl_id=mi["moduleimpl_id"],
|
||
|
jour="01/01/2020",
|
||
|
description="evaluation 2",
|
||
|
coefficient=coef_2,
|
||
|
)
|
||
|
# --- Notes ordinaires
|
||
|
note_1 = 12.0
|
||
|
note_2 = 13.0
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=note_1)
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=note_2)
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
# Vérifie structure du bulletin:
|
||
|
assert b["etudid"] == etud["etudid"]
|
||
|
assert len(b["ues"][0]["modules"][0]["evaluations"]) == 2
|
||
|
assert len(b["ues"][0]["modules"]) == 1
|
||
|
# Note moyenne:
|
||
|
note_th = (coef_1 * note_1 + coef_2 * note_2) / (coef_1 + coef_2)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(note_th)
|
||
|
|
||
|
# Absence à une évaluation
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=None) # abs
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=note_2)
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
note_th = (coef_1 * 0.0 + coef_2 * note_2) / (coef_1 + coef_2)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(note_th)
|
||
|
# Absences aux deux évaluations
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=None) # abs
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=None) # abs
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(0.0)
|
||
|
# Note excusée EXC <-> scu.NOTES_NEUTRALISE
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=note_1)
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=scu.NOTES_NEUTRALISE) # EXC
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(note_1)
|
||
|
# Note en attente ATT <-> scu.NOTES_ATTENTE
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=note_1)
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=scu.NOTES_ATTENTE) # ATT
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == scu.fmt_note(note_1)
|
||
|
# Neutralisation (EXC) des 2 évals
|
||
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=scu.NOTES_NEUTRALISE) # EXC
|
||
|
_, _, _ = G.create_note(evaluation=e2, etud=etud, note=scu.NOTES_NEUTRALISE) # EXC
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == "-"
|
||
|
# Vérification bas niveau: (peut changer dans le futur !)
|
||
|
nt = sco_cache.NotesTableCache.get(sem["formsemestre_id"])
|
||
|
mod_moy = nt.get_etud_mod_moy(mi["moduleimpl_id"], etud["etudid"])
|
||
|
assert mod_moy == "NA0" # peut changer dans le futur !
|
||
|
# Non inscrit
|
||
|
# - désinscrit notre étudiant:
|
||
|
inscr = sco_moduleimpl.do_moduleimpl_inscription_list(
|
||
|
moduleimpl_id=mi["moduleimpl_id"], etudid=etud["etudid"]
|
||
|
)
|
||
|
assert len(inscr) == 1
|
||
|
oid = inscr[0]["moduleimpl_inscription_id"]
|
||
|
sco_moduleimpl.do_moduleimpl_inscription_delete(
|
||
|
oid, formsemestre_id=mi["formsemestre_id"]
|
||
|
)
|
||
|
# -
|
||
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||
|
sem["formsemestre_id"], etud["etudid"]
|
||
|
)
|
||
|
assert b["ues"] == [] # inscrit à aucune UE !
|
||
|
# Vérification bas niveau: (peut changer dans le futur !)
|
||
|
nt = sco_cache.NotesTableCache.get(sem["formsemestre_id"])
|
||
|
mod_moy = nt.get_etud_mod_moy(mi["moduleimpl_id"], etud["etudid"])
|
||
|
assert mod_moy == "NI" # peut changer dans le futur !
|