2021-07-02 12:34:44 +02:00
|
|
|
import sco_formations
|
|
|
|
import json
|
|
|
|
import random
|
2021-08-01 10:16:16 +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
|
|
|
|
|
|
|
|
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-20 01:09:55 +02:00
|
|
|
f = sco_formations.formation_import_xml(doc=doc)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +02:00
|
|
|
elif mod["semestre_id"] == 2:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem2["formsemestre_id"]
|
2021-08-01 10:16:16 +02:00
|
|
|
elif mod["semestre_id"] == 3:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem3["formsemestre_id"]
|
2021-08-01 10:16:16 +02:00
|
|
|
else:
|
2021-07-02 12:34:44 +02:00
|
|
|
formsemestre_id = sem4["formsemestre_id"]
|
|
|
|
|
|
|
|
mi = G.create_moduleimpl(
|
2021-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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-08-01 10:16:16 +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
|
|
|
|
)
|