forked from ScoDoc/ScoDoc
PE: Fix moys (thx @jmpulille). Ajoute log au zip.
This commit is contained in:
parent
6761f5a620
commit
9c15cbe647
@ -6,18 +6,37 @@
|
||||
"""Affichages, debug
|
||||
"""
|
||||
|
||||
from flask import g
|
||||
from app import log
|
||||
|
||||
PE_DEBUG = 0
|
||||
PE_DEBUG = False
|
||||
|
||||
if not PE_DEBUG:
|
||||
# log to notes.log
|
||||
def pe_print(*a, **kw):
|
||||
# kw is ignored. log always add a newline
|
||||
log(" ".join(a))
|
||||
|
||||
# On stocke les logs PE dans g.scodoc_pe_log
|
||||
# pour ne pas modifier les nombreux appels à pe_print.
|
||||
def pe_start_log() -> list[str]:
|
||||
"Initialize log"
|
||||
g.scodoc_pe_log = []
|
||||
return g.scodoc_pe_log
|
||||
|
||||
|
||||
def pe_print(*a):
|
||||
"Log (or print in PE_DEBUG mode) and store in g"
|
||||
lines = getattr(g, "scodoc_pe_log")
|
||||
if lines is None:
|
||||
lines = pe_start_log()
|
||||
msg = " ".join(a)
|
||||
lines.append(msg)
|
||||
if PE_DEBUG:
|
||||
print(msg)
|
||||
else:
|
||||
pe_print = print # print function
|
||||
log(msg)
|
||||
|
||||
|
||||
def pe_get_log() -> str:
|
||||
"Renvoie une chaîne avec tous les messages loggués"
|
||||
return "\n".join(getattr(g, "scodoc_pe_log", []))
|
||||
|
||||
|
||||
# Affichage dans le tableur pe en cas d'absence de notes
|
||||
SANS_NOTE = "-"
|
||||
|
@ -44,6 +44,7 @@ Created on Fri Sep 9 09:15:05 2016
|
||||
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
from zipfile import ZipFile
|
||||
|
||||
import numpy as np
|
||||
@ -70,13 +71,17 @@ class JuryPE(object):
|
||||
"""
|
||||
|
||||
def __init__(self, diplome):
|
||||
pe_affichage.pe_start_log()
|
||||
self.diplome = diplome
|
||||
"L'année du diplome"
|
||||
|
||||
self.nom_export_zip = f"Jury_PE_{self.diplome}"
|
||||
"Nom du zip où ranger les fichiers générés"
|
||||
|
||||
# Chargement des étudiants à prendre en compte Sydans le jury
|
||||
pe_affichage.pe_print(
|
||||
f"Données de poursuite d'étude générées le {time.strftime('%d/%m/%Y à %H:%M')}\n"
|
||||
)
|
||||
# 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}"""
|
||||
@ -96,6 +101,8 @@ class JuryPE(object):
|
||||
self._gen_xls_interclassements_rcss(zipfile)
|
||||
self._gen_xls_synthese_jury_par_tag(zipfile)
|
||||
self._gen_xls_synthese_par_etudiant(zipfile)
|
||||
# et le log
|
||||
self._add_log_to_zip(zipfile)
|
||||
|
||||
# Fin !!!! Tada :)
|
||||
|
||||
@ -251,6 +258,11 @@ class JuryPE(object):
|
||||
zipfile, f"synthese_jury_{self.diplome}_par_etudiant.xlsx", output.read()
|
||||
)
|
||||
|
||||
def _add_log_to_zip(self, zipfile):
|
||||
"""Add a text file with the log messages"""
|
||||
log_data = pe_affichage.pe_get_log()
|
||||
self.add_file_to_zip(zipfile, "pe_log.txt", log_data)
|
||||
|
||||
def add_file_to_zip(self, zipfile: ZipFile, filename: str, data, path=""):
|
||||
"""Add a file to given zip
|
||||
All files under NOM_EXPORT_ZIP/
|
||||
@ -397,7 +409,7 @@ class JuryPE(object):
|
||||
|
||||
# Les moys
|
||||
champ = (descr, NOM_STAT_GROUPE, "moy")
|
||||
moys = moy_traj.get_max()
|
||||
moys = moy_traj.get_moy()
|
||||
donnees.loc[etudids_communs, champ] = moys.loc[etudids_communs]
|
||||
|
||||
# Ajoute les données d'interclassement
|
||||
|
@ -102,11 +102,3 @@ def pe_view_sem_recap(formsemestre_id: int):
|
||||
download_name=scu.sanitize_filename(jury.nom_export_zip + ".zip"),
|
||||
as_attachment=True,
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"pe/pe_view_sem_recap.j2",
|
||||
annee_diplome=annee_diplome,
|
||||
formsemestre=formsemestre,
|
||||
sco=ScoData(formsemestre=formsemestre),
|
||||
cosemestres=cosemestres,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user