forked from ScoDoc/ScoDoc
Enhanced tests + some code cleaning
This commit is contained in:
parent
f9c2eb0e94
commit
73cabb0039
@ -34,10 +34,7 @@
|
|||||||
import time, string, glob, re, inspect
|
import time, string, glob, re, inspect
|
||||||
import urllib, urllib2, cgi, xml
|
import urllib, urllib2, cgi, xml
|
||||||
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except:
|
|
||||||
from StringIO import StringIO
|
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
import os.path, glob
|
import os.path, glob
|
||||||
import traceback
|
import traceback
|
||||||
@ -48,9 +45,8 @@ from email.MIMEBase import MIMEBase
|
|||||||
from email.Header import Header
|
from email.Header import Header
|
||||||
from email import Encoders
|
from email import Encoders
|
||||||
|
|
||||||
from sco_zope import *
|
from sco_zope import * # pylint: disable=unused-wildcard-import
|
||||||
|
|
||||||
#
|
|
||||||
try:
|
try:
|
||||||
import Products.ZPsycopgDA.DA as ZopeDA
|
import Products.ZPsycopgDA.DA as ZopeDA
|
||||||
except:
|
except:
|
||||||
|
@ -87,7 +87,8 @@ import ZNotes
|
|||||||
import ZAbsences
|
import ZAbsences
|
||||||
import ZEntreprises
|
import ZEntreprises
|
||||||
import ZScoUsers
|
import ZScoUsers
|
||||||
import sco_modalites
|
|
||||||
|
# import sco_modalites
|
||||||
import ImportScolars
|
import ImportScolars
|
||||||
import sco_abs
|
import sco_abs
|
||||||
import sco_portal_apogee
|
import sco_portal_apogee
|
||||||
|
@ -33,8 +33,8 @@ Elle n'est pas utilisée pour les parcours, ni pour rien d'autre
|
|||||||
(c'est donc un attribut "cosmétique").
|
(c'est donc un attribut "cosmétique").
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from notesdb import *
|
import notesdb as ndb
|
||||||
from sco_utils import *
|
import sco_utils as scu
|
||||||
from notes_log import log
|
from notes_log import log
|
||||||
from TrivialFormulator import TrivialFormulator, TF
|
from TrivialFormulator import TrivialFormulator, TF
|
||||||
import sco_codes_parcours
|
import sco_codes_parcours
|
||||||
@ -56,7 +56,7 @@ def group_sems_by_modalite(context, sems):
|
|||||||
"""Given the list of fromsemestre, group them by modalite,
|
"""Given the list of fromsemestre, group them by modalite,
|
||||||
sorted in each one by semestre id and date
|
sorted in each one by semestre id and date
|
||||||
"""
|
"""
|
||||||
sems_by_mod = DictDefault(defaultvalue=[])
|
sems_by_mod = scu.DictDefault(defaultvalue=[])
|
||||||
modalites = list_formsemestres_modalites(context, sems)
|
modalites = list_formsemestres_modalites(context, sems)
|
||||||
for modalite in modalites:
|
for modalite in modalites:
|
||||||
for sem in sems:
|
for sem in sems:
|
||||||
@ -75,12 +75,12 @@ def group_sems_by_modalite(context, sems):
|
|||||||
|
|
||||||
# ------ Low level interface (database) ------
|
# ------ Low level interface (database) ------
|
||||||
|
|
||||||
_modaliteEditor = EditableTable(
|
_modaliteEditor = ndb.EditableTable(
|
||||||
"notes_form_modalites",
|
"notes_form_modalites",
|
||||||
"form_modalite_id",
|
"form_modalite_id",
|
||||||
("form_modalite_id", "modalite", "titre", "numero"),
|
("form_modalite_id", "modalite", "titre", "numero"),
|
||||||
sortkey="numero",
|
sortkey="numero",
|
||||||
output_formators={"numero": int_null_is_zero},
|
output_formators={"numero": ndb.int_null_is_zero},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -90,23 +90,23 @@ def do_modalite_list(context, *args, **kw):
|
|||||||
return _modaliteEditor.list(cnx, *args, **kw)
|
return _modaliteEditor.list(cnx, *args, **kw)
|
||||||
|
|
||||||
|
|
||||||
def do_modalite_create(context, args, REQUEST):
|
def do_modalite_create(context, args, REQUEST=None):
|
||||||
"create a modalite"
|
"create a modalite"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = context.GetDBConnexion()
|
||||||
r = _modaliteEditor.create(cnx, args)
|
r = _modaliteEditor.create(cnx, args)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def do_modalite_delete(context, oid, REQUEST=None):
|
def do_modalite_delete(context, oid, REQUEST=None):
|
||||||
"delete a modalite"
|
"delete a modalite"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = context.GetDBConnexion()
|
||||||
log("do_modalite_delete: form_modalite_id=%s" % oid)
|
log("do_modalite_delete: form_modalite_id=%s" % oid)
|
||||||
_modaliteEditor.delete(cnx, oid)
|
_modaliteEditor.delete(cnx, oid)
|
||||||
|
|
||||||
|
|
||||||
def do_modalite_edit(context, *args, **kw):
|
def do_modalite_edit(context, *args, **kw):
|
||||||
"edit a modalite"
|
"edit a modalite"
|
||||||
cnx = self.GetDBConnexion()
|
cnx = context.GetDBConnexion()
|
||||||
# check
|
# check
|
||||||
m = do_modalite_list(context, {"form_modalite_id": args[0]["form_modalite_id"]})[0]
|
m = do_modalite_list(context, {"form_modalite_id": args[0]["form_modalite_id"]})[0]
|
||||||
_modaliteEditor.edit(cnx, *args, **kw)
|
_modaliteEditor.edit(cnx, *args, **kw)
|
||||||
|
@ -132,7 +132,7 @@ class ScoFake:
|
|||||||
code_specialite=None,
|
code_specialite=None,
|
||||||
):
|
):
|
||||||
"""Crée une formation"""
|
"""Crée une formation"""
|
||||||
if acronyme == "":
|
if not acronyme:
|
||||||
acronyme = "TEST" + str(random.randint(100000, 999999))
|
acronyme = "TEST" + str(random.randint(100000, 999999))
|
||||||
oid = self.context.do_formation_create(locals(), REQUEST=REQUEST)
|
oid = self.context.do_formation_create(locals(), REQUEST=REQUEST)
|
||||||
oids = self.context.formation_list(args={"formation_id": oid})
|
oids = self.context.formation_list(args={"formation_id": oid})
|
||||||
@ -295,7 +295,14 @@ class ScoFake:
|
|||||||
comment=comment,
|
comment=comment,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_formation(self, nb_semestre=1, nb_ue_per_semestre=2, nb_module_per_ue=2):
|
def setup_formation(
|
||||||
|
self,
|
||||||
|
nb_semestre=1,
|
||||||
|
nb_ue_per_semestre=2,
|
||||||
|
nb_module_per_ue=2,
|
||||||
|
acronyme=None,
|
||||||
|
titre=None,
|
||||||
|
):
|
||||||
"""Création d'une formation, avec UE, modules et évaluations.
|
"""Création d'une formation, avec UE, modules et évaluations.
|
||||||
|
|
||||||
Formation avec `nb_semestre` comportant chacun `nb_ue_per_semestre` UE
|
Formation avec `nb_semestre` comportant chacun `nb_ue_per_semestre` UE
|
||||||
@ -304,7 +311,7 @@ class ScoFake:
|
|||||||
Returns:
|
Returns:
|
||||||
formation (dict), liste d'ue (dicts), liste de modules.
|
formation (dict), liste d'ue (dicts), liste de modules.
|
||||||
"""
|
"""
|
||||||
f = self.create_formation(acronyme="")
|
f = self.create_formation(acronyme=acronyme, titre=titre)
|
||||||
ue_list = []
|
ue_list = []
|
||||||
mod_list = []
|
mod_list = []
|
||||||
for semestre_id in range(1, nb_semestre + 1):
|
for semestre_id in range(1, nb_semestre + 1):
|
||||||
@ -337,6 +344,9 @@ class ScoFake:
|
|||||||
date_debut="01/01/2020",
|
date_debut="01/01/2020",
|
||||||
date_fin="30/06/2020",
|
date_fin="30/06/2020",
|
||||||
nb_evaluations_per_module=1,
|
nb_evaluations_per_module=1,
|
||||||
|
titre=None,
|
||||||
|
responsables=["bach"],
|
||||||
|
modalite=None,
|
||||||
):
|
):
|
||||||
"""Création semestre, avec modules et évaluations."""
|
"""Création semestre, avec modules et évaluations."""
|
||||||
sem = self.create_formsemestre(
|
sem = self.create_formsemestre(
|
||||||
@ -344,6 +354,9 @@ class ScoFake:
|
|||||||
semestre_id=semestre_id,
|
semestre_id=semestre_id,
|
||||||
date_debut=date_debut,
|
date_debut=date_debut,
|
||||||
date_fin=date_fin,
|
date_fin=date_fin,
|
||||||
|
titre=titre,
|
||||||
|
responsables=responsables,
|
||||||
|
modalite=modalite,
|
||||||
)
|
)
|
||||||
eval_list = []
|
eval_list = []
|
||||||
for mod in mod_list:
|
for mod in mod_list:
|
||||||
|
@ -14,6 +14,7 @@ Utiliser comme:
|
|||||||
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
||||||
import sco_utils
|
import sco_utils
|
||||||
import sco_codes_parcours
|
import sco_codes_parcours
|
||||||
|
import sco_modalites
|
||||||
|
|
||||||
G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable
|
G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable
|
||||||
G.verbose = False
|
G.verbose = False
|
||||||
@ -21,8 +22,29 @@ G.verbose = False
|
|||||||
# --- Création d'étudiants
|
# --- Création d'étudiants
|
||||||
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
||||||
|
|
||||||
|
# Deux modalités
|
||||||
|
# sco_modalites.do_modalite_create(context, {})
|
||||||
|
|
||||||
# --- Mise en place formation 4 semestres
|
# --- Mise en place formation 4 semestres
|
||||||
f, ue_list, mod_list = G.setup_formation(nb_semestre=4)
|
form_dut, ue_list, mod_list = G.setup_formation(
|
||||||
|
nb_semestre=4, titre="DUT RT", acronyme="DUT-RT"
|
||||||
|
)
|
||||||
|
|
||||||
|
# --- et une formation LP en 2 semestres
|
||||||
|
form_lp, ue_list_lp, mod_list_lp = G.setup_formation(
|
||||||
|
nb_semestre=2, titre="Licence Pro Ingéniérie Pédagogique", acronyme="LP IP"
|
||||||
|
)
|
||||||
|
# et un semestre que l'on ne va pas utiliser ici:
|
||||||
|
_, _ = G.setup_formsemestre(
|
||||||
|
form_lp,
|
||||||
|
mod_list_lp,
|
||||||
|
semestre_id=1,
|
||||||
|
date_debut="01/09/2021",
|
||||||
|
date_fin="15/01/2022",
|
||||||
|
titre="Licence Pro Ingéniérie Pédagogique",
|
||||||
|
responsables=["callas"],
|
||||||
|
modalite="FAP",
|
||||||
|
)
|
||||||
|
|
||||||
# --- Crée les 4 semestres et affecte des notes aléatoires
|
# --- Crée les 4 semestres et affecte des notes aléatoires
|
||||||
sems, evals = [], []
|
sems, evals = [], []
|
||||||
@ -33,7 +55,12 @@ for semestre_id, date_debut, date_fin in [
|
|||||||
(4, "16/01/2021", "30/06/2021"),
|
(4, "16/01/2021", "30/06/2021"),
|
||||||
]:
|
]:
|
||||||
sem, eval_list = G.setup_formsemestre(
|
sem, eval_list = G.setup_formsemestre(
|
||||||
f, mod_list, semestre_id=semestre_id, date_debut=date_debut, date_fin=date_fin
|
form_dut,
|
||||||
|
mod_list,
|
||||||
|
semestre_id=semestre_id,
|
||||||
|
date_debut=date_debut,
|
||||||
|
date_fin=date_fin,
|
||||||
|
titre="BUT Réseaux et Tests",
|
||||||
)
|
)
|
||||||
sems.append(sem)
|
sems.append(sem)
|
||||||
evals.append(eval_list) # liste des listes d'evaluations
|
evals.append(eval_list) # liste des listes d'evaluations
|
||||||
@ -55,7 +82,12 @@ for semestre_id, date_debut, date_fin in [
|
|||||||
(4, "16/01/2023", "30/06/2023"),
|
(4, "16/01/2023", "30/06/2023"),
|
||||||
]:
|
]:
|
||||||
sem, eval_list = G.setup_formsemestre(
|
sem, eval_list = G.setup_formsemestre(
|
||||||
f, mod_list, semestre_id=semestre_id, date_debut=date_debut, date_fin=date_fin
|
form_dut,
|
||||||
|
mod_list,
|
||||||
|
semestre_id=semestre_id,
|
||||||
|
date_debut=date_debut,
|
||||||
|
date_fin=date_fin,
|
||||||
|
titre="BUT Réseaux et Tests",
|
||||||
)
|
)
|
||||||
sems.append(sem)
|
sems.append(sem)
|
||||||
evals.append(eval_list) # liste des listes d'evaluations
|
evals.append(eval_list) # liste des listes d'evaluations
|
||||||
|
Loading…
Reference in New Issue
Block a user