2021-12-03 14:13:49 +01:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2022-01-01 14:49:42 +01:00
|
|
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
2021-12-03 14:13:49 +01:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
2021-12-02 12:08:03 +01:00
|
|
|
"""ScoDoc 9 models : Référentiel Compétence BUT 2021
|
|
|
|
"""
|
2021-12-03 11:03:33 +01:00
|
|
|
from datetime import datetime
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-29 08:17:04 +02:00
|
|
|
import flask_sqlalchemy
|
2022-01-03 12:25:42 +01:00
|
|
|
from sqlalchemy.orm import class_mapper
|
|
|
|
import sqlalchemy
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
from app import db
|
|
|
|
|
|
|
|
from app.scodoc.sco_utils import ModuleType
|
|
|
|
|
|
|
|
|
2022-01-03 12:25:42 +01:00
|
|
|
# from https://stackoverflow.com/questions/2537471/method-of-iterating-over-sqlalchemy-models-defined-columns
|
|
|
|
def attribute_names(cls):
|
|
|
|
"liste ids (noms de colonnes) d'un modèle"
|
|
|
|
return [
|
|
|
|
prop.key
|
|
|
|
for prop in class_mapper(cls).iterate_properties
|
|
|
|
if isinstance(prop, sqlalchemy.orm.ColumnProperty)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
class XMLModel:
|
2022-04-26 06:02:17 +02:00
|
|
|
"""Mixin class, to ease loading Orebut XMLs"""
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
_xml_attribs = {} # to be overloaded
|
|
|
|
id = "_"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def attr_from_xml(cls, args: dict) -> dict:
|
|
|
|
"""dict with attributes imported from Orébut XML
|
|
|
|
and renamed for our models.
|
|
|
|
The mapping is specified by the _xml_attribs
|
|
|
|
attribute in each model class.
|
2022-01-03 12:25:42 +01:00
|
|
|
Keep only attributes corresponding to columns in our model:
|
|
|
|
other XML attributes are simply ignored.
|
2021-12-02 12:08:03 +01:00
|
|
|
"""
|
2022-01-03 12:25:42 +01:00
|
|
|
columns = attribute_names(cls)
|
|
|
|
renamed_attributes = {cls._xml_attribs.get(k, k): v for (k, v) in args.items()}
|
|
|
|
return {k: renamed_attributes[k] for k in renamed_attributes if k in columns}
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f'<{self.__class__.__name__} {self.id} "{self.titre if hasattr(self, "titre") else ""}">'
|
|
|
|
|
|
|
|
|
|
|
|
class ApcReferentielCompetences(db.Model, XMLModel):
|
2022-01-05 23:42:11 +01:00
|
|
|
"Référentiel de compétence d'une spécialité"
|
2021-12-02 12:08:03 +01:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
|
2022-01-03 12:25:42 +01:00
|
|
|
annexe = db.Column(db.Text())
|
2021-12-02 12:08:03 +01:00
|
|
|
specialite = db.Column(db.Text())
|
|
|
|
specialite_long = db.Column(db.Text())
|
|
|
|
type_titre = db.Column(db.Text())
|
2022-01-03 12:25:42 +01:00
|
|
|
type_structure = db.Column(db.Text())
|
|
|
|
type_departement = db.Column(db.Text()) # "secondaire", "tertiaire"
|
|
|
|
version_orebut = db.Column(db.Text())
|
2021-12-03 11:03:33 +01:00
|
|
|
_xml_attribs = { # Orébut xml attrib : attribute
|
2021-12-02 12:08:03 +01:00
|
|
|
"type": "type_titre",
|
2022-01-03 12:25:42 +01:00
|
|
|
"version": "version_orebut",
|
2021-12-02 12:08:03 +01:00
|
|
|
}
|
2021-12-03 11:03:33 +01:00
|
|
|
# ScoDoc specific fields:
|
|
|
|
scodoc_date_loaded = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
|
scodoc_orig_filename = db.Column(db.Text())
|
|
|
|
# Relations:
|
2021-12-02 12:08:03 +01:00
|
|
|
competences = db.relationship(
|
|
|
|
"ApcCompetence",
|
|
|
|
backref="referentiel",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
|
|
|
parcours = db.relationship(
|
|
|
|
"ApcParcours",
|
|
|
|
backref="referentiel",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
2021-12-03 15:44:57 +01:00
|
|
|
formations = db.relationship("Formation", backref="referentiel_competence")
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-02-12 20:25:22 +01:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<ApcReferentielCompetences {self.id} {self.specialite}>"
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
def to_dict(self):
|
|
|
|
"""Représentation complète du ref. de comp.
|
|
|
|
comme un dict.
|
|
|
|
"""
|
2021-12-02 17:36:32 +01:00
|
|
|
return {
|
|
|
|
"dept_id": self.dept_id,
|
2022-01-03 12:25:42 +01:00
|
|
|
"annexe": self.annexe,
|
2021-12-02 17:36:32 +01:00
|
|
|
"specialite": self.specialite,
|
|
|
|
"specialite_long": self.specialite_long,
|
2022-01-03 12:25:42 +01:00
|
|
|
"type_structure": self.type_structure,
|
|
|
|
"type_departement": self.type_departement,
|
2021-12-02 17:36:32 +01:00
|
|
|
"type_titre": self.type_titre,
|
2022-01-03 12:25:42 +01:00
|
|
|
"version_orebut": self.version_orebut,
|
2021-12-03 15:44:57 +01:00
|
|
|
"scodoc_date_loaded": self.scodoc_date_loaded.isoformat() + "Z"
|
|
|
|
if self.scodoc_date_loaded
|
|
|
|
else "",
|
2021-12-03 11:03:33 +01:00
|
|
|
"scodoc_orig_filename": self.scodoc_orig_filename,
|
2021-12-02 17:36:32 +01:00
|
|
|
"competences": {x.titre: x.to_dict() for x in self.competences},
|
|
|
|
"parcours": {x.code: x.to_dict() for x in self.parcours},
|
|
|
|
}
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-29 08:17:04 +02:00
|
|
|
def get_niveaux_by_parcours(self, annee) -> dict:
|
|
|
|
"""
|
|
|
|
Construit la liste des niveaux de compétences pour chaque parcours
|
|
|
|
de ce référentiel.
|
|
|
|
Les niveaux sont groupés par parcours, en isolant les niveaux de tronc commun.
|
|
|
|
Le tronc commun n'est pas identifié comme tel dans les référentiels Orébut:
|
|
|
|
on cherche les niveaux qui sont présents dans tous les parcours et les range sous
|
|
|
|
la clé "TC" (toujours présente mais éventuellement liste vide si pas de tronc commun).
|
|
|
|
|
|
|
|
résultat:
|
|
|
|
{
|
|
|
|
"TC" : [ ApcNiveau ],
|
|
|
|
parcour.id : [ ApcNiveau ]
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
parcours = self.parcours.order_by(ApcParcours.numero).all()
|
|
|
|
niveaux_by_parcours = {
|
|
|
|
parcour.id: ApcNiveau.niveaux_annee_de_parcours(parcour, annee)
|
|
|
|
for parcour in parcours
|
|
|
|
}
|
|
|
|
# Cherche tronc commun
|
|
|
|
niveaux_ids_tc = set.intersection(
|
|
|
|
*[
|
|
|
|
{n.id for n in niveaux_by_parcours[parcour_id]}
|
|
|
|
for parcour_id in niveaux_by_parcours
|
|
|
|
]
|
|
|
|
)
|
|
|
|
# Enleve les niveaux du tronc commun
|
|
|
|
niveaux_by_parcours_no_tc = {
|
|
|
|
parcour.id: [
|
|
|
|
niveau
|
|
|
|
for niveau in niveaux_by_parcours[parcour.id]
|
|
|
|
if niveau.id not in niveaux_ids_tc
|
|
|
|
]
|
|
|
|
for parcour in parcours
|
|
|
|
}
|
|
|
|
# Niveaux du TC
|
|
|
|
niveaux_tc = []
|
|
|
|
if len(parcours):
|
|
|
|
niveaux_parcours_1 = niveaux_by_parcours[parcours[0].id]
|
|
|
|
niveaux_tc = [
|
|
|
|
niveau for niveau in niveaux_parcours_1 if niveau.id in niveaux_ids_tc
|
|
|
|
]
|
|
|
|
niveaux_by_parcours_no_tc["TC"] = niveaux_tc
|
|
|
|
return niveaux_by_parcours_no_tc
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
class ApcCompetence(db.Model, XMLModel):
|
2022-01-05 23:42:11 +01:00
|
|
|
"Compétence"
|
2021-12-02 12:08:03 +01:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
referentiel_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_referentiel_competences.id"), nullable=False
|
|
|
|
)
|
2022-01-05 23:42:11 +01:00
|
|
|
# les compétences dans Orébut sont identifiées par leur id unique
|
2022-02-12 20:25:22 +01:00
|
|
|
# (mais id_orebut n'est pas unique car le même ref. pourra être chargé dans plusieurs depts)
|
|
|
|
id_orebut = db.Column(db.Text(), nullable=True, index=True)
|
2021-12-03 11:03:33 +01:00
|
|
|
titre = db.Column(db.Text(), nullable=False, index=True)
|
2021-12-02 12:08:03 +01:00
|
|
|
titre_long = db.Column(db.Text())
|
|
|
|
couleur = db.Column(db.Text())
|
|
|
|
numero = db.Column(db.Integer) # ordre de présentation
|
|
|
|
_xml_attribs = { # xml_attrib : attribute
|
2022-01-03 12:25:42 +01:00
|
|
|
"id": "id_orebut",
|
|
|
|
"nom_court": "titre", # was name
|
2021-12-02 12:08:03 +01:00
|
|
|
"libelle_long": "titre_long",
|
|
|
|
}
|
|
|
|
situations = db.relationship(
|
|
|
|
"ApcSituationPro",
|
|
|
|
backref="competence",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
|
|
|
composantes_essentielles = db.relationship(
|
|
|
|
"ApcComposanteEssentielle",
|
|
|
|
backref="competence",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
|
|
|
niveaux = db.relationship(
|
|
|
|
"ApcNiveau",
|
|
|
|
backref="competence",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
|
|
|
|
2022-02-12 20:25:22 +01:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<ApcCompetence {self.id} {self.titre}>"
|
|
|
|
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {
|
2022-01-03 12:25:42 +01:00
|
|
|
"id_orebut": self.id_orebut,
|
2021-12-02 17:36:32 +01:00
|
|
|
"titre": self.titre,
|
|
|
|
"titre_long": self.titre_long,
|
|
|
|
"couleur": self.couleur,
|
|
|
|
"numero": self.numero,
|
|
|
|
"situations": [x.to_dict() for x in self.situations],
|
|
|
|
"composantes_essentielles": [
|
|
|
|
x.to_dict() for x in self.composantes_essentielles
|
|
|
|
],
|
|
|
|
"niveaux": {x.annee: x.to_dict() for x in self.niveaux},
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
class ApcSituationPro(db.Model, XMLModel):
|
2022-04-26 06:02:17 +02:00
|
|
|
"Situation professionnelle"
|
2021-12-02 12:08:03 +01:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
competence_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_competence.id"), nullable=False
|
|
|
|
)
|
|
|
|
libelle = db.Column(db.Text(), nullable=False)
|
|
|
|
# aucun attribut (le text devient le libellé)
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {"libelle": self.libelle}
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ApcComposanteEssentielle(db.Model, XMLModel):
|
2022-04-26 06:02:17 +02:00
|
|
|
"Composante essentielle"
|
2021-12-02 12:08:03 +01:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
competence_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_competence.id"), nullable=False
|
|
|
|
)
|
|
|
|
libelle = db.Column(db.Text(), nullable=False)
|
|
|
|
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {"libelle": self.libelle}
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
class ApcNiveau(db.Model, XMLModel):
|
2022-04-29 08:17:04 +02:00
|
|
|
"""Niveau de compétence
|
|
|
|
Chaque niveau peut être associé à deux UE,
|
|
|
|
des semestres impair et pair de la même année.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__tablename__ = "apc_niveau"
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
competence_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_competence.id"), nullable=False
|
|
|
|
)
|
|
|
|
libelle = db.Column(db.Text(), nullable=False)
|
2022-04-29 08:17:04 +02:00
|
|
|
annee = db.Column(db.Text(), nullable=False) # "BUT1", "BUT2", "BUT3"
|
|
|
|
# L'ordre est le niveau (1,2,3) ou (1,2) suivant la competence
|
2021-12-02 12:08:03 +01:00
|
|
|
ordre = db.Column(db.Integer, nullable=False) # 1, 2, 3
|
|
|
|
app_critiques = db.relationship(
|
|
|
|
"ApcAppCritique",
|
|
|
|
backref="niveau",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
2022-04-29 08:17:04 +02:00
|
|
|
ues = db.relationship("UniteEns", back_populates="niveau_competence")
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-26 06:02:17 +02:00
|
|
|
def __repr__(self):
|
2022-04-29 08:17:04 +02:00
|
|
|
return f"<{self.__class__.__name__} ordre={self.ordre} annee={self.annee} {self.competence}>"
|
2022-04-26 06:02:17 +02:00
|
|
|
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {
|
|
|
|
"libelle": self.libelle,
|
|
|
|
"annee": self.annee,
|
|
|
|
"ordre": self.ordre,
|
|
|
|
"app_critiques": {x.code: x.to_dict() for x in self.app_critiques},
|
|
|
|
}
|
|
|
|
|
2022-04-29 08:17:04 +02:00
|
|
|
@classmethod
|
|
|
|
def niveaux_annee_de_parcours(
|
|
|
|
cls, parcour: "ApcParcours", annee: int
|
|
|
|
) -> flask_sqlalchemy.BaseQuery:
|
|
|
|
"""Les niveaux de l'année du parcours"""
|
|
|
|
if annee not in {1, 2, 3}:
|
|
|
|
raise ValueError("annee invalide pour un parcours BUT")
|
|
|
|
annee_formation = f"BUT{annee}"
|
|
|
|
return ApcNiveau.query.filter(
|
|
|
|
ApcParcoursNiveauCompetence.annee_parcours_id == ApcAnneeParcours.id,
|
|
|
|
ApcParcours.id == ApcAnneeParcours.parcours_id,
|
|
|
|
ApcParcours.referentiel == parcour.referentiel,
|
|
|
|
ApcParcoursNiveauCompetence.competence_id == ApcCompetence.id,
|
|
|
|
ApcCompetence.id == ApcNiveau.competence_id,
|
|
|
|
ApcAnneeParcours.parcours == parcour,
|
|
|
|
ApcNiveau.annee == annee_formation,
|
|
|
|
)
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-05-02 14:39:06 +02:00
|
|
|
app_critiques_modules = db.Table(
|
|
|
|
"apc_modules_acs",
|
|
|
|
db.Column(
|
|
|
|
"module_id",
|
|
|
|
db.ForeignKey("notes_modules.id", ondelete="CASCADE"),
|
|
|
|
primary_key=True,
|
|
|
|
),
|
|
|
|
db.Column(
|
|
|
|
"app_crit_id",
|
|
|
|
db.ForeignKey("apc_app_critique.id"),
|
|
|
|
primary_key=True,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
class ApcAppCritique(db.Model, XMLModel):
|
|
|
|
"Apprentissage Critique BUT"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
niveau_id = db.Column(db.Integer, db.ForeignKey("apc_niveau.id"), nullable=False)
|
2021-12-03 11:03:33 +01:00
|
|
|
code = db.Column(db.Text(), nullable=False, index=True)
|
2021-12-02 12:08:03 +01:00
|
|
|
libelle = db.Column(db.Text())
|
|
|
|
|
2022-05-02 14:39:06 +02:00
|
|
|
# modules = db.relationship(
|
|
|
|
# "Module",
|
|
|
|
# secondary="apc_modules_acs",
|
|
|
|
# lazy="dynamic",
|
|
|
|
# backref=db.backref("app_critiques", lazy="dynamic"),
|
|
|
|
# )
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def app_critiques_ref_comp(
|
|
|
|
cls,
|
|
|
|
ref_comp: ApcReferentielCompetences,
|
|
|
|
annee: str,
|
|
|
|
competence: ApcCompetence = None,
|
|
|
|
) -> flask_sqlalchemy.BaseQuery:
|
|
|
|
"Liste les AC de tous les parcours de ref_comp pour l'année indiquée"
|
|
|
|
assert annee in {"BUT1", "BUT2", "BUT3"}
|
|
|
|
query = cls.query.filter(
|
|
|
|
ApcAppCritique.niveau_id == ApcNiveau.id,
|
|
|
|
ApcNiveau.competence_id == ApcCompetence.id,
|
|
|
|
ApcNiveau.annee == annee,
|
|
|
|
ApcCompetence.referentiel_id == ref_comp.id,
|
|
|
|
)
|
|
|
|
if competence is not None:
|
|
|
|
query = query.filter(ApcNiveau.competence == competence)
|
|
|
|
return query
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-26 06:02:17 +02:00
|
|
|
def to_dict(self) -> dict:
|
2021-12-03 15:44:57 +01:00
|
|
|
return {"libelle": self.libelle}
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-26 06:02:17 +02:00
|
|
|
def get_label(self) -> str:
|
2021-12-02 12:08:03 +01:00
|
|
|
return self.code + " - " + self.titre
|
|
|
|
|
|
|
|
def __repr__(self):
|
2022-04-26 06:02:17 +02:00
|
|
|
return f"<{self.__class__.__name__} {self.code}>"
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
def get_saes(self):
|
|
|
|
"""Liste des SAE associées"""
|
|
|
|
return [m for m in self.modules if m.module_type == ModuleType.SAE]
|
|
|
|
|
|
|
|
|
2022-05-01 23:58:41 +02:00
|
|
|
parcours_modules = db.Table(
|
|
|
|
"parcours_modules",
|
|
|
|
db.Column(
|
|
|
|
"parcours_id", db.Integer, db.ForeignKey("apc_parcours.id"), primary_key=True
|
|
|
|
),
|
|
|
|
db.Column(
|
|
|
|
"module_id",
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_modules.id", ondelete="CASCADE"),
|
|
|
|
primary_key=True,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
"""Association parcours <-> modules (many-to-many)"""
|
|
|
|
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
class ApcParcours(db.Model, XMLModel):
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
referentiel_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_referentiel_competences.id"), nullable=False
|
|
|
|
)
|
|
|
|
numero = db.Column(db.Integer) # ordre de présentation
|
|
|
|
code = db.Column(db.Text(), nullable=False)
|
|
|
|
libelle = db.Column(db.Text(), nullable=False)
|
|
|
|
annees = db.relationship(
|
|
|
|
"ApcAnneeParcours",
|
|
|
|
backref="parcours",
|
|
|
|
lazy="dynamic",
|
|
|
|
cascade="all, delete-orphan",
|
|
|
|
)
|
|
|
|
|
2022-04-26 06:02:17 +02:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__name__} {self.code}>"
|
|
|
|
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {
|
|
|
|
"code": self.code,
|
|
|
|
"numero": self.numero,
|
|
|
|
"libelle": self.libelle,
|
|
|
|
"annees": {x.ordre: x.to_dict() for x in self.annees},
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
class ApcAnneeParcours(db.Model, XMLModel):
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
parcours_id = db.Column(
|
|
|
|
db.Integer, db.ForeignKey("apc_parcours.id"), nullable=False
|
|
|
|
)
|
2021-12-02 17:36:32 +01:00
|
|
|
ordre = db.Column(db.Integer)
|
2022-04-29 08:17:04 +02:00
|
|
|
"numéro de l'année: 1, 2, 3"
|
2021-12-02 12:08:03 +01:00
|
|
|
|
2022-04-26 06:02:17 +02:00
|
|
|
def __repr__(self):
|
2022-04-29 08:17:04 +02:00
|
|
|
return f"<{self.__class__.__name__} ordre={self.ordre} parcours={self.parcours.code}>"
|
2022-04-26 06:02:17 +02:00
|
|
|
|
2021-12-02 17:36:32 +01:00
|
|
|
def to_dict(self):
|
|
|
|
return {
|
|
|
|
"ordre": self.ordre,
|
|
|
|
"competences": {
|
2022-01-08 17:22:51 +01:00
|
|
|
x.competence.titre: {
|
|
|
|
"niveau": x.niveau,
|
|
|
|
"id_orebut": x.competence.id_orebut,
|
|
|
|
}
|
2021-12-02 17:36:32 +01:00
|
|
|
for x in self.niveaux_competences
|
|
|
|
},
|
|
|
|
}
|
2021-12-02 12:08:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ApcParcoursNiveauCompetence(db.Model):
|
|
|
|
"""Association entre année de parcours et compétence.
|
|
|
|
Le "niveau" de la compétence est donné ici
|
|
|
|
(convention Orébut)
|
|
|
|
"""
|
|
|
|
|
|
|
|
competence_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("apc_competence.id", ondelete="CASCADE"),
|
|
|
|
primary_key=True,
|
|
|
|
)
|
|
|
|
annee_parcours_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("apc_annee_parcours.id", ondelete="CASCADE"),
|
|
|
|
primary_key=True,
|
|
|
|
)
|
|
|
|
niveau = db.Column(db.Integer, nullable=False) # 1, 2, 3
|
|
|
|
competence = db.relationship(
|
|
|
|
ApcCompetence,
|
|
|
|
backref=db.backref(
|
|
|
|
"annee_parcours",
|
|
|
|
passive_deletes=True,
|
|
|
|
cascade="save-update, merge, delete, delete-orphan",
|
2022-04-29 08:17:04 +02:00
|
|
|
lazy="dynamic",
|
2021-12-02 12:08:03 +01:00
|
|
|
),
|
|
|
|
)
|
|
|
|
annee_parcours = db.relationship(
|
|
|
|
ApcAnneeParcours,
|
|
|
|
backref=db.backref(
|
2021-12-02 17:36:32 +01:00
|
|
|
"niveaux_competences",
|
2021-12-02 12:08:03 +01:00
|
|
|
passive_deletes=True,
|
|
|
|
cascade="save-update, merge, delete, delete-orphan",
|
|
|
|
),
|
|
|
|
)
|
2022-04-26 06:02:17 +02:00
|
|
|
|
|
|
|
def __repr__(self):
|
2022-04-29 08:17:04 +02:00
|
|
|
return f"<{self.__class__.__name__} {self.competence}<->{self.annee_parcours} niveau={self.niveau}>"
|