2021-07-02 12:34:44 +02:00
|
|
|
import sco_formations
|
|
|
|
import json
|
|
|
|
import random
|
2021-07-29 16:31:15 +02:00
|
|
|
|
2021-07-02 12:34:44 +02:00
|
|
|
# La variable context est définie par le script de lancement
|
|
|
|
# l'affecte ainsi pour évietr les warnins pylint:
|
|
|
|
context = context # pylint: disable=undefined-variable
|
|
|
|
REQUEST = REQUEST # pylint: disable=undefined-variable
|
|
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
|
|
import sco_moduleimpl
|
|
|
|
import sco_groups_view
|
|
|
|
import sco_abs_views
|
|
|
|
|
|
|
|
G = sco_fake_gen.ScoFake(context.Notes)
|
|
|
|
G.verbose = False
|
|
|
|
|
|
|
|
file = open("scotests/export_formation1.xml")
|
|
|
|
doc = file.read()
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
# --- Création de la formation
|
|
|
|
|
2021-08-01 10:16:16 +02:00
|
|
|
f = sco_formations.formation_import_xml(doc=doc, context=context.Notes)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
# --- Création des semestres
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
sem1 = G.create_formsemestre(
|
|
|
|
formation_id=f[0],
|
|
|
|
semestre_id=1,
|
|
|
|
date_debut="01/09/2020",
|
|
|
|
date_fin="01/02/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
sem3 = G.create_formsemestre(
|
|
|
|
formation_id=f[0],
|
|
|
|
semestre_id=3,
|
|
|
|
date_debut="01/09/2020",
|
|
|
|
date_fin="01/02/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
sem2 = G.create_formsemestre(
|
|
|
|
formation_id=f[0],
|
|
|
|
semestre_id=2,
|
|
|
|
date_debut="02/02/2021",
|
|
|
|
date_fin="01/06/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
sem4 = G.create_formsemestre(
|
|
|
|
formation_id=f[0],
|
|
|
|
semestre_id=4,
|
|
|
|
date_debut="02/02/2021",
|
|
|
|
date_fin="01/06/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# --- Implémentation des modules
|
|
|
|
|
|
|
|
li_module = context.Notes.do_module_list()
|
|
|
|
mods_imp = []
|
2021-07-29 16:31:15 +02:00
|
|
|
for mod in li_module:
|
|
|
|
if mod["semestre_id"] == 1:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem1["formsemestre_id"]
|
2021-07-29 16:31:15 +02:00
|
|
|
elif mod["semestre_id"] == 2:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem2["formsemestre_id"]
|
2021-07-29 16:31:15 +02:00
|
|
|
elif mod["semestre_id"] == 3:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem3["formsemestre_id"]
|
2021-07-29 16:31:15 +02:00
|
|
|
else:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem4["formsemestre_id"]
|
|
|
|
|
|
|
|
mi = G.create_moduleimpl(
|
2021-07-29 16:31:15 +02:00
|
|
|
module_id=mod["module_id"],
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
responsable_id="bach",
|
2021-07-02 12:34:44 +02:00
|
|
|
)
|
|
|
|
mods_imp.append(mi)
|
|
|
|
|
|
|
|
# --- Création des étudiants
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
etuds = []
|
2021-07-02 12:34:44 +02:00
|
|
|
for nom, prenom in [
|
|
|
|
("Semestre11", "EtudiantNumero1"),
|
|
|
|
("Semestre12", "EtudiantNumero2"),
|
|
|
|
("Semestre23", "EtudiantNumero3"),
|
|
|
|
("Semestre24", "EtudiantNumero4"),
|
|
|
|
("Semestre35", "EtudiantNumero5"),
|
|
|
|
("Semestre36", "EtudiantNumero6"),
|
|
|
|
("Semestre47", "EtudiantNumero7"),
|
2021-07-29 16:31:15 +02:00
|
|
|
("Semestre48", "EtudiantNumero8"),
|
|
|
|
]:
|
2021-07-02 12:34:44 +02:00
|
|
|
etud = G.create_etud(
|
|
|
|
nom=nom,
|
|
|
|
prenom=prenom,
|
|
|
|
)
|
|
|
|
etuds.append(etud)
|
|
|
|
|
|
|
|
# --- Inscription des étudiants
|
|
|
|
|
|
|
|
for etud in etuds[0:2]:
|
|
|
|
G.inscrit_etudiant(sem1, etud)
|
|
|
|
|
|
|
|
for etud in etuds[2:4]:
|
|
|
|
G.inscrit_etudiant(sem2, etud)
|
|
|
|
|
|
|
|
for etud in etuds[4:6]:
|
|
|
|
G.inscrit_etudiant(sem3, etud)
|
|
|
|
|
|
|
|
for etud in etuds[6:]:
|
|
|
|
G.inscrit_etudiant(sem4, etud)
|
|
|
|
|
|
|
|
# --- Création d'une évaluation pour chaque UE
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
lim_sem1 = sco_moduleimpl.do_moduleimpl_list(
|
|
|
|
context.Notes, formsemestre_id=sem1["formsemestre_id"], REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_lim_sem1 = json.loads(lim_sem1)
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
lim_sem2 = sco_moduleimpl.do_moduleimpl_list(
|
|
|
|
context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_lim_sem2 = json.loads(lim_sem2)
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
lim_sem3 = sco_moduleimpl.do_moduleimpl_list(
|
|
|
|
context.Notes, formsemestre_id=sem3["formsemestre_id"], REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_lim_sem3 = json.loads(lim_sem3)
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
lim_sem4 = sco_moduleimpl.do_moduleimpl_list(
|
|
|
|
context.Notes, formsemestre_id=sem4["formsemestre_id"], REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_lim_sem4 = json.loads(lim_sem4)
|
|
|
|
|
|
|
|
|
|
|
|
for moduleimpl_id, jour, description, coefficient in [
|
|
|
|
(load_lim_sem1[1]["moduleimpl_id"], "02/09/2020", "InterroTestSemestre1", 1.0),
|
|
|
|
(load_lim_sem1[2]["moduleimpl_id"], "03/09/2020", "InterroTestSemestre1", 1.0),
|
|
|
|
(load_lim_sem2[1]["moduleimpl_id"], "03/02/2021", "InterroTestSemestre2", 1.0),
|
|
|
|
(load_lim_sem2[8]["moduleimpl_id"], "04/02/2021", "InterroTestSemestre2", 1.0),
|
|
|
|
(load_lim_sem3[3]["moduleimpl_id"], "02/09/2020", "InterroTestSemestre3", 1.0),
|
|
|
|
(load_lim_sem3[9]["moduleimpl_id"], "03/09/2020", "InterroTestSemestre3", 1.0),
|
|
|
|
(load_lim_sem3[15]["moduleimpl_id"], "04/09/2020", "InterroTestSemestre3", 1.0),
|
|
|
|
(load_lim_sem4[3]["moduleimpl_id"], "03/02/2021", "InterroTestSemestre4", 1.0),
|
|
|
|
(load_lim_sem4[9]["moduleimpl_id"], "04/02/2021", "InterroTestSemestre4", 1.0),
|
|
|
|
(load_lim_sem4[13]["moduleimpl_id"], "05/02/2021", "InterroTestSemestre4", 1.0),
|
2021-07-29 16:31:15 +02:00
|
|
|
]:
|
|
|
|
e = G.create_evaluation(
|
|
|
|
moduleimpl_id=moduleimpl_id,
|
|
|
|
jour=jour,
|
|
|
|
description=description,
|
|
|
|
coefficient=coefficient,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- Saisie des notes des étudiants (un élève a 12, un autre a 7 pour chaque semestre)
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
lie1 = context.Notes.do_evaluation_list_in_formsemestre(
|
|
|
|
formsemestre_id=sem1["formsemestre_id"]
|
|
|
|
)
|
|
|
|
lie2 = context.Notes.do_evaluation_list_in_formsemestre(
|
|
|
|
formsemestre_id=sem2["formsemestre_id"]
|
|
|
|
)
|
|
|
|
lie3 = context.Notes.do_evaluation_list_in_formsemestre(
|
|
|
|
formsemestre_id=sem3["formsemestre_id"]
|
|
|
|
)
|
|
|
|
lie4 = context.Notes.do_evaluation_list_in_formsemestre(
|
|
|
|
formsemestre_id=sem4["formsemestre_id"]
|
|
|
|
)
|
|
|
|
|
|
|
|
for eval in lie1:
|
|
|
|
for etud in etuds[:2]:
|
|
|
|
if etud == etuds[0]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=12.0
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=7.0
|
|
|
|
)
|
|
|
|
|
|
|
|
for eval in lie2:
|
|
|
|
for etud in etuds[2:4]:
|
|
|
|
if etud == etuds[2]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=12.0
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=7.0
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for eval in lie3:
|
|
|
|
for etud in etuds[4:6]:
|
|
|
|
if etud == etuds[4]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=12.0
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=7.0
|
|
|
|
)
|
|
|
|
|
|
|
|
for eval in lie4:
|
|
|
|
for etud in etuds[6:]:
|
|
|
|
if etud == etuds[6]:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=12.0
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=7.0
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
# --- Département
|
|
|
|
|
|
|
|
li_dep = context.ScoDoc.list_depts(format="json", REQUEST=REQUEST)
|
|
|
|
print(li_dep)
|
|
|
|
|
|
|
|
# --- Formation
|
|
|
|
|
|
|
|
lif = context.Notes.formation_list(format="json", REQUEST=REQUEST, formation_id=f[0])
|
|
|
|
load_lif = json.loads(lif)
|
|
|
|
assert len(load_lif) == 1
|
|
|
|
assert load_lif[0]["formation_id"] == f[0]
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
exp = sco_formations.formation_export(
|
|
|
|
context.Notes, formation_id=f[0], format="json", REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_exp = json.loads(exp)
|
|
|
|
assert load_exp["acronyme"] == "DUT Info"
|
|
|
|
assert load_exp["titre_officiel"] == "DUT Informatique"
|
|
|
|
assert load_exp["formation_code"] == "FCOD2"
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
# --- Semestre
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
li_sem = context.Notes.formsemestre_list(
|
|
|
|
formation_id=f[0], format="json", REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_li_sem = json.loads(li_sem)
|
|
|
|
assert len(load_li_sem) == 4
|
|
|
|
|
|
|
|
# --- Création des groupes
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
_ = sco_groups.partition_create(
|
|
|
|
context.Scolarite,
|
|
|
|
formsemestre_id=sem1["formsemestre_id"],
|
|
|
|
partition_name="Eleve 1ere annee",
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
li1 = sco_groups.get_partitions_list(context.Scolarite, sem1["formsemestre_id"])
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
_ = sco_groups.createGroup(context.Scolarite, li1[0]["partition_id"], "Groupe S1A")
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
li_grp1 = sco_groups.get_partition_groups(context.Scolarite, li1[0])
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
for etud in etuds[0:2]:
|
2021-07-02 12:34:44 +02:00
|
|
|
sco_groups.set_group(context.Scolarite, etud["etudid"], li_grp1[0]["group_id"])
|
|
|
|
|
|
|
|
|
|
|
|
# --- Groupes
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
li_part = sco_groups.formsemestre_partition_list(
|
|
|
|
context.Scolarite,
|
|
|
|
formsemestre_id=sem1["formsemestre_id"],
|
|
|
|
format="json",
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_li_part = json.loads(li_part)
|
2021-07-29 16:31:15 +02:00
|
|
|
assert len(load_li_part) == 2 # 2 partition (defaut et eleve 1ere annee)
|
2021-07-02 12:34:44 +02:00
|
|
|
assert load_li_part[0]["formsemestre_id"] == sem1["formsemestre_id"]
|
2021-07-29 16:31:15 +02:00
|
|
|
assert len(load_li_part[0]["group"]) == 1 # 2 groupes S1A
|
2021-07-02 12:34:44 +02:00
|
|
|
assert load_li_part[0]["group"][0]["group_name"] == "Groupe S1A"
|
|
|
|
assert load_li_part[0]["group"][0]["group_id"] == li_grp1[0]["group_id"]
|
2021-07-29 16:31:15 +02:00
|
|
|
assert (
|
|
|
|
load_li_part[0]["partition_id"]
|
|
|
|
== load_li_part[0]["group"][0]["partition_id"]
|
|
|
|
== li1[0]["partition_id"]
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
assert load_li_part[0]["partition_name"] == "Eleve 1ere annee"
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
vue_g1 = sco_groups_view.groups_view(
|
|
|
|
context.Scolarite,
|
|
|
|
group_ids=[li_grp1[0]["group_id"]],
|
|
|
|
format="json",
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_vue_g1 = json.loads(vue_g1)
|
|
|
|
assert len(load_vue_g1) == 2
|
|
|
|
assert load_vue_g1[0][li1[0]["partition_id"]] == li_grp1[0]["group_name"]
|
|
|
|
|
|
|
|
|
|
|
|
# --- Etudiant
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
etudi = context.Scolarite.etud_info(
|
|
|
|
etudid=etuds[0]["etudid"], format="json", REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_etudi = json.loads(etudi)
|
|
|
|
assert load_etudi["prenom"] == "Etudiantnumero1"
|
|
|
|
assert load_etudi["nom"] == "SEMESTRE11"
|
|
|
|
assert load_etudi["etudid"] == etuds[0]["etudid"]
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
# --- Absences
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
for debut, fin, demijournee in [
|
|
|
|
("18/01/2021", "18/01/2021", 1),
|
|
|
|
("19/01/2021", "19/01/2021", 0),
|
2021-07-29 16:31:15 +02:00
|
|
|
]:
|
|
|
|
sco_abs_views.doSignaleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
datedebut=debut,
|
|
|
|
datefin=fin,
|
|
|
|
demijournee=demijournee,
|
|
|
|
etudid=etuds[0]["etudid"],
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
nb_abs = context.Absences.CountAbs(
|
|
|
|
etuds[0]["etudid"], debut="09/01/2020", fin="02/01/2021"
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
assert nb_abs == 2
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
liste_abs = sco_abs_views.ListeAbsEtud(
|
|
|
|
context.Absences, etuds[0]["etudid"], format="json", REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_liste_abs = json.loads(liste_abs)
|
|
|
|
assert len(load_liste_abs) == 2
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
_ = sco_abs_views.doAnnuleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"15/01/2021",
|
|
|
|
"15/01/2021",
|
|
|
|
1,
|
|
|
|
etudid=etuds[0]["etudid"],
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
# --- Module
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
# Voir test dans test_formation.
|