forked from ScoDoc/ScoDoc
Compare commits
2 Commits
1083f60020
...
809d98df0a
Author | SHA1 | Date | |
---|---|---|---|
|
809d98df0a | ||
|
457a5a8b06 |
@ -27,6 +27,15 @@ class Absence(db.Model):
|
||||
# XXX TODO: contrainte ajoutée: vérifier suppression du module
|
||||
# (mettre à NULL sans supprimer)
|
||||
|
||||
def __init__(self, id, etudid, jour, estabs, estjust, matin, description):
|
||||
self.id = id,
|
||||
self.etudid = etudid,
|
||||
self.jour = jour,
|
||||
self.estabs = estabs,
|
||||
self.estjust = estjust,
|
||||
self.matin = matin,
|
||||
self.description = description
|
||||
|
||||
def to_dict(self):
|
||||
data = {
|
||||
"id": self.id,
|
||||
|
@ -93,11 +93,11 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||
type_departement,
|
||||
version_orebut,
|
||||
_xml_attribs,
|
||||
scodoc_date_loaded,
|
||||
#scodoc_date_loaded,
|
||||
scodoc_orig_filename,
|
||||
competences,
|
||||
parcours,
|
||||
formations,
|
||||
# competences,
|
||||
# parcours,
|
||||
# formations,
|
||||
):
|
||||
self.id = id
|
||||
self.dept_id = dept_id
|
||||
@ -109,11 +109,11 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||
self.type_departement = type_departement
|
||||
self.version_orebut = version_orebut
|
||||
self._xml_attribs = _xml_attribs
|
||||
self.scodoc_date_loaded = scodoc_date_loaded
|
||||
#self.scodoc_date_loaded = scodoc_date_loaded
|
||||
self.scodoc_orig_filename = scodoc_orig_filename
|
||||
self.competences = competences
|
||||
self.parcours = parcours
|
||||
self.formations = formations
|
||||
# self.competences = competences
|
||||
# self.parcours = parcours
|
||||
# self.formations = formations
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ApcReferentielCompetences {self.id} {self.specialite}>"
|
||||
|
@ -37,7 +37,7 @@ from app.models import (
|
||||
ModuleImpl,
|
||||
NotesNotes,
|
||||
ApcReferentielCompetences,
|
||||
ApcCompetence,
|
||||
ApcCompetence, Absence,
|
||||
)
|
||||
from app import db
|
||||
from app.models.but_refcomp import (
|
||||
@ -271,126 +271,126 @@ def create_ref_comp(formation: Formation):
|
||||
"""
|
||||
Créer un referentiel de competences
|
||||
"""
|
||||
### ApcSituationPro ###
|
||||
apc_situation_pro_id = 1
|
||||
apc_situation_pro_competence_id = 1
|
||||
apc_situation_pro_libelle = ""
|
||||
|
||||
apc_situation_pro = ApcSituationPro(
|
||||
apc_situation_pro_id, apc_situation_pro_competence_id, apc_situation_pro_libelle
|
||||
)
|
||||
db.session.add(apc_situation_pro)
|
||||
db.session.commit()
|
||||
|
||||
### ApcComposanteEssentielle ###
|
||||
apc_composante_essentielle_id = 1
|
||||
apc_composante_essentielle_competence_id = 1
|
||||
apc_composante_essentielle_libelle = ""
|
||||
|
||||
apc_composante_essentielle = ApcComposanteEssentielle(
|
||||
apc_composante_essentielle_id,
|
||||
apc_composante_essentielle_competence_id,
|
||||
apc_composante_essentielle_libelle,
|
||||
)
|
||||
db.session.add(apc_composante_essentielle)
|
||||
db.session.commit()
|
||||
|
||||
### ApcAppCritique ###
|
||||
apc_app_critique_id = 1
|
||||
apc_app_critique_niveau_id = 1
|
||||
apc_app_critique_code = ""
|
||||
apc_app_critique_libelle = ""
|
||||
apc_app_critique_modules = formation.modules
|
||||
|
||||
apc_app_critique = ApcAppCritique(
|
||||
apc_app_critique_id,
|
||||
apc_app_critique_niveau_id,
|
||||
apc_app_critique_code,
|
||||
apc_app_critique_libelle,
|
||||
apc_app_critique_modules,
|
||||
)
|
||||
db.session.add(apc_app_critique)
|
||||
db.session.commit()
|
||||
|
||||
### ApcNiveau ###
|
||||
apc_niveau_id = 1
|
||||
apc_niveau_competence_id = 1
|
||||
apc_niveau_libelle = ""
|
||||
apc_niveau_annee = ""
|
||||
apc_niveau_ordre = 1
|
||||
apc_niveau_app_critiques = apc_app_critique
|
||||
|
||||
apc_niveau = ApcNiveau(
|
||||
apc_niveau_id,
|
||||
apc_niveau_competence_id,
|
||||
apc_niveau_libelle,
|
||||
apc_niveau_annee,
|
||||
apc_niveau_ordre,
|
||||
apc_niveau_app_critiques,
|
||||
)
|
||||
db.session.add(apc_niveau)
|
||||
db.session.commit()
|
||||
|
||||
### ApcCompetence ###
|
||||
apc_competence_id = 1
|
||||
apc_competence_referentiel_id = 1
|
||||
apc_competence_id_orebut = ""
|
||||
apc_competence_titre = ""
|
||||
apc_competence_titre_long = ""
|
||||
apc_competence_couleur = ""
|
||||
apc_competence_numero = 1
|
||||
apc_competence_xml_attribs = { # xml_attrib : attribute
|
||||
"id": "id_orebut",
|
||||
"nom_court": "titre", # was name
|
||||
"libelle_long": "titre_long",
|
||||
}
|
||||
apc_competence_situations = apc_situation_pro
|
||||
apc_competence_composantes_essentielles = apc_composante_essentielle
|
||||
apc_competence_niveaux = apc_niveau
|
||||
|
||||
apc_competence = ApcCompetence(
|
||||
apc_competence_id,
|
||||
apc_competence_referentiel_id,
|
||||
apc_competence_id_orebut,
|
||||
apc_competence_titre,
|
||||
apc_competence_titre_long,
|
||||
apc_competence_couleur,
|
||||
apc_competence_numero,
|
||||
apc_competence_xml_attribs,
|
||||
apc_competence_situations,
|
||||
apc_competence_composantes_essentielles,
|
||||
apc_competence_niveaux,
|
||||
)
|
||||
db.session.add(apc_competence)
|
||||
db.session.commit()
|
||||
|
||||
### ApcAnneeParcours ###
|
||||
apc_annee_parcours_id = 1
|
||||
apc_annee_parcours_parcours_id = 1
|
||||
apc_annee_parcours_ordre = 1
|
||||
|
||||
ap_annee_parcours = ApcAnneeParcours(
|
||||
apc_annee_parcours_id, apc_annee_parcours_parcours_id, apc_annee_parcours_ordre
|
||||
)
|
||||
|
||||
### ApcParcours ###
|
||||
apc_parcours_id = 1
|
||||
apc_parcours_referentiel_id = 1
|
||||
apc_parcours_numero = 1
|
||||
apc_parcours_code = ""
|
||||
apc_parcours_libelle = ""
|
||||
apc_parcours_annees = ap_annee_parcours
|
||||
|
||||
apc_parcours = ApcParcours(
|
||||
apc_parcours_id,
|
||||
apc_parcours_referentiel_id,
|
||||
apc_parcours_numero,
|
||||
apc_parcours_code,
|
||||
apc_parcours_libelle,
|
||||
apc_parcours_annees,
|
||||
)
|
||||
db.session.add(apc_parcours)
|
||||
db.session.commit()
|
||||
# ### ApcSituationPro ###
|
||||
# apc_situation_pro_id = 1
|
||||
# apc_situation_pro_competence_id = 1
|
||||
# apc_situation_pro_libelle = ""
|
||||
#
|
||||
# apc_situation_pro = ApcSituationPro(
|
||||
# apc_situation_pro_id, apc_situation_pro_competence_id, apc_situation_pro_libelle
|
||||
# )
|
||||
# db.session.add(apc_situation_pro)
|
||||
# db.session.commit()
|
||||
#
|
||||
# ### ApcComposanteEssentielle ###
|
||||
# apc_composante_essentielle_id = 1
|
||||
# apc_composante_essentielle_competence_id = 1
|
||||
# apc_composante_essentielle_libelle = ""
|
||||
#
|
||||
# apc_composante_essentielle = ApcComposanteEssentielle(
|
||||
# apc_composante_essentielle_id,
|
||||
# apc_composante_essentielle_competence_id,
|
||||
# apc_composante_essentielle_libelle,
|
||||
# )
|
||||
# db.session.add(apc_composante_essentielle)
|
||||
# db.session.commit()
|
||||
#
|
||||
# ### ApcAppCritique ###
|
||||
# apc_app_critique_id = 1
|
||||
# apc_app_critique_niveau_id = 1
|
||||
# apc_app_critique_code = ""
|
||||
# apc_app_critique_libelle = ""
|
||||
# apc_app_critique_modules = formation.modules
|
||||
#
|
||||
# apc_app_critique = ApcAppCritique(
|
||||
# apc_app_critique_id,
|
||||
# apc_app_critique_niveau_id,
|
||||
# apc_app_critique_code,
|
||||
# apc_app_critique_libelle,
|
||||
# apc_app_critique_modules,
|
||||
# )
|
||||
# db.session.add(apc_app_critique)
|
||||
# db.session.commit()
|
||||
#
|
||||
# ### ApcNiveau ###
|
||||
# apc_niveau_id = 1
|
||||
# apc_niveau_competence_id = 1
|
||||
# apc_niveau_libelle = ""
|
||||
# apc_niveau_annee = ""
|
||||
# apc_niveau_ordre = 1
|
||||
# apc_niveau_app_critiques = apc_app_critique
|
||||
#
|
||||
# apc_niveau = ApcNiveau(
|
||||
# apc_niveau_id,
|
||||
# apc_niveau_competence_id,
|
||||
# apc_niveau_libelle,
|
||||
# apc_niveau_annee,
|
||||
# apc_niveau_ordre,
|
||||
# apc_niveau_app_critiques,
|
||||
# )
|
||||
# db.session.add(apc_niveau)
|
||||
# db.session.commit()
|
||||
#
|
||||
# ### ApcCompetence ###
|
||||
# apc_competence_id = 1
|
||||
# apc_competence_referentiel_id = 1
|
||||
# apc_competence_id_orebut = ""
|
||||
# apc_competence_titre = ""
|
||||
# apc_competence_titre_long = ""
|
||||
# apc_competence_couleur = ""
|
||||
# apc_competence_numero = 1
|
||||
# apc_competence_xml_attribs = { # xml_attrib : attribute
|
||||
# "id": "id_orebut",
|
||||
# "nom_court": "titre", # was name
|
||||
# "libelle_long": "titre_long",
|
||||
# }
|
||||
# apc_competence_situations = apc_situation_pro
|
||||
# apc_competence_composantes_essentielles = apc_composante_essentielle
|
||||
# apc_competence_niveaux = apc_niveau
|
||||
#
|
||||
# apc_competence = ApcCompetence(
|
||||
# apc_competence_id,
|
||||
# apc_competence_referentiel_id,
|
||||
# apc_competence_id_orebut,
|
||||
# apc_competence_titre,
|
||||
# apc_competence_titre_long,
|
||||
# apc_competence_couleur,
|
||||
# apc_competence_numero,
|
||||
# apc_competence_xml_attribs,
|
||||
# apc_competence_situations,
|
||||
# apc_competence_composantes_essentielles,
|
||||
# apc_competence_niveaux,
|
||||
# )
|
||||
# db.session.add(apc_competence)
|
||||
# db.session.commit()
|
||||
#
|
||||
# ### ApcAnneeParcours ###
|
||||
# apc_annee_parcours_id = 1
|
||||
# apc_annee_parcours_parcours_id = 1
|
||||
# apc_annee_parcours_ordre = 1
|
||||
#
|
||||
# ap_annee_parcours = ApcAnneeParcours(
|
||||
# apc_annee_parcours_id, apc_annee_parcours_parcours_id, apc_annee_parcours_ordre
|
||||
# )
|
||||
#
|
||||
# ### ApcParcours ###
|
||||
# apc_parcours_id = 1
|
||||
# apc_parcours_referentiel_id = 1
|
||||
# apc_parcours_numero = 1
|
||||
# apc_parcours_code = ""
|
||||
# apc_parcours_libelle = ""
|
||||
# apc_parcours_annees = ap_annee_parcours
|
||||
#
|
||||
# apc_parcours = ApcParcours(
|
||||
# apc_parcours_id,
|
||||
# apc_parcours_referentiel_id,
|
||||
# apc_parcours_numero,
|
||||
# apc_parcours_code,
|
||||
# apc_parcours_libelle,
|
||||
# apc_parcours_annees,
|
||||
# )
|
||||
# db.session.add(apc_parcours)
|
||||
# db.session.commit()
|
||||
|
||||
### ApcReferentielCompetences ###
|
||||
apc_referentiel_competences_id = 1
|
||||
@ -408,9 +408,9 @@ def create_ref_comp(formation: Formation):
|
||||
}
|
||||
apc_referentiel_competences_scodoc_date_loaded = ""
|
||||
apc_referentiel_competences_scodoc_orig_filename = ""
|
||||
apc_referentiel_competences_competences = apc_competence
|
||||
apc_referentiel_competences_parcours = apc_parcours
|
||||
apc_referentiel_competences_formations = formation
|
||||
# apc_referentiel_competences_competences = apc_competence
|
||||
# apc_referentiel_competences_parcours = apc_parcours
|
||||
# apc_referentiel_competences_formations = formation
|
||||
|
||||
apc_referentiel_competences = ApcReferentielCompetences(
|
||||
apc_referentiel_competences_id,
|
||||
@ -423,15 +423,46 @@ def create_ref_comp(formation: Formation):
|
||||
apc_referentiel_competences_type_departement,
|
||||
apc_referentiel_competences_version_orebut,
|
||||
apc_referentiel_competences_xml_attribs,
|
||||
apc_referentiel_competences_scodoc_date_loaded,
|
||||
#apc_referentiel_competences_scodoc_date_loaded,
|
||||
apc_referentiel_competences_scodoc_orig_filename,
|
||||
apc_referentiel_competences_competences,
|
||||
apc_referentiel_competences_parcours,
|
||||
apc_referentiel_competences_formations,
|
||||
# apc_referentiel_competences_competences,
|
||||
# apc_referentiel_competences_parcours,
|
||||
# apc_referentiel_competences_formations,
|
||||
)
|
||||
db.session.add(apc_referentiel_competences)
|
||||
db.session.commit()
|
||||
|
||||
formation.referentiel_competence_id = apc_referentiel_competences.id
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def add_absences(formsemestre: FormSemestre):
|
||||
"""
|
||||
Ajoute des absences en base
|
||||
"""
|
||||
date_debut = formsemestre.date_debut
|
||||
date_fin = formsemestre.date_fin
|
||||
|
||||
etuds = formsemestre.etuds
|
||||
# list_etuds = []
|
||||
for etu in etuds:
|
||||
id_db = 1
|
||||
aleatoire = random.randint(0, 1)
|
||||
if aleatoire == 1:
|
||||
nb_absences = random.randint(1, 5)
|
||||
for absence in range(0, nb_absences):
|
||||
id = id_db
|
||||
etudid = etu.id
|
||||
jour = date_debut + random.random() * (date_fin - date_debut)
|
||||
estabs = True
|
||||
estjust = True if random.randint(0, 1) == 1 else False
|
||||
matin = True if random.randint(0, 1) == 1 else False
|
||||
description = ""
|
||||
abs = Absence(id, etudid, jour, estabs, estjust, matin, description)
|
||||
db.session.add(abs)
|
||||
db.session.commit()
|
||||
id_db += 1
|
||||
|
||||
|
||||
def init_test_database():
|
||||
"""Appelé par la commande `flask init-test-database`
|
||||
@ -448,6 +479,7 @@ def init_test_database():
|
||||
inscrit_etudiants(etuds, formsemestre)
|
||||
saisie_notes_evaluations(formsemestre, user_lecteur)
|
||||
create_ref_comp(formation)
|
||||
add_absences(formsemestre)
|
||||
# à compléter
|
||||
# - groupes
|
||||
# - absences
|
||||
|
Loading…
Reference in New Issue
Block a user