2024-02-08 22:09:11 +01:00
|
|
|
##############################################################################
|
|
|
|
# Module "Avis de poursuite d'étude"
|
|
|
|
# conçu et développé par Cléo Baras (IUT de Grenoble)
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Affichages, debug
|
|
|
|
"""
|
|
|
|
|
2024-02-11 22:06:37 +01:00
|
|
|
from flask import g
|
2024-01-27 08:22:36 +01:00
|
|
|
from app import log
|
|
|
|
|
2024-02-26 12:03:19 +01:00
|
|
|
PE_DEBUG = False
|
2024-01-27 08:22:36 +01:00
|
|
|
|
2024-02-02 11:49:24 +01:00
|
|
|
|
2024-02-11 22:06:37 +01:00
|
|
|
# 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"
|
|
|
|
if PE_DEBUG:
|
2024-02-14 17:00:05 +01:00
|
|
|
msg = " ".join(a)
|
2024-02-11 22:06:37 +01:00
|
|
|
print(msg)
|
|
|
|
else:
|
2024-02-14 17:00:05 +01:00
|
|
|
lines = getattr(g, "scodoc_pe_log")
|
|
|
|
if lines is None:
|
|
|
|
lines = pe_start_log()
|
|
|
|
msg = " ".join(a)
|
|
|
|
lines.append(msg)
|
2024-02-11 22:06:37 +01:00
|
|
|
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", []))
|
|
|
|
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-02 06:11:21 +01:00
|
|
|
# Affichage dans le tableur pe en cas d'absence de notes
|
|
|
|
SANS_NOTE = "-"
|
2024-02-26 10:29:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
def aff_profil_coeffs(matrice_coeffs_moy_gen, with_index=False):
|
|
|
|
"""Affiche les différents types de coefficients (appelés profil)
|
|
|
|
d'une matrice_coeffs_moy_gen (pour debug)
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Les profils des coeffs d'UE (pour debug)
|
|
|
|
profils = []
|
|
|
|
index_a_profils = {}
|
|
|
|
for i in matrice_coeffs_moy_gen.index:
|
|
|
|
val = matrice_coeffs_moy_gen.loc[i].fillna("-")
|
|
|
|
val = " | ".join([str(v) for v in val])
|
|
|
|
if val not in profils:
|
|
|
|
profils += [val]
|
|
|
|
index_a_profils[val] = [str(i)]
|
|
|
|
else:
|
|
|
|
index_a_profils[val] += [str(i)]
|
|
|
|
|
|
|
|
# L'affichage
|
|
|
|
if len(profils) > 1:
|
|
|
|
if with_index:
|
|
|
|
elmts = [
|
|
|
|
" " * 10
|
|
|
|
+ prof
|
|
|
|
+ " (par ex. "
|
|
|
|
+ ", ".join(index_a_profils[prof][:10])
|
|
|
|
+ ")"
|
|
|
|
for prof in profils
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
elmts = [" " * 10 + prof for prof in profils]
|
|
|
|
profils_aff = "\n" + "\n".join(elmts)
|
|
|
|
else:
|
|
|
|
profils_aff = "\n".join(profils)
|
2024-02-26 12:03:19 +01:00
|
|
|
return profils_aff
|
|
|
|
|
|
|
|
|
|
|
|
def aff_UEs(champs):
|
|
|
|
"""Affiche les UEs"""
|
|
|
|
champs_tries = sorted(champs)
|
|
|
|
aff_comp = []
|
|
|
|
|
|
|
|
for comp in champs_tries:
|
|
|
|
aff_comp += ["📍" + comp]
|
|
|
|
return ", ".join(aff_comp)
|
|
|
|
|
|
|
|
|
|
|
|
def aff_competences(champs):
|
|
|
|
"""Affiche les compétences"""
|
|
|
|
champs_tries = sorted(champs)
|
|
|
|
aff_comp = []
|
|
|
|
|
|
|
|
for comp in champs_tries:
|
|
|
|
aff_comp += ["💡" + comp]
|
|
|
|
return ", ".join(aff_comp)
|
|
|
|
|
|
|
|
|
|
|
|
def aff_tag(tags):
|
|
|
|
"""Affiche les tags"""
|
|
|
|
tags_tries = sorted(tags)
|
|
|
|
aff_tag = ["👜" + tag for tag in tags_tries]
|
|
|
|
return ", ".join(aff_tag)
|