2021-08-07 15:20:30 +02:00
|
|
|
# -*- coding: UTF-8 -*
|
|
|
|
|
2021-11-13 08:25:51 +01:00
|
|
|
"""ScoDoc models: formsemestre
|
2021-08-07 15:20:30 +02:00
|
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
|
2021-11-17 10:28:51 +01:00
|
|
|
import flask_sqlalchemy
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
from app import db
|
|
|
|
from app.models import APO_CODE_STR_LEN
|
|
|
|
from app.models import SHORT_STR_LEN
|
|
|
|
from app.models import CODE_STR_LEN
|
2021-11-12 22:17:46 +01:00
|
|
|
from app.models import UniteEns
|
|
|
|
|
|
|
|
import app.scodoc.notesdb as ndb
|
|
|
|
from app.scodoc import sco_evaluation_db
|
2021-11-17 10:28:51 +01:00
|
|
|
from app.models.formations import UniteEns, Module
|
|
|
|
from app.models.moduleimpls import ModuleImpl
|
2021-11-18 23:53:57 +01:00
|
|
|
from app.models.etudiants import Identite
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class FormSemestre(db.Model):
|
2021-11-13 08:25:51 +01:00
|
|
|
"""Mise en oeuvre d'un semestre de formation"""
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
formsemestre_id = db.synonym("id")
|
2021-09-13 22:10:01 +02:00
|
|
|
# dept_id est aussi dans la formation, ajouté ici pour
|
2021-08-13 00:34:58 +02:00
|
|
|
# simplifier et accélérer les selects dans notesdb
|
|
|
|
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
|
2021-08-07 15:20:30 +02:00
|
|
|
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))
|
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
|
|
|
titre = db.Column(db.Text())
|
|
|
|
date_debut = db.Column(db.Date())
|
|
|
|
date_fin = db.Column(db.Date())
|
2021-08-10 00:23:30 +02:00
|
|
|
etat = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=True, server_default="true"
|
|
|
|
) # False si verrouillé
|
2021-08-14 18:54:32 +02:00
|
|
|
modalite = db.Column(
|
|
|
|
db.String(SHORT_STR_LEN), db.ForeignKey("notes_form_modalites.modalite")
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# gestion compensation sem DUT:
|
2021-08-10 00:23:30 +02:00
|
|
|
gestion_compensation = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="false"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# ne publie pas le bulletin XML:
|
2021-08-10 00:23:30 +02:00
|
|
|
bul_hide_xml = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="false"
|
|
|
|
)
|
2021-09-16 22:24:08 +02:00
|
|
|
# Bloque le calcul des moyennes (générale et d'UE)
|
|
|
|
block_moyennes = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="false"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# semestres decales (pour gestion jurys):
|
2021-08-10 00:23:30 +02:00
|
|
|
gestion_semestrielle = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="false"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# couleur fond bulletins HTML:
|
2021-08-10 00:23:30 +02:00
|
|
|
bul_bgcolor = db.Column(
|
|
|
|
db.String(SHORT_STR_LEN), default="white", server_default="white"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# autorise resp. a modifier semestre:
|
2021-08-10 00:23:30 +02:00
|
|
|
resp_can_edit = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="false"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# autorise resp. a modifier slt les enseignants:
|
2021-08-10 00:23:30 +02:00
|
|
|
resp_can_change_ens = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=True, server_default="true"
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# autorise les ens a creer des evals:
|
2021-08-10 00:23:30 +02:00
|
|
|
ens_can_edit_eval = db.Column(
|
|
|
|
db.Boolean(), nullable=False, default=False, server_default="False"
|
|
|
|
)
|
2021-08-14 18:54:32 +02:00
|
|
|
# code element semestre Apogee, eg 'VRTW1' ou 'V2INCS4,V2INLS4,...'
|
|
|
|
elt_sem_apo = db.Column(db.Text()) # peut être fort long !
|
|
|
|
# code element annee Apogee, eg 'VRT1A' ou 'V2INLA,V2INCA,...'
|
|
|
|
elt_annee_apo = db.Column(db.Text())
|
2021-08-07 15:20:30 +02:00
|
|
|
|
2021-10-16 19:19:07 +02:00
|
|
|
# Relations:
|
2021-08-07 15:20:30 +02:00
|
|
|
etapes = db.relationship(
|
2021-11-12 22:17:46 +01:00
|
|
|
"FormsemestreEtape", cascade="all,delete", backref="formsemestre"
|
2021-10-16 19:19:07 +02:00
|
|
|
)
|
2021-11-12 22:17:46 +01:00
|
|
|
modimpls = db.relationship("ModuleImpl", backref="formsemestre", lazy="dynamic")
|
2021-10-16 19:19:07 +02:00
|
|
|
|
2021-08-27 22:16:10 +02:00
|
|
|
# Ancien id ScoDoc7 pour les migrations de bases anciennes
|
2021-11-01 15:16:51 +01:00
|
|
|
# ne pas utiliser après migrate_scodoc7_dept_archives
|
2021-08-27 22:16:10 +02:00
|
|
|
scodoc7_id = db.Column(db.Text(), nullable=True)
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super(FormSemestre, self).__init__(**kwargs)
|
|
|
|
if self.modalite is None:
|
2021-11-12 22:17:46 +01:00
|
|
|
self.modalite = FormationModalite.DEFAULT_MODALITE
|
2021-08-07 15:20:30 +02:00
|
|
|
|
2021-11-17 10:28:51 +01:00
|
|
|
def query_ues(self) -> flask_sqlalchemy.BaseQuery:
|
|
|
|
"""UE des modules de ce semestre.
|
|
|
|
- Formations classiques: les UEs auxquelles appartiennent
|
|
|
|
les modules mis en place dans ce semestre.
|
|
|
|
- Formations APC / BUT: les UEs de la formation qui ont
|
|
|
|
le même numéro de semestre que ce formsemestre.
|
|
|
|
"""
|
|
|
|
if self.formation.get_parcours().APC_SAE:
|
|
|
|
sem_ues = UniteEns.query.filter_by(
|
|
|
|
formation=self.formation, semestre_idx=self.semestre_id
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
sem_ues = db.session.query(UniteEns).filter(
|
|
|
|
ModuleImpl.formsemestre_id == self.id,
|
|
|
|
Module.id == ModuleImpl.module_id,
|
|
|
|
UniteEns.id == Module.ue_id,
|
|
|
|
)
|
|
|
|
return sem_ues
|
2021-11-13 08:25:51 +01:00
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
# Association id des utilisateurs responsables (aka directeurs des etudes) du semestre
|
|
|
|
notes_formsemestre_responsables = db.Table(
|
|
|
|
"notes_formsemestre_responsables",
|
|
|
|
db.Column(
|
|
|
|
"formsemestre_id",
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
),
|
|
|
|
db.Column("responsable_id", db.Integer, db.ForeignKey("user.id")),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormsemestreEtape(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Étape Apogée associées au semestre"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre_etapes"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
|
|
|
etape_apo = db.Column(db.String(APO_CODE_STR_LEN))
|
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormationModalite(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Modalités de formation, utilisées pour la présentation
|
|
|
|
(grouper les semestres, générer des codes, etc.)
|
|
|
|
"""
|
|
|
|
|
2021-08-09 11:33:04 +02:00
|
|
|
__tablename__ = "notes_form_modalites"
|
|
|
|
|
2021-08-12 13:54:56 +02:00
|
|
|
DEFAULT_MODALITE = "FI"
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
2021-08-12 13:54:56 +02:00
|
|
|
modalite = db.Column(
|
2021-08-14 18:54:32 +02:00
|
|
|
db.String(SHORT_STR_LEN),
|
2021-08-12 13:54:56 +02:00
|
|
|
unique=True,
|
|
|
|
index=True,
|
|
|
|
default=DEFAULT_MODALITE,
|
|
|
|
server_default=DEFAULT_MODALITE,
|
|
|
|
) # code
|
2021-08-07 15:20:30 +02:00
|
|
|
titre = db.Column(db.Text()) # texte explicatif
|
|
|
|
# numero = ordre de presentation)
|
|
|
|
numero = db.Column(db.Integer)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def insert_modalites():
|
|
|
|
"""Create default modalities"""
|
|
|
|
numero = 0
|
2021-08-09 23:23:11 +02:00
|
|
|
try:
|
|
|
|
for (code, titre) in (
|
2021-11-12 22:17:46 +01:00
|
|
|
(FormationModalite.DEFAULT_MODALITE, "Formation Initiale"),
|
2021-08-09 23:23:11 +02:00
|
|
|
("FAP", "Apprentissage"),
|
|
|
|
("FC", "Formation Continue"),
|
|
|
|
("DEC", "Formation Décalées"),
|
|
|
|
("LIC", "Licence"),
|
|
|
|
("CPRO", "Contrats de Professionnalisation"),
|
|
|
|
("DIST", "À distance"),
|
|
|
|
("ETR", "À l'étranger"),
|
|
|
|
("EXT", "Extérieur"),
|
|
|
|
("OTHER", "Autres formations"),
|
|
|
|
):
|
2021-11-12 22:17:46 +01:00
|
|
|
modalite = FormationModalite.query.filter_by(modalite=code).first()
|
2021-08-09 23:23:11 +02:00
|
|
|
if modalite is None:
|
2021-11-12 22:17:46 +01:00
|
|
|
modalite = FormationModalite(
|
2021-08-09 23:23:11 +02:00
|
|
|
modalite=code, titre=titre, numero=numero
|
|
|
|
)
|
|
|
|
db.session.add(modalite)
|
|
|
|
numero += 1
|
2021-08-07 15:20:30 +02:00
|
|
|
db.session.commit()
|
2021-08-09 23:23:11 +02:00
|
|
|
except:
|
|
|
|
db.session.rollback()
|
|
|
|
raise
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormsemestreUECoef(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Coef des UE capitalisees arrivant dans ce semestre"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre_uecoef"
|
|
|
|
__table_args__ = (db.UniqueConstraint("formsemestre_id", "ue_id"),)
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
formsemestre_uecoef_id = db.synonym("id")
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
|
|
|
ue_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_ue.id"),
|
|
|
|
)
|
|
|
|
coefficient = db.Column(db.Float, nullable=False)
|
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormsemestreUEComputationExpr(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Formules utilisateurs pour calcul moyenne UE"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre_ue_computation_expr"
|
|
|
|
__table_args__ = (db.UniqueConstraint("formsemestre_id", "ue_id"),)
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
notes_formsemestre_ue_computation_expr_id = db.synonym("id")
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
|
|
|
ue_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_ue.id"),
|
|
|
|
)
|
|
|
|
# formule de calcul moyenne
|
|
|
|
computation_expr = db.Column(db.Text())
|
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormsemestreCustomMenu(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Menu custom associe au semestre"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre_custommenu"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
custommenu_id = db.synonym("id")
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
|
|
|
title = db.Column(db.Text())
|
|
|
|
url = db.Column(db.Text())
|
2021-08-10 00:23:30 +02:00
|
|
|
idx = db.Column(db.Integer, default=0, server_default="0") # rang dans le menu
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
class FormsemestreInscription(db.Model):
|
2021-08-07 15:20:30 +02:00
|
|
|
"""Inscription à un semestre de formation"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_formsemestre_inscription"
|
|
|
|
__table_args__ = (db.UniqueConstraint("formsemestre_id", "etudid"),)
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
formsemestre_inscription_id = db.synonym("id")
|
|
|
|
|
|
|
|
etudid = db.Column(db.Integer, db.ForeignKey("identite.id"))
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_formsemestre.id"),
|
|
|
|
)
|
2021-11-18 23:53:57 +01:00
|
|
|
etud = db.relationship(
|
|
|
|
Identite,
|
|
|
|
backref=db.backref("formsemestre_inscriptions", cascade="all, delete-orphan"),
|
|
|
|
)
|
|
|
|
formsemestre = db.relationship(
|
|
|
|
FormSemestre,
|
|
|
|
backref=db.backref("inscriptions", cascade="all, delete-orphan"),
|
|
|
|
)
|
2021-08-07 15:20:30 +02:00
|
|
|
# I inscrit, D demission en cours de semestre, DEF si "defaillant"
|
|
|
|
etat = db.Column(db.String(CODE_STR_LEN))
|
|
|
|
# etape apogee d'inscription (experimental 2020)
|
|
|
|
etape = db.Column(db.String(APO_CODE_STR_LEN))
|
|
|
|
|
|
|
|
|
|
|
|
class NotesSemSet(db.Model):
|
|
|
|
"""semsets: ensemble de formsemestres pour exports Apogée"""
|
|
|
|
|
|
|
|
__tablename__ = "notes_semset"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
semset_id = db.synonym("id")
|
2021-08-13 00:34:58 +02:00
|
|
|
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"))
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
title = db.Column(db.Text)
|
|
|
|
annee_scolaire = db.Column(db.Integer, nullable=True, default=None)
|
|
|
|
# periode: 0 (année), 1 (Simpair), 2 (Spair)
|
|
|
|
sem_id = db.Column(db.Integer, nullable=True, default=None)
|
|
|
|
|
|
|
|
|
2021-09-10 21:48:04 +02:00
|
|
|
# Association: many to many
|
2021-08-07 15:20:30 +02:00
|
|
|
notes_semset_formsemestre = db.Table(
|
|
|
|
"notes_semset_formsemestre",
|
|
|
|
db.Column("formsemestre_id", db.Integer, db.ForeignKey("notes_formsemestre.id")),
|
2021-09-10 21:48:04 +02:00
|
|
|
db.Column(
|
|
|
|
"semset_id",
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_semset.id", ondelete="CASCADE"),
|
|
|
|
nullable=False,
|
|
|
|
),
|
2021-08-07 15:20:30 +02:00
|
|
|
db.UniqueConstraint("formsemestre_id", "semset_id"),
|
|
|
|
)
|