2021-08-07 15:20:30 +02:00
|
|
|
"""ScoDoc8 models : Formations (hors BUT)
|
|
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from app import db
|
|
|
|
from app.models import APO_CODE_STR_LEN
|
|
|
|
from app.models import SHORT_STR_LEN
|
2021-11-08 19:44:25 +01:00
|
|
|
from app.scodoc.sco_utils import ModuleType
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class NotesFormation(db.Model):
|
|
|
|
"""Programme pédagogique d'une formation"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formations"
|
2021-09-19 21:31:35 +02:00
|
|
|
__table_args__ = (db.UniqueConstraint("dept_id", "acronyme", "titre", "version"),)
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
formation_id = db.synonym("id")
|
2021-08-13 00:34:58 +02:00
|
|
|
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
|
|
|
|
|
2021-08-15 22:33:09 +02:00
|
|
|
acronyme = db.Column(db.Text(), nullable=False)
|
2021-08-07 15:20:30 +02:00
|
|
|
titre = db.Column(db.Text(), nullable=False)
|
2021-08-08 16:01:10 +02:00
|
|
|
titre_officiel = db.Column(db.Text(), nullable=False)
|
2021-08-10 00:23:30 +02:00
|
|
|
version = db.Column(db.Integer, default=1, server_default="1")
|
2021-08-08 16:01:10 +02:00
|
|
|
formation_code = db.Column(
|
|
|
|
db.String(SHORT_STR_LEN),
|
|
|
|
server_default=db.text("notes_newid_fcod()"),
|
|
|
|
nullable=False,
|
|
|
|
)
|
|
|
|
# nb: la fonction SQL notes_newid_fcod doit être créée à part
|
2021-08-10 00:23:30 +02:00
|
|
|
type_parcours = db.Column(db.Integer, default=0, server_default="0")
|
2021-08-07 15:20:30 +02:00
|
|
|
code_specialite = db.Column(db.String(SHORT_STR_LEN))
|
|
|
|
|
2021-09-26 11:28:13 +02:00
|
|
|
ues = db.relationship("NotesUE", backref="formation", lazy="dynamic")
|
2021-08-13 00:34:58 +02:00
|
|
|
formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation")
|
2021-10-16 19:19:07 +02:00
|
|
|
ues = db.relationship("NotesUE", lazy="dynamic", backref="formation")
|
2021-08-13 00:34:58 +02:00
|
|
|
|
2021-09-26 11:28:13 +02:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__name__}(id={self.id}, dept_id={self.dept_id}, acronyme='{self.acronyme}')>"
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class NotesUE(db.Model):
|
|
|
|
"""Unité d'Enseignement"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_ue"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
ue_id = db.synonym("id")
|
|
|
|
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))
|
2021-08-15 22:41:47 +02:00
|
|
|
acronyme = db.Column(db.Text(), nullable=False)
|
2021-08-07 15:20:30 +02:00
|
|
|
numero = db.Column(db.Integer) # ordre de présentation
|
|
|
|
titre = db.Column(db.Text())
|
|
|
|
# Type d'UE: 0 normal ("fondamentale"), 1 "sport", 2 "projet et stage (LP)",
|
|
|
|
# 4 "élective"
|
2021-08-10 00:23:30 +02:00
|
|
|
type = db.Column(db.Integer, default=0, server_default="0")
|
2021-08-08 16:01:10 +02:00
|
|
|
# Les UE sont "compatibles" (pour la capitalisation) ssi elles ont ^m code
|
|
|
|
# note: la fonction SQL notes_newid_ucod doit être créée à part
|
|
|
|
ue_code = db.Column(
|
|
|
|
db.String(SHORT_STR_LEN),
|
|
|
|
server_default=db.text("notes_newid_ucod()"),
|
|
|
|
nullable=False,
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
ects = db.Column(db.Float) # nombre de credits ECTS
|
2021-08-10 00:23:30 +02:00
|
|
|
is_external = db.Column(db.Boolean(), default=False, server_default="false")
|
2021-08-07 15:20:30 +02:00
|
|
|
# id de l'element pedagogique Apogee correspondant:
|
|
|
|
code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
|
|
|
|
# coef UE, utilise seulement si l'option use_ue_coefs est activée:
|
|
|
|
coefficient = db.Column(db.Float)
|
|
|
|
|
2021-10-16 19:19:07 +02:00
|
|
|
# relations
|
|
|
|
matieres = db.relationship("NotesMatiere", lazy="dynamic", backref="ue")
|
|
|
|
modules = db.relationship("NotesModule", lazy="dynamic", backref="ue")
|
|
|
|
|
2021-09-26 11:28:13 +02:00
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__name__}(id={self.id}, formation_id={self.formation_id}, acronyme='{self.acronyme}')>"
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class NotesMatiere(db.Model):
|
|
|
|
"""Matières: regroupe les modules d'une UE
|
|
|
|
La matière a peu d'utilité en dehors de la présentation des modules
|
|
|
|
d'une UE.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_matieres"
|
|
|
|
__table_args__ = (db.UniqueConstraint("ue_id", "titre"),)
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
matiere_id = db.synonym("id")
|
|
|
|
ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id"))
|
|
|
|
titre = db.Column(db.Text())
|
|
|
|
numero = db.Column(db.Integer) # ordre de présentation
|
|
|
|
|
2021-10-16 19:19:07 +02:00
|
|
|
modules = db.relationship("NotesModule", lazy="dynamic", backref="matiere")
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class NotesModule(db.Model):
|
|
|
|
"""Module"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_modules"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
module_id = db.synonym("id")
|
|
|
|
titre = db.Column(db.Text())
|
|
|
|
abbrev = db.Column(db.Text()) # nom court
|
2021-08-27 17:03:47 +02:00
|
|
|
# certains départements ont des codes infiniment longs: donc Text !
|
|
|
|
code = db.Column(db.Text(), nullable=False)
|
2021-08-07 15:20:30 +02:00
|
|
|
heures_cours = db.Column(db.Float)
|
|
|
|
heures_td = db.Column(db.Float)
|
|
|
|
heures_tp = db.Column(db.Float)
|
|
|
|
coefficient = db.Column(db.Float) # coef PPN
|
2021-08-09 11:33:04 +02:00
|
|
|
ects = db.Column(db.Float) # Crédits ECTS
|
2021-08-08 17:38:46 +02:00
|
|
|
ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id"), index=True)
|
2021-08-07 15:20:30 +02:00
|
|
|
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))
|
|
|
|
matiere_id = db.Column(db.Integer, db.ForeignKey("notes_matieres.id"))
|
|
|
|
# pas un id mais le numéro du semestre: 1, 2, ...
|
2021-08-10 00:23:30 +02:00
|
|
|
semestre_id = db.Column(db.Integer, nullable=False, default=1, server_default="1")
|
2021-08-07 15:20:30 +02:00
|
|
|
numero = db.Column(db.Integer) # ordre de présentation
|
|
|
|
# id de l'element pedagogique Apogee correspondant:
|
|
|
|
code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
|
2021-11-08 19:44:25 +01:00
|
|
|
# Type: ModuleType: DEFAULT, MALUS, RESSOURCE, MODULE_SAE (enum)
|
|
|
|
module_type = db.Column(db.Integer)
|
2021-10-16 19:19:07 +02:00
|
|
|
# Relations:
|
|
|
|
modimpls = db.relationship("NotesModuleImpl", backref="module", lazy="dynamic")
|
2021-08-07 15:20:30 +02:00
|
|
|
|
2021-11-08 19:44:25 +01:00
|
|
|
def __repr__(self):
|
|
|
|
return (
|
|
|
|
f"<Module{ModuleType(self.module_type).name} id={self.id} code={self.code}>"
|
|
|
|
)
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class NotesTag(db.Model):
|
|
|
|
"""Tag sur un module"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_tags"
|
2021-08-18 22:20:20 +02:00
|
|
|
__table_args__ = (db.UniqueConstraint("title", "dept_id"),)
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
tag_id = db.synonym("id")
|
2021-08-18 22:20:20 +02:00
|
|
|
|
|
|
|
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
|
|
|
|
title = db.Column(db.Text(), nullable=False)
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Association tag <-> module
|
|
|
|
notes_modules_tags = db.Table(
|
|
|
|
"notes_modules_tags",
|
2021-10-26 10:22:55 +02:00
|
|
|
db.Column(
|
|
|
|
"tag_id",
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_tags.id", ondelete="CASCADE"),
|
|
|
|
),
|
|
|
|
db.Column(
|
|
|
|
"module_id", db.Integer, db.ForeignKey("notes_modules.id", ondelete="CASCADE")
|
|
|
|
),
|
2021-08-07 15:20:30 +02:00
|
|
|
)
|