2021-07-03 23:35:32 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# XXX A REVOIR POUR SCODOC8
|
|
|
|
|
2021-07-02 12:34:44 +02:00
|
|
|
import random
|
2021-07-03 23:35:32 +02:00
|
|
|
from app import db
|
|
|
|
from app.auth.models import User
|
|
|
|
from app.auth.models import Role
|
|
|
|
|
|
|
|
DEPT = "TEST"
|
|
|
|
|
2021-07-02 12:34:44 +02:00
|
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
|
|
|
|
|
|
G = sco_fake_gen.ScoFake(context.Notes)
|
|
|
|
G.verbose = False
|
|
|
|
|
|
|
|
# --- Création d'étudiants
|
|
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
|
2021-07-03 23:35:32 +02:00
|
|
|
# --- Création de l'utilisateur responsable du semestre, des modules etc....
|
|
|
|
user = User(user_name="unutil")
|
|
|
|
user.set_password("scodocpass")
|
|
|
|
user.add_role(Role.get_named_role("Ens"), DEPT)
|
|
|
|
db.session.add(u)
|
|
|
|
db.session.commit()
|
2021-07-02 12:34:44 +02:00
|
|
|
print(user)
|
|
|
|
|
|
|
|
# --- Création formation et de deux UE
|
|
|
|
f = G.create_formation(acronyme="")
|
|
|
|
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
|
|
|
mat11 = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
|
|
|
mod11 = G.create_module(
|
|
|
|
matiere_id=mat11["matiere_id"],
|
|
|
|
code="TSM11",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test11",
|
|
|
|
ue_id=ue["ue_id"], # faiblesse de l'API
|
|
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
|
|
)
|
|
|
|
|
|
|
|
mat12 = G.create_matiere(ue_id=ue["ue_id"], titre="matière test12")
|
|
|
|
mod12 = G.create_module(
|
|
|
|
matiere_id=mat12["matiere_id"],
|
|
|
|
code="TSM12",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test12",
|
|
|
|
ue_id=ue["ue_id"], # faiblesse de l'API
|
|
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
ue2 = G.create_ue(formation_id=f["formation_id"], acronyme="TST2", titre="ue test2")
|
|
|
|
mat21 = G.create_matiere(ue_id=ue2["ue_id"], titre="matière test21")
|
|
|
|
mod21 = G.create_module(
|
|
|
|
matiere_id=mat21["matiere_id"],
|
|
|
|
code="TSM21",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test21",
|
|
|
|
ue_id=ue2["ue_id"], # faiblesse de l'API
|
|
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
|
|
)
|
|
|
|
|
|
|
|
mat22 = G.create_matiere(ue_id=ue2["ue_id"], titre="matière test22")
|
|
|
|
mod22 = G.create_module(
|
|
|
|
matiere_id=mat22["matiere_id"],
|
|
|
|
code="TSM22",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test22",
|
|
|
|
ue_id=ue2["ue_id"], # faiblesse de l'API
|
|
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Mise place d'un semestre
|
|
|
|
sem = G.create_formsemestre(
|
|
|
|
formation_id=f["formation_id"],
|
|
|
|
semestre_id=1,
|
|
|
|
date_debut="01/01/2021",
|
|
|
|
date_fin="30/06/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
mods = []
|
|
|
|
for module_id, formsemestre_id, responsable_id in [
|
|
|
|
(mod11["module_id"], sem["formsemestre_id"], "bach"),
|
|
|
|
(mod12["module_id"], sem["formsemestre_id"], "bach"),
|
|
|
|
(mod21["module_id"], sem["formsemestre_id"], "bach"),
|
2021-07-03 23:35:32 +02:00
|
|
|
(mod22["module_id"], sem["formsemestre_id"], "bach"),
|
|
|
|
]:
|
|
|
|
mi = G.create_moduleimpl(
|
|
|
|
module_id=module_id,
|
|
|
|
formsemestre_id=formsemestre_id,
|
|
|
|
responsable_id=responsable_id,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
mods.append(mi)
|
|
|
|
|
|
|
|
|
|
|
|
# --- Inscription des étudiants
|
|
|
|
for etud in etuds:
|
|
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
|
|
|
|
|
|
|
|
# --- Création d'évaluations (2 par modules)
|
|
|
|
|
2021-07-03 23:35:32 +02:00
|
|
|
evals = []
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
for moduleimpl_id, jour, description, coefficient in [
|
|
|
|
(mods[0]["moduleimpl_id"], "01/02/2021", "e1", 1.0),
|
|
|
|
(mods[0]["moduleimpl_id"], "02/02/2021", "e2", 1.0),
|
|
|
|
(mods[1]["moduleimpl_id"], "03/02/2021", "e3", 1.0),
|
|
|
|
(mods[1]["moduleimpl_id"], "04/02/2021", "e4", 1.0),
|
|
|
|
(mods[2]["moduleimpl_id"], "05/02/2021", "e5", 1.0),
|
|
|
|
(mods[2]["moduleimpl_id"], "06/02/2021", "e6", 1.0),
|
|
|
|
(mods[3]["moduleimpl_id"], "07/02/2021", "e7", 1.0),
|
|
|
|
(mods[3]["moduleimpl_id"], "08/02/2021", "e8", 1.0),
|
2021-07-03 23:35:32 +02:00
|
|
|
]:
|
|
|
|
e = G.create_evaluation(
|
|
|
|
moduleimpl_id=moduleimpl_id,
|
|
|
|
jour=jour,
|
|
|
|
description=description,
|
|
|
|
coefficient=coefficient,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
evals.append(e)
|
|
|
|
|
|
|
|
|
|
|
|
# --- Saisie des notes aléatoires
|
|
|
|
|
2021-07-03 23:35:32 +02:00
|
|
|
for eval in evals:
|
2021-07-02 12:34:44 +02:00
|
|
|
for etud in etuds:
|
|
|
|
nb_changed, nb_suppress, existing_decisions = G.create_note(
|
|
|
|
evaluation=eval, etud=etud, note=float(random.randint(0, 20))
|
|
|
|
)
|