forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -98,23 +98,34 @@ class JuryPE(object):
|
||||
self.nom_export_zip = f"Jury_PE_{self.diplome}"
|
||||
"Nom du zip où ranger les fichiers générés"
|
||||
|
||||
self.zipdata = io.BytesIO()
|
||||
|
||||
with ZipFile(self.zipdata, "w") as zipfile:
|
||||
# Chargement des étudiants à prendre en compte dans le jury
|
||||
pe_affichage.pe_print(
|
||||
f"""*** Recherche et chargement des étudiants diplômés en {
|
||||
self.diplome} pour la formation {self.formation_id}"""
|
||||
)
|
||||
self.etudiants = EtudiantsJuryPE(
|
||||
self.diplome
|
||||
) # Les infos sur les étudiants
|
||||
self.etudiants = EtudiantsJuryPE(self.diplome) # Les infos sur les étudiants
|
||||
self.etudiants.find_etudiants(self.formation_id)
|
||||
self.diplomes_ids = self.etudiants.diplomes_ids
|
||||
|
||||
# Intègre le bilan des semestres taggués au zip final
|
||||
self.zipdata = io.BytesIO()
|
||||
with ZipFile(self.zipdata, "w") as zipfile:
|
||||
if not self.diplomes_ids:
|
||||
pe_affichage.pe_print("*** Aucun étudiant diplômé")
|
||||
else:
|
||||
self._gen_xls_diplomes(zipfile)
|
||||
self._gen_xls_semestre_taggues(zipfile)
|
||||
self._gen_xls_trajectoires(zipfile)
|
||||
self._gen_xls_aggregats(zipfile)
|
||||
self._gen_xls_synthese(zipfile)
|
||||
|
||||
# Fin !!!! Tada :)
|
||||
|
||||
def _gen_xls_diplomes(self, zipfile: ZipFile):
|
||||
"Intègre le bilan des semestres taggués au zip"
|
||||
output = io.BytesIO()
|
||||
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
||||
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
||||
output, engine="openpyxl"
|
||||
) as writer:
|
||||
if self.diplomes_ids:
|
||||
onglet = "diplômés"
|
||||
df_diplome = self.etudiants.df_administratif(self.diplomes_ids)
|
||||
@ -134,16 +145,16 @@ class JuryPE(object):
|
||||
path="details",
|
||||
)
|
||||
|
||||
if not self.diplomes_ids:
|
||||
pe_affichage.pe_tools("*** Aucun étudiant diplômé")
|
||||
else:
|
||||
# Génère les semestres taggués (avec le calcul des moyennes) pour le jury PE
|
||||
def _gen_xls_semestre_taggues(self, zipfile: ZipFile):
|
||||
"Génère les semestres taggués (avec le calcul des moyennes) pour le jury PE"
|
||||
pe_affichage.pe_print("*** Génère les semestres taggués")
|
||||
self.semestres_taggues = compute_semestres_tag(self.etudiants)
|
||||
|
||||
# Intègre le bilan des semestres taggués au zip final
|
||||
output = io.BytesIO()
|
||||
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
||||
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
||||
output, engine="openpyxl"
|
||||
) as writer:
|
||||
for formsemestretag in self.semestres_taggues.values():
|
||||
onglet = formsemestretag.nom
|
||||
df = formsemestretag.df_moyennes_et_classements()
|
||||
@ -158,8 +169,10 @@ class JuryPE(object):
|
||||
path="details",
|
||||
)
|
||||
|
||||
# Génère les trajectoires (combinaison de semestres suivis
|
||||
# par un étudiant pour atteindre le semestre final d'un aggrégat)
|
||||
def _gen_xls_trajectoires(self, zipfile: ZipFile):
|
||||
"""Génère les trajectoires (combinaison de semestres suivis
|
||||
par un étudiant pour atteindre le semestre final d'un aggrégat)
|
||||
"""
|
||||
pe_affichage.pe_print(
|
||||
"*** Génère les trajectoires (différentes combinaisons de semestres) des étudiants"
|
||||
)
|
||||
@ -176,7 +189,9 @@ class JuryPE(object):
|
||||
|
||||
# Intègre le bilan des trajectoires tagguées au zip final
|
||||
output = io.BytesIO()
|
||||
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
||||
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
||||
output, engine="openpyxl"
|
||||
) as writer:
|
||||
for trajectoire_tagguee in self.trajectoires_tagguees.values():
|
||||
onglet = trajectoire_tagguee.get_repr()
|
||||
df = trajectoire_tagguee.df_moyennes_et_classements()
|
||||
@ -191,6 +206,8 @@ class JuryPE(object):
|
||||
path="details",
|
||||
)
|
||||
|
||||
def _gen_xls_aggregats(self, zipfile: ZipFile):
|
||||
"""Intègre le bilan des aggrégats (interclassé par promo) au zip"""
|
||||
# Génère les interclassements (par promo et) par (nom d') aggrégat
|
||||
pe_affichage.pe_print("*** Génère les interclassements par aggrégat")
|
||||
self.interclassements_taggues = compute_interclassements(
|
||||
@ -199,7 +216,9 @@ class JuryPE(object):
|
||||
|
||||
# Intègre le bilan des aggrégats (interclassé par promo) au zip final
|
||||
output = io.BytesIO()
|
||||
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
||||
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
||||
output, engine="openpyxl"
|
||||
) as writer:
|
||||
for interclass_tag in self.interclassements_taggues.values():
|
||||
if interclass_tag.significatif: # Avec des notes
|
||||
onglet = interclass_tag.get_repr()
|
||||
@ -215,14 +234,17 @@ class JuryPE(object):
|
||||
path="details",
|
||||
)
|
||||
|
||||
def _gen_xls_synthese(self, zipfile: ZipFile):
|
||||
"""Synthèse des éléments du jury PE"""
|
||||
# Synthèse des éléments du jury PE
|
||||
self.synthese = self.synthetise_juryPE()
|
||||
|
||||
# Export des données => mode 1 seule feuille -> supprimé
|
||||
pe_affichage.pe_print("*** Export du jury de synthese")
|
||||
output = io.BytesIO()
|
||||
|
||||
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
||||
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
||||
output, engine="openpyxl"
|
||||
) as writer:
|
||||
for onglet, df in self.synthese.items():
|
||||
# écriture dans l'onglet:
|
||||
df.to_excel(writer, onglet, index=True, header=True)
|
||||
@ -232,8 +254,6 @@ class JuryPE(object):
|
||||
zipfile, f"synthese_jury_{self.diplome}.xlsx", output.read()
|
||||
)
|
||||
|
||||
# Fin !!!! Tada :)
|
||||
|
||||
def add_file_to_zip(self, zipfile: ZipFile, filename: str, data, path=""):
|
||||
"""Add a file to given zip
|
||||
All files under NOM_EXPORT_ZIP/
|
||||
|
@ -35,14 +35,13 @@
|
||||
|
||||
"""
|
||||
|
||||
from flask import send_file, request
|
||||
from flask import flash, g, redirect, request, send_file, url_for
|
||||
|
||||
from app.models import FormSemestre
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc import html_sco_header
|
||||
from app.scodoc import sco_preferences
|
||||
|
||||
from app.pe import pe_comp
|
||||
from app.pe import pe_jury
|
||||
@ -125,7 +124,6 @@ def pe_view_sem_recap(
|
||||
"""Génération des avis de poursuite d'étude"""
|
||||
if request.method == "GET":
|
||||
return _pe_view_sem_recap_form(formsemestre_id)
|
||||
prefs = sco_preferences.SemPreferences(formsemestre_id=formsemestre_id)
|
||||
|
||||
sem_base = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
if not sem_base.formation.is_apc():
|
||||
@ -142,6 +140,15 @@ def pe_view_sem_recap(
|
||||
diplome = pe_comp.get_annee_diplome_semestre(sem_base)
|
||||
|
||||
jury = pe_jury.JuryPE(diplome, sem_base.formation.formation_id)
|
||||
if not jury.diplomes_ids:
|
||||
flash("aucun étudiant à considérer !")
|
||||
return redirect(
|
||||
url_for(
|
||||
"notes.pe_view_sem_recap",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre_id,
|
||||
)
|
||||
)
|
||||
|
||||
data = jury.get_zipped_data()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user