2020-12-29 18:53:03 +01:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Test notes bonus/malus
|
|
|
|
|
|
|
|
Création 10 étudiants, puis formation en 4 semestre.
|
|
|
|
Le premier étudiant redouble sa deuxième année.
|
|
|
|
|
|
|
|
Utiliser comme:
|
|
|
|
scotests/scointeractive.sh -r TEST00 scotests/test_bonusmalus.py
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
|
|
import sco_utils as scu
|
2021-01-17 22:31:28 +01:00
|
|
|
import sco_moduleimpl
|
2020-12-29 18:53:03 +01:00
|
|
|
|
|
|
|
G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable
|
|
|
|
G.verbose = False
|
|
|
|
|
|
|
|
# --- Création d'étudiants
|
|
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
|
|
|
|
# --- Mise en place formation 1 semestre
|
|
|
|
f, ue_list, mod_list = G.setup_formation(nb_semestre=1)
|
|
|
|
|
|
|
|
# --- Ajoute module malus à la premiere matiere de la première UE
|
|
|
|
mod_malus = G.create_module(
|
|
|
|
titre="MALUS",
|
|
|
|
code="MAL",
|
|
|
|
coefficient=10,
|
|
|
|
ue_id=ue_list[0]["ue_id"],
|
|
|
|
matiere_id=mod_list[0]["matiere_id"],
|
|
|
|
formation_id=f["formation_id"],
|
|
|
|
semestre_id=1,
|
|
|
|
module_type=scu.MODULE_MALUS,
|
|
|
|
)
|
|
|
|
mod_list.append(mod_malus)
|
|
|
|
|
|
|
|
# --- Crée le semestre
|
|
|
|
|
|
|
|
semestre_id, date_debut, date_fin = (1, "01/09/2019", "15/01/2020")
|
|
|
|
sem, eval_list = G.setup_formsemestre(
|
|
|
|
f, mod_list, semestre_id=semestre_id, date_debut=date_debut, date_fin=date_fin
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Recupère le module de malus
|
2021-01-17 22:31:28 +01:00
|
|
|
modimpls = sco_moduleimpl.do_moduleimpl_list(
|
|
|
|
context, # pylint: disable=undefined-variable
|
|
|
|
formsemestre_id=sem["formsemestre_id"],
|
|
|
|
)
|
2020-12-29 18:53:03 +01:00
|
|
|
# de façon tout à fait inefficace ;-)
|
|
|
|
moduleimpl_malus = [m for m in modimpls if m["module_id"] == mod_malus["module_id"]][0]
|
|
|
|
# et l'évaluation de malus, de la même façon:
|
|
|
|
eval_malus = [
|
|
|
|
e for e in eval_list if e["moduleimpl_id"] == moduleimpl_malus["moduleimpl_id"]
|
|
|
|
][0]
|
|
|
|
eval_normales = [
|
|
|
|
e for e in eval_list if e["moduleimpl_id"] != moduleimpl_malus["moduleimpl_id"]
|
|
|
|
]
|
|
|
|
|
|
|
|
# --- Affect des malus entre -10 et +10
|
|
|
|
n = len(etuds)
|
|
|
|
malus = [((x / (n - 1.0)) * 20) - 10 for x in range(n)]
|
|
|
|
for etud, note in zip(etuds, malus):
|
|
|
|
G.create_note(evaluation=e, etud=etud, note=note)
|
|
|
|
|
|
|
|
# --- Inscrit les étudiants et affecte des notes aléatoires aux évaluations normales
|
|
|
|
for etud in etuds:
|
|
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
G.set_etud_notes_sem(sem, eval_normales, etuds)
|