forked from ScoDoc/ScoDoc
wip lecture cursus etu
This commit is contained in:
parent
962e9129c7
commit
ee1bb3cc27
@ -30,6 +30,7 @@
|
|||||||
import collections
|
import collections
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from openpyxl.cell import Cell
|
||||||
from openpyxl.styles.numbers import FORMAT_NUMBER_00
|
from openpyxl.styles.numbers import FORMAT_NUMBER_00
|
||||||
|
|
||||||
from flask import flash, abort
|
from flask import flash, abort
|
||||||
@ -59,12 +60,9 @@ from app.scodoc import sco_cursus
|
|||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
import sco_version
|
import sco_version
|
||||||
|
from app.scodoc.sco_excel import ScoExcelBook, ScoExcelSheet
|
||||||
|
|
||||||
# Structure de donnée:
|
listeAnnees = ["BUT1", "BUT2", "BUT3"]
|
||||||
# --- _Compilation
|
|
||||||
# +----- parcours
|
|
||||||
# +- parcour : ApcParcours
|
|
||||||
# +- etudiants : list[_Etudiant]
|
|
||||||
|
|
||||||
|
|
||||||
class _Bilan:
|
class _Bilan:
|
||||||
@ -84,11 +82,16 @@ class _Niveau:
|
|||||||
self.bilan = None
|
self.bilan = None
|
||||||
self.etudiant = etudiant
|
self.etudiant = etudiant
|
||||||
self.candidates = niveauDesc.get_ues(etudiant)
|
self.candidates = niveauDesc.get_ues(etudiant)
|
||||||
self.UEs: tuple[_UE, _UE] = niveauDesc.get_ues(etudiant)
|
self.ues = collections.defaultdict(list)
|
||||||
|
|
||||||
|
def add_ue_status(self, semestre_idx, status):
|
||||||
|
self.ues[semestre_idx].append(status)
|
||||||
|
|
||||||
|
|
||||||
class _Annee:
|
class _Annee:
|
||||||
def __init__(self):
|
def __init__(self, etudiant, anneeDesc):
|
||||||
|
self.etudiant = etudiant
|
||||||
|
self.anneeDesc = anneeDesc
|
||||||
self.bilan: _Bilan = None
|
self.bilan: _Bilan = None
|
||||||
self.niveaux = {}
|
self.niveaux = {}
|
||||||
|
|
||||||
@ -97,9 +100,12 @@ class _Competence:
|
|||||||
def __init__(self, etudiant, competenceDesc, semestres):
|
def __init__(self, etudiant, competenceDesc, semestres):
|
||||||
self.descr = competenceDesc
|
self.descr = competenceDesc
|
||||||
self.etudiant = etudiant
|
self.etudiant = etudiant
|
||||||
self.niveaux = []
|
self.niveaux = {}
|
||||||
for niveauDesc in competenceDesc.niveaux:
|
for niveau_id, niveauDesc in competenceDesc.niveaux.items():
|
||||||
self.niveaux.append(_Niveau(etudiant, niveauDesc, semestres))
|
self.niveaux[niveau_id] = _Niveau(etudiant, niveauDesc, semestres)
|
||||||
|
|
||||||
|
def getNiveau(self, niveau_id):
|
||||||
|
return self.niveaux[niveau_id]
|
||||||
|
|
||||||
|
|
||||||
class _Semestre:
|
class _Semestre:
|
||||||
@ -119,8 +125,8 @@ class _NiveauDesc:
|
|||||||
def __init__(self, scodocNiveau):
|
def __init__(self, scodocNiveau):
|
||||||
self.fromScodoc = scodocNiveau
|
self.fromScodoc = scodocNiveau
|
||||||
self.ues = {}
|
self.ues = {}
|
||||||
for ue in scodocNiveau.ues:
|
for scodocUe in scodocNiveau.ues:
|
||||||
self.ues[(ue.formation_id, ue.semestre_idx)] = ue
|
self.ues[(scodocUe.formation_id, scodocUe.semestre_idx)] = scodocUe
|
||||||
|
|
||||||
def get_ues(self, etudiant):
|
def get_ues(self, etudiant):
|
||||||
"""get list of candidates UEs for Niveau"""
|
"""get list of candidates UEs for Niveau"""
|
||||||
@ -129,7 +135,6 @@ class _NiveauDesc:
|
|||||||
formation_id = inscription.formsemestre.formation_id
|
formation_id = inscription.formsemestre.formation_id
|
||||||
semestre_idx = inscription.formsemestre.semestre_id
|
semestre_idx = inscription.formsemestre.semestre_id
|
||||||
if (formation_id, semestre_idx) in self.ues:
|
if (formation_id, semestre_idx) in self.ues:
|
||||||
breakpoint()
|
|
||||||
# identifier les ues cocernées
|
# identifier les ues cocernées
|
||||||
ues[semestre_idx % 2] = inscription.formsemestre
|
ues[semestre_idx % 2] = inscription.formsemestre
|
||||||
return ues
|
return ues
|
||||||
@ -138,34 +143,65 @@ class _NiveauDesc:
|
|||||||
class _CompetenceDesc:
|
class _CompetenceDesc:
|
||||||
def __init__(self, scodocCompetence):
|
def __init__(self, scodocCompetence):
|
||||||
self.fromScodoc: ApcCompetence = scodocCompetence
|
self.fromScodoc: ApcCompetence = scodocCompetence
|
||||||
self.niveaux: list[_NiveauDesc] = [
|
self.niveaux = {}
|
||||||
_NiveauDesc(scodocNiveau) for scodocNiveau in scodocCompetence.niveaux.all()
|
for scodocNiveau in scodocCompetence.niveaux.all():
|
||||||
]
|
self.niveaux[scodocNiveau.id] = _NiveauDesc(scodocNiveau)
|
||||||
|
|
||||||
|
def getNiveauDesc(self, niveau_id):
|
||||||
|
return self.niveaux[niveau_id]
|
||||||
|
|
||||||
|
def getNiveaux(self, codeAnnee):
|
||||||
|
niveaux = []
|
||||||
|
for niveau_id, niveauDesc in self.niveaux.items():
|
||||||
|
if codeAnnee == niveauDesc.fromScodoc.annee:
|
||||||
|
niveaux.append(niveauDesc)
|
||||||
|
return niveaux
|
||||||
|
|
||||||
|
|
||||||
|
class _AnneeDesc:
|
||||||
|
def __init__(self, codeAnnee):
|
||||||
|
self.codeAnnee = codeAnnee
|
||||||
|
self.niveaux = {}
|
||||||
|
|
||||||
|
def addNiveau(self, niveaux):
|
||||||
|
for niveau in niveaux:
|
||||||
|
self.niveaux[niveau.fromScodoc.id] = niveau
|
||||||
|
|
||||||
|
|
||||||
class _ParcoursDesc:
|
class _ParcoursDesc:
|
||||||
def __init__(self, formation, scodocParcour: ApcParcours = None):
|
def __init__(self, formation, scodocParcour: ApcParcours = None):
|
||||||
self.fromScodoc: ApcParcours = scodocParcour # None pour le tronc commun 'TC'
|
self.fromScodoc: ApcParcours = scodocParcour # None pour le tronc commun 'TC'
|
||||||
self.etudiants = []
|
self.etudiants = []
|
||||||
|
self.competences = {}
|
||||||
|
self.annees = {}
|
||||||
if scodocParcour is None:
|
if scodocParcour is None:
|
||||||
self.competences = [
|
for (
|
||||||
_CompetenceDesc(scodocCompetence)
|
scodocCompetence
|
||||||
for scodocCompetence in formation.referentiel_competence.get_competences_tronc_commun()
|
) in formation.referentiel_competence.get_competences_tronc_commun():
|
||||||
]
|
self.competences[scodocCompetence.id] = _CompetenceDesc(
|
||||||
|
scodocCompetence
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
query = formation.query_competences_parcour(scodocParcour)
|
query = formation.query_competences_parcour(scodocParcour)
|
||||||
if query is None:
|
if not query is None:
|
||||||
self.competences = []
|
for scodocCompetence in query.all():
|
||||||
else:
|
self.competences[scodocCompetence.id] = _CompetenceDesc(
|
||||||
self.competences = [
|
scodocCompetence
|
||||||
_CompetenceDesc(scodocCompetence)
|
)
|
||||||
for scodocCompetence in query.all()
|
for codeAnnee in listeAnnees:
|
||||||
]
|
anneeDesc = _AnneeDesc(codeAnnee)
|
||||||
|
for competence_id, competence in self.competences.items():
|
||||||
|
anneeDesc.addNiveau(competence.getNiveaux(codeAnnee))
|
||||||
|
self.annees[codeAnnee] = anneeDesc
|
||||||
|
breakpoint()
|
||||||
|
|
||||||
def add_etudiant(self, etudiant):
|
def add_etudiant(self, etudiant):
|
||||||
if not etudiant in self.etudiants:
|
if not etudiant in self.etudiants:
|
||||||
self.etudiants.append(etudiant)
|
self.etudiants.append(etudiant)
|
||||||
|
|
||||||
|
def getNiveauDesc(self, competence_id, niveau_id):
|
||||||
|
return self.competences[competence_id].getNiveauDesc(niveau_id)
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
data = []
|
data = []
|
||||||
etudiant: _Etudiant
|
etudiant: _Etudiant
|
||||||
@ -173,28 +209,80 @@ class _ParcoursDesc:
|
|||||||
data.append(etudiant.getData())
|
data.append(etudiant.getData())
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def generate_title(self, worksheet: ScoExcelSheet):
|
||||||
|
worksheet.append_blank_row()
|
||||||
|
cells1 = [
|
||||||
|
worksheet.make_cell(title)
|
||||||
|
for title in [
|
||||||
|
"etudid",
|
||||||
|
"nip",
|
||||||
|
"Civ",
|
||||||
|
"nom",
|
||||||
|
"prenom",
|
||||||
|
"parcours",
|
||||||
|
"cursus",
|
||||||
|
"absences",
|
||||||
|
"abs. non just.",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
cells2 = [ len(title) * '' ]
|
||||||
|
cells3 = [ len(title) * '' ]
|
||||||
|
cells4 = [ len(title) * '' ]
|
||||||
|
worksheet.append_row(cells1)
|
||||||
|
worksheet.append_row(cells2)
|
||||||
|
worksheet.append_row(cells3)
|
||||||
|
worksheet.append_row(cells4)
|
||||||
|
for codeAnnee in listeAnnees:
|
||||||
|
|
||||||
|
|
||||||
|
def generate(self, workbook: ScoExcelBook):
|
||||||
|
if self.fromScodoc:
|
||||||
|
sheet_name = self.fromScodoc.code
|
||||||
|
else:
|
||||||
|
sheet_name = "TC"
|
||||||
|
worksheet = ScoExcelSheet = workbook.create_sheet(sheet_name)
|
||||||
|
self.generate_title(worksheet)
|
||||||
|
|
||||||
|
|
||||||
class _Etudiant:
|
class _Etudiant:
|
||||||
def __init__(self, ident, formation):
|
def __init__(self, ident, formation):
|
||||||
self.ident = ident
|
self.ident = ident
|
||||||
self.cursus: EtudCursusBUT = EtudCursusBUT(ident, formation)
|
self.cursus: EtudCursusBUT = EtudCursusBUT(ident, formation)
|
||||||
self.semestres = {}
|
self.formsemestres = []
|
||||||
self.parcour = self.cursus.inscriptions[-1].parcour
|
self.parcour = self.cursus.inscriptions[-1].parcour
|
||||||
self.history = []
|
self.history = []
|
||||||
self.competence = []
|
self.competences = {}
|
||||||
self.annees = []
|
self.annees = []
|
||||||
for inscription in self.cursus.inscriptions:
|
for inscription in self.cursus.inscriptions:
|
||||||
formsemestre = inscription.formsemestre
|
formsemestre = inscription.formsemestre
|
||||||
self.semestres[formsemestre.semestre_id] = inscription.formsemestre
|
self.formsemestres.append(inscription.formsemestre.id)
|
||||||
Sx = f"S{formsemestre.semestre_id}"
|
Sx = f"S{formsemestre.semestre_id}"
|
||||||
etat = inscription.etat
|
etat = inscription.etat
|
||||||
if etat != "I":
|
if etat != "I":
|
||||||
Sx += "(Dem)" if etat == "D" else f"({etat})"
|
Sx += "(Dem)" if etat == "D" else f"({etat})"
|
||||||
self.history.append(Sx)
|
self.history.append(Sx)
|
||||||
|
|
||||||
def fill_in(self, parcourDescr, semestres, cursus):
|
def fill_in(self, parcourDescr, semestres):
|
||||||
for competenceDescr in parcourDescr.competences:
|
self.annees = {
|
||||||
self.competence.append(_Competence(self, competenceDescr, semestres))
|
codeAnnee: _Annee(self, anneeDesc)
|
||||||
|
for codeAnnee, anneeDesc in parcourDescr.annees.items()
|
||||||
|
}
|
||||||
|
for (competence_id, competenceDesc) in parcourDescr.competences.items():
|
||||||
|
self.competences[competence_id] = _Competence(
|
||||||
|
self, competenceDesc, semestres
|
||||||
|
)
|
||||||
|
for formsemestre_id in self.formsemestres:
|
||||||
|
semestre: _Semestre = semestres[formsemestre_id]
|
||||||
|
ues = semestre.resultatsSemestreBUT.etud_ues(self.ident.etudid)
|
||||||
|
for ue in ues:
|
||||||
|
niveau_id = ue.niveau_competence_id
|
||||||
|
competence_id = ue.niveau_competence.competence_id
|
||||||
|
semestre_idx = ue.semestre_idx
|
||||||
|
niveau = self.competences[competence_id].getNiveau(niveau_id)
|
||||||
|
status = semestre.resultatsSemestreBUT.get_etud_ue_status(
|
||||||
|
self.ident.etudid, ue.id
|
||||||
|
)
|
||||||
|
niveau.add_ue_status(semestre_idx, status)
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
result = [
|
result = [
|
||||||
@ -217,12 +305,15 @@ class _Compilation:
|
|||||||
formsemestre_id = formsemestre.formsemestre_id
|
formsemestre_id = formsemestre.formsemestre_id
|
||||||
self.semestre: _Semestre = _Semestre(formsemestre_id, formsemestre)
|
self.semestre: _Semestre = _Semestre(formsemestre_id, formsemestre)
|
||||||
self.formation: Formation = formsemestre.formation
|
self.formation: Formation = formsemestre.formation
|
||||||
self.add_semestre(formsemestre_id)
|
self.add_semestre(formsemestre_id, self.semestre)
|
||||||
breakpoint()
|
|
||||||
for ident in self.semestre.resultatsSemestreBUT.get_inscrits(order_by="moy"):
|
for ident in self.semestre.resultatsSemestreBUT.get_inscrits(order_by="moy"):
|
||||||
etudiant: _Etudiant = _Etudiant(ident, self.formation)
|
etudiant: _Etudiant = _Etudiant(ident, self.formation)
|
||||||
for inscription in etudiant.cursus.inscriptions:
|
for inscription in etudiant.cursus.inscriptions:
|
||||||
formsemestre = inscription.formsemestre
|
formsemestre = inscription.formsemestre
|
||||||
|
if (
|
||||||
|
formsemestre.formation.referentiel_competence
|
||||||
|
== self.formation.referentiel_competence
|
||||||
|
):
|
||||||
self.add_semestre(formsemestre.id)
|
self.add_semestre(formsemestre.id)
|
||||||
scodocParcour = etudiant.parcour
|
scodocParcour = etudiant.parcour
|
||||||
if scodocParcour is None:
|
if scodocParcour is None:
|
||||||
@ -235,26 +326,33 @@ class _Compilation:
|
|||||||
parcoursDesc = _ParcoursDesc(self.formation, scodocParcour)
|
parcoursDesc = _ParcoursDesc(self.formation, scodocParcour)
|
||||||
self.parcours[parcourCode] = parcoursDesc
|
self.parcours[parcourCode] = parcoursDesc
|
||||||
parcoursDesc.add_etudiant(etudiant)
|
parcoursDesc.add_etudiant(etudiant)
|
||||||
etudiant.fill_in(parcoursDesc, self.semestres, etudiant.cursus)
|
etudiant.fill_in(parcoursDesc, self.semestres)
|
||||||
|
breakpoint()
|
||||||
|
pass
|
||||||
|
|
||||||
def add_semestre(self, formsemestre_id):
|
def add_semestre(self, formsemestre_id, semestre: _Semestre = None):
|
||||||
if not formsemestre_id in self.semestres:
|
if not formsemestre_id in self.semestres:
|
||||||
|
if semestre is None:
|
||||||
|
semestre = _Semestre(formsemestre_id)
|
||||||
self.semestres[formsemestre_id] = _Semestre(formsemestre_id)
|
self.semestres[formsemestre_id] = _Semestre(formsemestre_id)
|
||||||
|
|
||||||
def add_parcours(self, parcour: ApcParcours, etudiant: _Etudiant):
|
def add_parcours(self, scodocParcour: ApcParcours, etudiant: _Etudiant):
|
||||||
parcour_code = parcour.get("code", "TC")
|
parcour_code = scodocParcour.get("code", "TC")
|
||||||
if not parcour_code in self.parcours:
|
if not parcour_code in self.parcours:
|
||||||
self.parcours[parcour_code] = _ParcoursDesc(self.formation, parcour)
|
self.parcours[parcour_code] = _ParcoursDesc(self.formation, scodocParcour)
|
||||||
self.parcours[parcour_code].add(etudiant)
|
self.parcours[parcour_code].add(etudiant)
|
||||||
|
|
||||||
def computes_decision(self):
|
def computes_decision(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def make_excel(self, filename: str):
|
def make_excel(self, filename: str):
|
||||||
for parcours in self.parcours:
|
workbook = ScoExcelBook()
|
||||||
data = self.parcours[parcours].getData()
|
for parcoursCode, parcours in self.parcours.items():
|
||||||
|
parcours.generate(workbook)
|
||||||
|
|
||||||
mime, suffix = scu.get_mime_suffix("xlsx")
|
mime, suffix = scu.get_mime_suffix("xlsx")
|
||||||
return scu.send_file(data, filename=filename, mime=mime, suffix=suffix)
|
xls = workbook.generate()
|
||||||
|
return scu.send_file(xls, filename=filename, mime=mime, suffix=suffix)
|
||||||
|
|
||||||
|
|
||||||
def feuille_preparation_jury_but(formsemestre_id):
|
def feuille_preparation_jury_but(formsemestre_id):
|
||||||
|
Loading…
Reference in New Issue
Block a user