2024-01-25 17:17:01 +01:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Module "Avis de poursuite d'étude"
|
|
|
|
# conçu et développé par Cléo Baras (IUT de Grenoble)
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
Created on Fri Sep 9 09:15:05 2016
|
|
|
|
|
|
|
|
@author: barasc
|
|
|
|
"""
|
|
|
|
|
|
|
|
# ----------------------------------------------------------
|
|
|
|
# Ensemble des fonctions et des classes
|
|
|
|
# permettant les calculs preliminaires (hors affichage)
|
|
|
|
# a l'edition d'un jury de poursuites d'etudes
|
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
|
|
|
import io
|
|
|
|
import os
|
2024-02-11 22:06:37 +01:00
|
|
|
import time
|
2024-01-25 17:17:01 +01:00
|
|
|
from zipfile import ZipFile
|
|
|
|
|
2024-02-02 06:11:21 +01:00
|
|
|
import numpy as np
|
2024-02-08 22:09:11 +01:00
|
|
|
import pandas as pd
|
2024-02-24 12:21:42 +01:00
|
|
|
import jinja2
|
2024-02-02 06:11:21 +01:00
|
|
|
|
2024-02-20 16:22:22 +01:00
|
|
|
from app.pe.rcss import pe_rcs
|
2024-02-21 20:02:38 +01:00
|
|
|
from app.pe.moys import pe_sxtag
|
2024-02-24 10:48:38 +01:00
|
|
|
|
2024-02-08 22:09:11 +01:00
|
|
|
import app.pe.pe_affichage as pe_affichage
|
2024-02-17 03:30:19 +01:00
|
|
|
import app.pe.pe_etudiant as pe_etudiant
|
2024-02-21 20:02:38 +01:00
|
|
|
from app.pe.moys import (
|
|
|
|
pe_tabletags,
|
|
|
|
pe_ressemtag,
|
|
|
|
pe_sxtag,
|
|
|
|
pe_rcstag,
|
|
|
|
pe_interclasstag,
|
|
|
|
pe_moytag,
|
|
|
|
)
|
2024-02-19 14:50:38 +01:00
|
|
|
import app.pe.pe_rcss_jury as pe_rcss_jury
|
2024-02-27 14:39:14 +01:00
|
|
|
from app.scodoc.sco_utils import *
|
2024-01-25 17:17:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
class JuryPE(object):
|
2024-02-08 22:09:11 +01:00
|
|
|
"""
|
|
|
|
Classe mémorisant toutes les informations nécessaires pour établir un jury de PE, sur la base
|
|
|
|
d'une année de diplôme. De ce semestre est déduit :
|
|
|
|
1. l'année d'obtention du DUT,
|
|
|
|
2. tous les étudiants susceptibles à ce stade (au regard de leur parcours) d'être diplomés.
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-27 17:11:00 +01:00
|
|
|
Les options sont :
|
|
|
|
``
|
|
|
|
options = {
|
|
|
|
"cohorte_restreinte": False,
|
|
|
|
"moyennes_tags": True,
|
|
|
|
"moyennes_ue_res_sae": True,
|
|
|
|
"moyennes_ues_rcues": True,
|
|
|
|
"min_max_moy": False,
|
|
|
|
"synthese_individuelle_etud": False,
|
|
|
|
}
|
|
|
|
|
2024-02-08 22:09:11 +01:00
|
|
|
Args:
|
|
|
|
diplome : l'année d'obtention du diplome BUT et du jury de PE (généralement février XXXX)
|
|
|
|
"""
|
|
|
|
|
2024-02-27 17:11:00 +01:00
|
|
|
def __init__(self, diplome: int, formsemestre_id_base, options=None):
|
2024-02-11 22:06:37 +01:00
|
|
|
pe_affichage.pe_start_log()
|
2024-01-25 17:17:01 +01:00
|
|
|
self.diplome = diplome
|
2024-01-26 10:18:46 +01:00
|
|
|
"L'année du diplome"
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-27 17:11:00 +01:00
|
|
|
self.formsemestre_id_base = formsemestre_id_base
|
|
|
|
"""L'identifiant du formsemestre ayant servi à lancer le jury"""
|
|
|
|
|
2024-01-25 21:54:22 +01:00
|
|
|
self.nom_export_zip = f"Jury_PE_{self.diplome}"
|
2024-01-26 10:18:46 +01:00
|
|
|
"Nom du zip où ranger les fichiers générés"
|
|
|
|
|
2024-02-27 17:11:00 +01:00
|
|
|
# Les options
|
|
|
|
self.options = options
|
2024-02-27 18:00:06 +01:00
|
|
|
"""Options de configuration (cf. pe_sem_recap)"""
|
2024-02-27 17:11:00 +01:00
|
|
|
|
2024-02-11 22:06:37 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:58:15 +01:00
|
|
|
f"Données de poursuite d'étude générées le {time.strftime('%d/%m/%Y à %H:%M')}\n",
|
|
|
|
info=True,
|
2024-02-11 22:06:37 +01:00
|
|
|
)
|
2024-02-27 17:11:00 +01:00
|
|
|
|
|
|
|
pe_affichage.pe_print("Options", info=True)
|
|
|
|
for cle, val in self.options.items():
|
|
|
|
pe_affichage.pe_print(f" > {cle} -> {val}", info=True)
|
|
|
|
|
2024-02-11 22:06:37 +01:00
|
|
|
# Chargement des étudiants à prendre en compte dans le jury
|
2024-01-27 12:21:21 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:58:15 +01:00
|
|
|
f"""***********************************************************"""
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"""*** Recherche des étudiants diplômés 🎓 en {self.diplome}""", info=True
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:39:14 +01:00
|
|
|
f"""***********************************************************"""
|
2024-01-27 12:21:21 +01:00
|
|
|
)
|
2024-02-25 12:45:58 +01:00
|
|
|
|
|
|
|
# Les infos sur les étudiants
|
|
|
|
self.etudiants = pe_etudiant.EtudiantsJuryPE(self.diplome)
|
|
|
|
"""Les informations sur les étudiants du jury PE"""
|
2024-02-14 15:19:21 +01:00
|
|
|
self.etudiants.find_etudiants()
|
2024-01-27 12:21:21 +01:00
|
|
|
self.diplomes_ids = self.etudiants.diplomes_ids
|
2024-01-27 10:13:04 +01:00
|
|
|
|
2024-02-27 14:39:14 +01:00
|
|
|
self.rcss_jury = pe_rcss_jury.RCSsJuryPE(self.diplome, self.etudiants)
|
2024-02-18 19:24:03 +01:00
|
|
|
"""Les informations sur les regroupements de semestres"""
|
|
|
|
|
2024-01-27 12:21:21 +01:00
|
|
|
self.zipdata = io.BytesIO()
|
2024-01-26 10:18:46 +01:00
|
|
|
with ZipFile(self.zipdata, "w") as zipfile:
|
2024-01-27 10:13:04 +01:00
|
|
|
if not self.diplomes_ids:
|
2024-02-27 14:58:15 +01:00
|
|
|
pe_affichage.pe_print("*** Aucun étudiant diplômé", info=True)
|
2024-01-27 10:13:04 +01:00
|
|
|
else:
|
2024-02-19 14:50:38 +01:00
|
|
|
try:
|
|
|
|
self._gen_xls_diplomes(zipfile)
|
|
|
|
self._gen_xls_ressembuttags(zipfile)
|
2024-02-20 16:22:22 +01:00
|
|
|
self._gen_trajectoires()
|
|
|
|
self._gen_semXs()
|
2024-02-19 14:50:38 +01:00
|
|
|
self._gen_xls_sxtags(zipfile)
|
2024-02-20 20:52:44 +01:00
|
|
|
self._gen_rcsemxs()
|
|
|
|
self._gen_xls_rcstags(zipfile)
|
2024-02-21 20:02:38 +01:00
|
|
|
self._gen_xls_interclasstags(zipfile)
|
|
|
|
self._gen_xls_synthese_jury_par_tag(zipfile)
|
2024-02-24 10:48:38 +01:00
|
|
|
self._gen_html_synthese_par_etudiant(zipfile)
|
2024-02-19 14:50:38 +01:00
|
|
|
except Exception as e:
|
|
|
|
raise e
|
2024-02-11 22:06:37 +01:00
|
|
|
# et le log
|
|
|
|
self._add_log_to_zip(zipfile)
|
2024-02-02 11:49:24 +01:00
|
|
|
|
2024-01-27 12:21:21 +01:00
|
|
|
# Fin !!!! Tada :)
|
2024-01-26 10:18:46 +01:00
|
|
|
|
2024-01-27 12:21:21 +01:00
|
|
|
def _gen_xls_diplomes(self, zipfile: ZipFile):
|
|
|
|
"Intègre le bilan des semestres taggués au zip"
|
|
|
|
output = io.BytesIO()
|
|
|
|
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)
|
|
|
|
df_diplome.to_excel(writer, onglet, index=True, header=True)
|
|
|
|
if self.etudiants.abandons_ids:
|
|
|
|
onglet = "redoublants-réorientés"
|
|
|
|
df_abandon = self.etudiants.df_administratif(
|
|
|
|
self.etudiants.abandons_ids
|
2024-01-27 10:13:04 +01:00
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
df_abandon.to_excel(writer, onglet, index=True, header=True)
|
|
|
|
output.seek(0)
|
|
|
|
|
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile,
|
|
|
|
f"etudiants_{self.diplome}.xlsx",
|
|
|
|
output.read(),
|
|
|
|
path="details",
|
|
|
|
)
|
|
|
|
|
2024-02-17 02:35:43 +01:00
|
|
|
def _gen_xls_ressembuttags(self, zipfile: ZipFile):
|
|
|
|
"""Calcule les moyennes par tag des résultats des Semestres BUT"""
|
2024-02-17 03:30:19 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:58:15 +01:00
|
|
|
f"""*************************************************************************"""
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"""*** Génère les ResSemBUTTag (ResSemestreBUT taggués)""", info=True
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 12:45:58 +01:00
|
|
|
f"""*************************************************************************"""
|
2024-02-17 03:30:19 +01:00
|
|
|
)
|
2024-02-17 02:35:43 +01:00
|
|
|
|
2024-02-25 12:45:58 +01:00
|
|
|
# Tous les formsestres des étudiants
|
2024-02-17 02:35:43 +01:00
|
|
|
formsemestres = get_formsemestres_etudiants(self.etudiants)
|
2024-02-27 14:58:15 +01:00
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"1) Génère les {len(formsemestres)} ResSemBUTTag", info=True
|
|
|
|
)
|
2024-02-17 02:35:43 +01:00
|
|
|
|
2024-02-17 03:30:19 +01:00
|
|
|
self.ressembuttags = {}
|
2024-02-17 02:35:43 +01:00
|
|
|
for frmsem_id, formsemestre in formsemestres.items():
|
|
|
|
# Crée le semestre_tag et exécute les calculs de moyennes
|
2024-02-27 17:11:00 +01:00
|
|
|
ressembuttag = pe_ressemtag.ResSemBUTTag(formsemestre, options=self.options)
|
2024-02-27 14:39:14 +01:00
|
|
|
self.ressembuttags[frmsem_id] = ressembuttag
|
|
|
|
# Ajoute les étudiants découverts dans les ressembuttags aux données des étudiants
|
|
|
|
# nbre_etudiants_ajoutes = self.etudiants.add_etudiants(
|
|
|
|
# ressembuttag.etudids_sorted
|
|
|
|
# )
|
|
|
|
# if nbre_etudiants_ajoutes:
|
|
|
|
# pe_affichage.pe_print(
|
|
|
|
# f"--> Ajout de {nbre_etudiants_ajoutes} étudiants aux données du jury"
|
|
|
|
# )
|
2024-01-27 12:21:21 +01:00
|
|
|
|
|
|
|
# Intègre le bilan des semestres taggués au zip final
|
2024-02-27 14:58:15 +01:00
|
|
|
pe_affichage.pe_print(f"2) Bilan", info=True)
|
2024-01-27 12:21:21 +01:00
|
|
|
output = io.BytesIO()
|
|
|
|
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
|
|
|
output, engine="openpyxl"
|
|
|
|
) as writer:
|
2024-02-20 09:13:19 +01:00
|
|
|
onglets = []
|
2024-02-17 02:35:43 +01:00
|
|
|
for res_sem_tag in self.ressembuttags.values():
|
2024-02-27 16:18:08 +01:00
|
|
|
onglet = res_sem_tag.get_repr(verbose=True)
|
|
|
|
onglet = onglet.replace("Semestre ", "S")
|
|
|
|
onglets += ["📊" + onglet]
|
|
|
|
df = res_sem_tag.to_df()
|
|
|
|
# Conversion colonnes en multiindex
|
|
|
|
df = convert_colonnes_to_multiindex(df)
|
|
|
|
# écriture dans l'onglet
|
|
|
|
df.to_excel(writer, onglet, index=True, header=True)
|
2024-02-27 14:58:15 +01:00
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"--> Export excel de {', '.join(onglets)}", info=True
|
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
output.seek(0)
|
|
|
|
|
2024-02-16 16:07:48 +01:00
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile,
|
2024-02-17 02:35:43 +01:00
|
|
|
f"ResSemBUTTags_{self.diplome}.xlsx",
|
2024-02-16 16:07:48 +01:00
|
|
|
output.read(),
|
|
|
|
path="details",
|
|
|
|
)
|
|
|
|
|
2024-02-20 16:22:22 +01:00
|
|
|
def _gen_trajectoires(self):
|
|
|
|
"""Génère l'ensemble des trajectoires (RCS), qui traduisent les différents
|
|
|
|
chemins au sein des (form)semestres pour atteindre la cible d'un
|
|
|
|
RCS (par ex: 'S2' ou '3S').
|
2024-02-16 16:07:48 +01:00
|
|
|
"""
|
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:58:15 +01:00
|
|
|
"***************************************************************************"
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"*** Génère les trajectoires (≠tes combinaisons de semestres) des étudiants",
|
|
|
|
info=True,
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 16:25:28 +01:00
|
|
|
"***************************************************************************"
|
2024-02-16 16:07:48 +01:00
|
|
|
)
|
2024-02-18 19:24:03 +01:00
|
|
|
|
2024-02-27 14:39:14 +01:00
|
|
|
self.rcss_jury.cree_trajectoires()
|
|
|
|
pe_affichage.aff_trajectoires_suivies_par_etudiants(self.etudiants)
|
2024-02-16 16:07:48 +01:00
|
|
|
|
2024-02-20 16:22:22 +01:00
|
|
|
def _gen_semXs(self):
|
|
|
|
"""Génère les SemXs (trajectoires/combinaisons de semestre de même rang x)
|
|
|
|
qui traduisent les différents chemins des étudiants pour valider un semestre Sx.
|
|
|
|
"""
|
2024-02-19 14:50:38 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 14:58:15 +01:00
|
|
|
"***************************************************************************"
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"*** Génère les SemXs (RCS de même Sx donnant lieu à validation du semestre)",
|
|
|
|
info=True,
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"***************************************************************************"
|
2024-02-19 14:50:38 +01:00
|
|
|
)
|
2024-02-27 14:58:15 +01:00
|
|
|
|
|
|
|
# Génère les regroupements de semestres de type Sx
|
|
|
|
|
2024-02-27 14:39:14 +01:00
|
|
|
self.rcss_jury.cree_semxs()
|
|
|
|
pe_affichage.aff_semXs_suivis_par_etudiants(self.etudiants)
|
2024-02-18 19:24:03 +01:00
|
|
|
|
2024-02-20 09:13:19 +01:00
|
|
|
def _gen_xls_sxtags(self, zipfile: ZipFile):
|
|
|
|
"""Génère les semestres taggués en s'appuyant sur les RCF de type Sx (pour
|
|
|
|
identifier les redoublements impactant les semestres taggués).
|
|
|
|
"""
|
2024-02-16 16:07:48 +01:00
|
|
|
# Génère les moyennes des RCS de type Sx
|
2024-02-20 16:22:22 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 16:18:08 +01:00
|
|
|
"***************************************************************************"
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"*** Calcule les moyennes des SxTag (moyennes d'un RCS de type Sx)",
|
|
|
|
info=True,
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 16:25:28 +01:00
|
|
|
"***************************************************************************"
|
2024-02-20 16:22:22 +01:00
|
|
|
)
|
2024-02-17 02:35:43 +01:00
|
|
|
|
2024-02-18 19:24:03 +01:00
|
|
|
# Les SxTag (moyenne de Sx par UE)
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("1) Calcul des moyennes", info=True)
|
2024-02-17 02:35:43 +01:00
|
|
|
self.sxtags = {}
|
2024-02-20 16:22:22 +01:00
|
|
|
for rcf_id, rcf in self.rcss_jury.semXs.items():
|
2024-02-18 19:24:03 +01:00
|
|
|
# SxTag traduisant le RCF
|
|
|
|
sxtag_id = rcf_id
|
2024-02-19 14:50:38 +01:00
|
|
|
self.sxtags[sxtag_id] = pe_sxtag.SxTag(sxtag_id, rcf, self.ressembuttags)
|
2024-02-16 16:07:48 +01:00
|
|
|
|
|
|
|
# Intègre le bilan des semestres taggués au zip final
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("2) Bilan", info=True)
|
2024-02-16 16:07:48 +01:00
|
|
|
output = io.BytesIO()
|
|
|
|
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
2024-02-17 03:30:19 +01:00
|
|
|
output, engine="openpyxl"
|
2024-02-16 16:07:48 +01:00
|
|
|
) as writer:
|
2024-02-20 09:13:19 +01:00
|
|
|
onglets = []
|
2024-02-18 19:24:03 +01:00
|
|
|
for sxtag in self.sxtags.values():
|
2024-02-21 20:02:38 +01:00
|
|
|
if sxtag.is_significatif():
|
2024-02-27 16:18:08 +01:00
|
|
|
onglet = sxtag.get_repr(verbose=False)
|
|
|
|
onglets += ["📊" + onglet]
|
|
|
|
df = sxtag.to_df()
|
|
|
|
# Conversion colonnes en multiindex
|
|
|
|
df = convert_colonnes_to_multiindex(df)
|
2024-02-27 14:39:14 +01:00
|
|
|
|
2024-02-27 16:18:08 +01:00
|
|
|
# écriture dans l'onglet
|
|
|
|
df.to_excel(writer, onglet, index=True, header=True)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"--> Export excel de {', '.join(onglets)}", info=True
|
|
|
|
)
|
2024-02-20 09:13:19 +01:00
|
|
|
|
2024-02-16 16:07:48 +01:00
|
|
|
output.seek(0)
|
2024-02-21 20:02:38 +01:00
|
|
|
if onglets:
|
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile,
|
|
|
|
f"semestres_taggues_{self.diplome}.xlsx",
|
|
|
|
output.read(),
|
|
|
|
path="details",
|
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
|
2024-02-20 16:22:22 +01:00
|
|
|
def _gen_rcsemxs(self):
|
2024-02-18 19:24:03 +01:00
|
|
|
"""Génère les regroupements cohérents de RCFs qu'ont suivi chaque étudiant"""
|
|
|
|
|
2024-02-19 14:50:38 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 16:18:08 +01:00
|
|
|
"""******************************************************************************"""
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 12:45:58 +01:00
|
|
|
"""*** Génère les RCSemX (regroupements cohérents de données extraites des SemX)\n"""
|
2024-02-27 16:18:08 +01:00
|
|
|
"""*** amenant du S1 à un semestre final""",
|
|
|
|
info=True,
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 12:45:58 +01:00
|
|
|
"""******************************************************************************"""
|
2024-02-19 14:50:38 +01:00
|
|
|
)
|
2024-02-27 18:00:06 +01:00
|
|
|
self.rcss_jury.cree_rcsemxs(options=self.options)
|
|
|
|
if "moyennes_ues_rcues" in self.options and self.options["moyennes_ues_rcues"]:
|
|
|
|
pe_affichage.aff_rcsemxs_suivis_par_etudiants(self.etudiants)
|
2024-02-18 19:24:03 +01:00
|
|
|
|
2024-02-20 20:52:44 +01:00
|
|
|
def _gen_xls_rcstags(self, zipfile: ZipFile):
|
2024-02-18 19:24:03 +01:00
|
|
|
"""Génère les RCS taggués traduisant les moyennes (orientées compétences)
|
|
|
|
de regroupements de semestre de type Sx, xA ou xS.
|
2024-02-15 17:05:03 +01:00
|
|
|
|
|
|
|
Stocke le résultat dans self.rccs_tag, un dictionnaire de
|
2024-02-17 02:35:43 +01:00
|
|
|
la forme ``{nom_aggregat: {fid_terminal: RCSTag(fid_terminal)} }``
|
2024-02-15 17:05:03 +01:00
|
|
|
|
|
|
|
Pour rappel : Chaque RCS est identifié par un nom d'aggrégat et par un formsemestre terminal.
|
|
|
|
|
|
|
|
Par exemple :
|
|
|
|
|
|
|
|
* combinaisons '3S' : S1+S2+S3 en prenant en compte tous les S3 qu'ont fréquenté les
|
|
|
|
étudiants du jury PE. Ces S3 marquent les formsemestre terminal de chaque combinaison.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
etudiants: Les données des étudiants
|
|
|
|
semestres_tag: Les semestres tag (pour lesquels des moyennes par tag ont été calculés)
|
2024-01-27 12:21:21 +01:00
|
|
|
"""
|
|
|
|
|
2024-02-16 16:07:48 +01:00
|
|
|
# Génère les moyennes des RCS de type Sx
|
2024-02-25 12:45:58 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 16:18:08 +01:00
|
|
|
"""****************************************************"""
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"""*** Génère les moyennes associées aux RCSemX""", info=True
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 12:45:58 +01:00
|
|
|
"""****************************************************"""
|
|
|
|
)
|
2024-02-15 17:05:03 +01:00
|
|
|
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("1) Calcul des moyennes des RCSTag", info=True)
|
2024-02-27 18:00:06 +01:00
|
|
|
if not self.rcss_jury.rcsemxs:
|
|
|
|
if (
|
|
|
|
"moyennes_ues_rcues" in self.options
|
|
|
|
and not self.options["moyennes_ues_rcues"]
|
|
|
|
):
|
|
|
|
pe_affichage.pe_print(" -> Pas de RCSemX à calculer (cf. options)")
|
|
|
|
else:
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
" -> Pas de RCSemX à calculer (alors qu'aucune option ne les limite) => problème"
|
|
|
|
)
|
|
|
|
self.rcsstags = {}
|
|
|
|
return
|
|
|
|
|
|
|
|
# Calcul des RCSTags sur la base des RCSemX
|
2024-02-26 10:29:45 +01:00
|
|
|
self.rcsstags = {}
|
2024-02-20 20:52:44 +01:00
|
|
|
for rcs_id, rcsemx in self.rcss_jury.rcsemxs.items():
|
2024-02-26 10:29:45 +01:00
|
|
|
self.rcsstags[rcs_id] = pe_rcstag.RCSemXTag(
|
|
|
|
rcsemx, self.sxtags, self.rcss_jury.semXs_suivis
|
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
|
|
|
|
# Intègre le bilan des trajectoires tagguées au zip final
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("2) Bilan", info=True)
|
2024-01-27 12:21:21 +01:00
|
|
|
output = io.BytesIO()
|
|
|
|
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
|
|
|
output, engine="openpyxl"
|
|
|
|
) as writer:
|
2024-02-20 09:13:19 +01:00
|
|
|
onglets = []
|
2024-02-26 10:29:45 +01:00
|
|
|
for rcs_tag in self.rcsstags.values():
|
2024-02-21 20:02:38 +01:00
|
|
|
if rcs_tag.is_significatif():
|
2024-02-27 16:18:08 +01:00
|
|
|
onglet = rcs_tag.get_repr(verbose=False)
|
|
|
|
onglets += ["📊" + onglet]
|
2024-02-27 14:39:14 +01:00
|
|
|
|
2024-02-27 16:18:08 +01:00
|
|
|
df = rcs_tag.to_df()
|
|
|
|
# Conversion colonnes en multiindex
|
|
|
|
df = convert_colonnes_to_multiindex(df)
|
|
|
|
onglets += ["📊" + onglet]
|
|
|
|
# écriture dans l'onglet
|
|
|
|
df.to_excel(writer, onglet, index=True, header=True)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
f"--> Export excel de {', '.join(onglets)}", info=True
|
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
output.seek(0)
|
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
if onglets:
|
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile,
|
|
|
|
f"RCRCFs_{self.diplome}.xlsx",
|
|
|
|
output.read(),
|
|
|
|
path="details",
|
|
|
|
)
|
|
|
|
|
|
|
|
def _gen_xls_interclasstags(self, zipfile: ZipFile):
|
|
|
|
"""Génère les interclassements sur la promo de diplômés
|
|
|
|
par (nom d') aggrégat
|
|
|
|
en distinguant les interclassements par accronymes d'UEs (sur les SxTag)
|
|
|
|
et ceux par compétences (sur les RCSTag).
|
|
|
|
"""
|
|
|
|
pe_affichage.pe_print(
|
2024-02-25 16:25:28 +01:00
|
|
|
"""******************************************************************"""
|
2024-01-27 12:21:21 +01:00
|
|
|
)
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 18:00:06 +01:00
|
|
|
"""*** Génère les interclassements sur chaque type de RCS/agrégat"""
|
2024-02-27 16:18:08 +01:00
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"""******************************************************************"""
|
|
|
|
)
|
|
|
|
|
2024-02-27 18:00:06 +01:00
|
|
|
if (
|
|
|
|
"moyennes_ues_rcues" not in self.options
|
|
|
|
or self.options["moyennes_ues_rcues"]
|
|
|
|
):
|
|
|
|
self.interclasstags = {
|
|
|
|
pe_moytag.CODE_MOY_UE: {},
|
|
|
|
pe_moytag.CODE_MOY_COMPETENCES: {},
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
self.interclasstags = {pe_moytag.CODE_MOY_UE: {}}
|
2024-02-21 20:02:38 +01:00
|
|
|
|
|
|
|
etudiants_diplomes = self.etudiants.etudiants_diplomes
|
|
|
|
|
2024-02-27 18:00:06 +01:00
|
|
|
# Les interclassements par UE (toujours présents par défaut)
|
2024-02-21 20:02:38 +01:00
|
|
|
for Sx in pe_rcs.TOUS_LES_SEMESTRES:
|
|
|
|
interclass = pe_interclasstag.InterClassTag(
|
|
|
|
Sx,
|
|
|
|
pe_moytag.CODE_MOY_UE,
|
|
|
|
etudiants_diplomes,
|
|
|
|
self.rcss_jury.semXs,
|
|
|
|
self.sxtags,
|
|
|
|
self.rcss_jury.semXs_suivis,
|
|
|
|
)
|
|
|
|
self.interclasstags[pe_moytag.CODE_MOY_UE][Sx] = interclass
|
|
|
|
|
|
|
|
# Les interclassements par compétences
|
2024-02-27 18:00:06 +01:00
|
|
|
if (
|
|
|
|
"moyennes_ues_rcues" not in self.options
|
|
|
|
or self.options["moyennes_ues_rcues"]
|
|
|
|
):
|
|
|
|
for nom_rcs in pe_rcs.TOUS_LES_RCS:
|
|
|
|
interclass = pe_interclasstag.InterClassTag(
|
|
|
|
nom_rcs,
|
|
|
|
pe_moytag.CODE_MOY_COMPETENCES,
|
|
|
|
etudiants_diplomes,
|
|
|
|
self.rcss_jury.rcsemxs,
|
|
|
|
self.rcsstags,
|
|
|
|
self.rcss_jury.rcsemxs_suivis,
|
|
|
|
)
|
|
|
|
self.interclasstags[pe_moytag.CODE_MOY_COMPETENCES][
|
|
|
|
nom_rcs
|
|
|
|
] = interclass
|
2024-01-27 12:21:21 +01:00
|
|
|
|
|
|
|
# Intègre le bilan des aggrégats (interclassé par promo) au zip final
|
|
|
|
output = io.BytesIO()
|
|
|
|
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
|
|
|
output, engine="openpyxl"
|
|
|
|
) as writer:
|
2024-02-20 09:13:19 +01:00
|
|
|
onglets = []
|
2024-02-27 18:00:06 +01:00
|
|
|
for (
|
|
|
|
type_interclass
|
|
|
|
) in self.interclasstags: # Pour les types d'interclassements prévus
|
2024-02-21 20:02:38 +01:00
|
|
|
interclasstag = self.interclasstags[type_interclass]
|
|
|
|
for nom_rcs, interclass in interclasstag.items():
|
|
|
|
if interclass.is_significatif():
|
2024-02-27 16:18:08 +01:00
|
|
|
onglet = interclass.get_repr()
|
|
|
|
onglets += ["📊" + onglet]
|
|
|
|
df = interclass.to_df(cohorte="Promo")
|
|
|
|
# Conversion colonnes en multiindex
|
|
|
|
df = convert_colonnes_to_multiindex(df)
|
|
|
|
onglets += [onglet]
|
|
|
|
# écriture dans l'onglet
|
|
|
|
df.to_excel(writer, onglet, index=True, header=True)
|
|
|
|
pe_affichage.pe_print(f"=> Export excel de {', '.join(onglets)}", info=True)
|
2024-02-20 09:13:19 +01:00
|
|
|
|
2024-01-27 12:21:21 +01:00
|
|
|
output.seek(0)
|
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
if onglets:
|
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile,
|
|
|
|
f"InterClassTags_{self.diplome}.xlsx",
|
|
|
|
output.read(),
|
|
|
|
path="details",
|
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
|
2024-02-02 11:49:24 +01:00
|
|
|
def _gen_xls_synthese_jury_par_tag(self, zipfile: ZipFile):
|
|
|
|
"""Synthèse des éléments du jury PE tag par tag"""
|
2024-02-24 10:48:38 +01:00
|
|
|
pe_affichage.pe_print(
|
2024-02-27 16:18:08 +01:00
|
|
|
"**************************************************************************************"
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"*** Synthèse finale des moyennes par tag et par type de moyennes (UEs ou Compétences)",
|
|
|
|
info=True,
|
|
|
|
)
|
|
|
|
pe_affichage.pe_print(
|
|
|
|
"**************************************************************************************"
|
2024-02-24 10:48:38 +01:00
|
|
|
)
|
2024-01-27 12:21:21 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
self.synthese = {}
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print(" -> Synthèse des données administratives", info=True)
|
2024-02-24 10:48:38 +01:00
|
|
|
self.synthese["administratif"] = self.etudiants.df_administratif(
|
|
|
|
self.diplomes_ids
|
2024-02-02 11:49:24 +01:00
|
|
|
)
|
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
tags = self._do_tags_list(self.interclasstags)
|
|
|
|
for tag in tags:
|
2024-02-27 18:00:06 +01:00
|
|
|
for type_moy in self.interclasstags:
|
2024-02-27 16:18:08 +01:00
|
|
|
self.synthese[(tag, type_moy)] = self.df_tag_type(tag, type_moy)
|
2024-02-02 11:49:24 +01:00
|
|
|
|
|
|
|
# Export des données => mode 1 seule feuille -> supprimé
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("*** Export du jury de synthese par tags", info=True)
|
2024-02-02 11:49:24 +01:00
|
|
|
output = io.BytesIO()
|
|
|
|
with pd.ExcelWriter( # pylint: disable=abstract-class-instantiated
|
|
|
|
output, engine="openpyxl"
|
|
|
|
) as writer:
|
2024-02-20 09:13:19 +01:00
|
|
|
onglets = []
|
2024-02-24 10:48:38 +01:00
|
|
|
for onglet, df in self.synthese.items():
|
|
|
|
# Conversion colonnes en multiindex
|
2024-02-24 12:21:42 +01:00
|
|
|
df_final = df.copy()
|
|
|
|
df_final = convert_colonnes_to_multiindex(df_final)
|
2024-02-24 10:48:38 +01:00
|
|
|
# Nom de l'onglet
|
2024-02-24 09:31:47 +01:00
|
|
|
if isinstance(onglet, tuple):
|
2024-02-27 16:18:08 +01:00
|
|
|
(repr, type_moy) = onglet
|
|
|
|
nom_onglet = onglet[0][: 31 - 7]
|
2024-02-27 14:39:14 +01:00
|
|
|
if type_moy == pe_moytag.CODE_MOY_COMPETENCES:
|
2024-02-27 16:18:08 +01:00
|
|
|
nom_onglet = nom_onglet + " (Comp)"
|
2024-02-24 09:31:47 +01:00
|
|
|
else:
|
2024-02-27 16:18:08 +01:00
|
|
|
nom_onglet = nom_onglet + " (UEs)"
|
2024-02-24 09:31:47 +01:00
|
|
|
else:
|
|
|
|
nom_onglet = onglet
|
|
|
|
onglets += [nom_onglet]
|
2024-02-02 11:49:24 +01:00
|
|
|
# écriture dans l'onglet:
|
2024-02-26 12:03:19 +01:00
|
|
|
df_final = df_final.replace("nan", "")
|
2024-02-24 12:21:42 +01:00
|
|
|
df_final.to_excel(writer, nom_onglet, index=True, header=True)
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print(f"=> Export excel de {', '.join(onglets)}", info=True)
|
2024-02-02 11:49:24 +01:00
|
|
|
output.seek(0)
|
|
|
|
|
2024-02-27 17:11:00 +01:00
|
|
|
if onglets:
|
|
|
|
self.add_file_to_zip(
|
2024-02-27 18:00:06 +01:00
|
|
|
zipfile, f"synthese_jury_{self.diplome}.xlsx", output.read()
|
2024-02-27 17:11:00 +01:00
|
|
|
)
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
def _gen_html_synthese_par_etudiant(self, zipfile: ZipFile):
|
|
|
|
"""Synthèse des éléments du jury PE, étudiant par étudiant"""
|
|
|
|
# Synthèse des éléments du jury PE
|
2024-02-27 16:18:08 +01:00
|
|
|
pe_affichage.pe_print("**************************************************")
|
|
|
|
pe_affichage.pe_print("*** Synthèse finale étudiant par étudiant", info=True)
|
|
|
|
pe_affichage.pe_print("**************************************************")
|
2024-02-24 10:48:38 +01:00
|
|
|
|
2024-02-27 18:00:06 +01:00
|
|
|
if (
|
|
|
|
"moyennes_ues_rcues" not in self.options
|
|
|
|
or self.options["moyennes_ues_rcues"]
|
|
|
|
):
|
|
|
|
etudids = list(self.diplomes_ids)
|
|
|
|
for etudid in etudids:
|
|
|
|
nom, prenom, html = self.synthetise_jury_etudiant(etudid)
|
|
|
|
self.add_file_to_zip(
|
|
|
|
zipfile, f"{nom}_{prenom}.html", html, path="etudiants"
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
pe_affichage.pe_print(" > Pas de synthèse étudiant/étudiant possible/prévu")
|
2024-02-24 10:48:38 +01:00
|
|
|
|
2024-02-11 22:06:37 +01:00
|
|
|
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)
|
|
|
|
|
2024-01-26 10:18:46 +01:00
|
|
|
def add_file_to_zip(self, zipfile: ZipFile, filename: str, data, path=""):
|
|
|
|
"""Add a file to given zip
|
2024-01-25 17:17:01 +01:00
|
|
|
All files under NOM_EXPORT_ZIP/
|
|
|
|
path may specify a subdirectory
|
|
|
|
|
|
|
|
Args:
|
2024-01-26 10:18:46 +01:00
|
|
|
zipfile: ZipFile
|
2024-01-25 17:17:01 +01:00
|
|
|
filename: Le nom du fichier à intégrer au zip
|
|
|
|
data: Les données du fichier
|
|
|
|
path: Un dossier dans l'arborescence du zip
|
|
|
|
"""
|
2024-01-25 19:42:22 +01:00
|
|
|
path_in_zip = os.path.join(path, filename) # self.nom_export_zip,
|
2024-01-26 10:18:46 +01:00
|
|
|
zipfile.writestr(path_in_zip, data)
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-01-26 10:18:46 +01:00
|
|
|
def get_zipped_data(self) -> io.BytesIO | None:
|
2024-01-25 17:17:01 +01:00
|
|
|
"""returns file-like data with a zip of all generated (CSV) files.
|
2024-01-26 10:18:46 +01:00
|
|
|
Warning: reset stream to the begining.
|
2024-01-25 17:17:01 +01:00
|
|
|
"""
|
|
|
|
self.zipdata.seek(0)
|
|
|
|
return self.zipdata
|
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
def _do_tags_list(self, interclassements: dict[str, dict]):
|
2024-01-25 17:17:01 +01:00
|
|
|
"""La liste des tags extraites des interclassements"""
|
|
|
|
tags = []
|
2024-02-21 20:02:38 +01:00
|
|
|
# Pour chaque type d'interclassements
|
|
|
|
for type in interclassements:
|
|
|
|
interclassement = interclassements[type]
|
|
|
|
for aggregat in interclassement:
|
|
|
|
interclass = interclassement[aggregat]
|
|
|
|
if interclass.tags_sorted:
|
|
|
|
tags.extend(interclass.tags_sorted)
|
|
|
|
tags = sorted(set(tags))
|
|
|
|
return tags
|
2024-01-25 17:17:01 +01:00
|
|
|
|
|
|
|
# **************************************************************************************************************** #
|
|
|
|
# Méthodes pour la synthèse du juryPE
|
|
|
|
# *****************************************************************************************************************
|
|
|
|
|
2024-02-27 16:18:08 +01:00
|
|
|
def df_tag_type(self, tag, type_moy):
|
2024-02-21 20:02:38 +01:00
|
|
|
"""Génère le DataFrame synthétisant les moyennes/classements (groupe +
|
|
|
|
interclassement promo) pour tous les aggrégats prévus, en fonction
|
|
|
|
du type (UEs ou Compétences) de données souhaitées,
|
2024-01-25 17:17:01 +01:00
|
|
|
tels que fourni dans l'excel final.
|
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
Si type=UEs => tous les sxtag du tag
|
|
|
|
Si type=Compétences => tous les rcstag du tag
|
|
|
|
|
2024-01-25 17:17:01 +01:00
|
|
|
Args:
|
|
|
|
tag: Un des tags (a minima `but`)
|
2024-02-21 20:02:38 +01:00
|
|
|
type_moy: Un type de moyenne
|
2024-01-25 17:17:01 +01:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
"""
|
|
|
|
|
2024-02-03 15:26:58 +01:00
|
|
|
# Les données des étudiants
|
2024-02-21 20:02:38 +01:00
|
|
|
etuds = [etud for etudid, etud in self.etudiants.etudiants_diplomes.items()]
|
2024-02-27 16:30:00 +01:00
|
|
|
df = pe_tabletags.df_administratif(etuds, aggregat="Administratif", cohorte="")
|
2024-02-21 20:02:38 +01:00
|
|
|
|
|
|
|
if type_moy == pe_moytag.CODE_MOY_UE:
|
|
|
|
aggregats = pe_rcs.TOUS_LES_SEMESTRES
|
|
|
|
else:
|
|
|
|
aggregats = pe_rcs.TOUS_LES_RCS
|
|
|
|
|
2024-02-24 09:31:47 +01:00
|
|
|
aff_aggregat = []
|
2024-02-21 20:02:38 +01:00
|
|
|
for aggregat in aggregats:
|
|
|
|
# Descr de l'aggrégat
|
|
|
|
descr = pe_rcs.TYPES_RCS[aggregat]["descr"]
|
|
|
|
|
|
|
|
# L'interclassement associé
|
|
|
|
interclass = self.interclasstags[type_moy][aggregat]
|
|
|
|
|
|
|
|
if interclass.is_significatif():
|
|
|
|
# Le dataframe du classement sur le groupe
|
|
|
|
df_groupe = interclass.compute_df_synthese_moyennes_tag(
|
2024-02-27 16:18:08 +01:00
|
|
|
tag, aggregat=aggregat, type_colonnes=False
|
2024-02-03 15:26:58 +01:00
|
|
|
)
|
2024-02-24 09:31:47 +01:00
|
|
|
if not df_groupe.empty:
|
|
|
|
aff_aggregat += [aggregat]
|
|
|
|
df = df.join(df_groupe)
|
2024-02-21 20:02:38 +01:00
|
|
|
|
|
|
|
# Le dataframe du classement sur la promo
|
|
|
|
df_promo = interclass.to_df(
|
|
|
|
administratif=False,
|
|
|
|
aggregat=aggregat,
|
|
|
|
tags_cibles=[tag],
|
|
|
|
cohorte="Promo",
|
|
|
|
)
|
2024-02-26 12:03:19 +01:00
|
|
|
|
2024-02-24 09:31:47 +01:00
|
|
|
if not df_promo.empty:
|
|
|
|
aff_aggregat += [aggregat]
|
|
|
|
df = df.join(df_promo)
|
2024-02-03 15:26:58 +01:00
|
|
|
|
2024-02-24 09:31:47 +01:00
|
|
|
if aff_aggregat:
|
|
|
|
pe_affichage.pe_print(
|
2024-02-27 16:18:08 +01:00
|
|
|
f" -> Synthèse de 👜{tag} par {type_moy} avec {', '.join(aff_aggregat)}"
|
2024-02-24 09:31:47 +01:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
pe_affichage.pe_print(f" -> Synthèse du tag {tag} par {type_moy} : <vide>")
|
2024-02-24 10:48:38 +01:00
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
return df
|
|
|
|
# Fin de l'aggrégat
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
def synthetise_jury_etudiant(self, etudid) -> (str, str, str):
|
|
|
|
"""Synthétise les résultats d'un étudiant dans un
|
|
|
|
fichier html à son nom en s'appuyant sur la synthese final
|
2024-02-02 11:49:24 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
Returns:
|
|
|
|
Un tuple nom, prenom, html
|
|
|
|
"""
|
|
|
|
etudiant = self.etudiants.identites[etudid]
|
|
|
|
nom = etudiant.nom
|
|
|
|
prenom = etudiant.prenom # initial du prénom
|
2024-02-27 16:18:08 +01:00
|
|
|
parcours = self.etudiants.cursus[etudid]["parcours"]
|
|
|
|
if not parcours:
|
|
|
|
parcours = "<parcours indéterminé>"
|
2024-02-24 12:21:42 +01:00
|
|
|
|
|
|
|
# Accès au template
|
|
|
|
environnement = jinja2.Environment(
|
|
|
|
loader=jinja2.FileSystemLoader("app/templates/")
|
|
|
|
)
|
|
|
|
template = environnement.get_template("pe/pe_view_resultats_etudiant.j2")
|
|
|
|
|
|
|
|
# Colonnes des tableaux htmls => competences
|
|
|
|
competences = []
|
2024-02-27 16:18:08 +01:00
|
|
|
for aggregat in pe_rcs.TOUS_LES_RCS:
|
2024-02-24 12:21:42 +01:00
|
|
|
# L'interclassement associé
|
|
|
|
interclass = self.interclasstags[pe_moytag.CODE_MOY_COMPETENCES][aggregat]
|
|
|
|
competences.extend(interclass.champs_sorted)
|
|
|
|
competences = sorted(set(competences))
|
|
|
|
colonnes_html = competences
|
2024-02-02 11:49:24 +01:00
|
|
|
|
2024-02-21 20:02:38 +01:00
|
|
|
tags = self._do_tags_list(self.interclasstags)
|
2024-02-24 12:21:42 +01:00
|
|
|
|
|
|
|
# Les données par UE
|
|
|
|
moyennes = {}
|
|
|
|
for tag in tags:
|
|
|
|
moyennes[tag] = {}
|
|
|
|
# Les données de synthèse
|
2024-02-27 16:18:08 +01:00
|
|
|
df = self.synthese[(tag, pe_moytag.CODE_MOY_COMPETENCES)]
|
2024-02-25 10:39:51 +01:00
|
|
|
for aggregat in pe_rcs.TOUS_LES_RCS:
|
2024-02-27 14:39:14 +01:00
|
|
|
# moyennes[tag][aggregat] = {}
|
|
|
|
descr = pe_rcs.get_descr_rcs(aggregat)
|
|
|
|
|
|
|
|
moy = {}
|
|
|
|
est_significatif = False
|
2024-02-24 12:21:42 +01:00
|
|
|
for comp in competences + ["Général"]:
|
2024-02-27 14:39:14 +01:00
|
|
|
moy[comp] = {
|
2024-02-24 12:21:42 +01:00
|
|
|
"note": "",
|
|
|
|
"rang_groupe": "",
|
|
|
|
"rang_promo": "",
|
|
|
|
}
|
|
|
|
colonne = pe_moytag.get_colonne_df(
|
2024-02-27 16:18:08 +01:00
|
|
|
aggregat, tag, comp, "Groupe", "note"
|
2024-02-24 12:21:42 +01:00
|
|
|
)
|
|
|
|
if colonne in df.columns:
|
|
|
|
valeur = df.loc[etudid, colonne]
|
|
|
|
if not np.isnan(valeur):
|
2024-02-27 14:39:14 +01:00
|
|
|
moy[comp]["note"] = round(valeur, 2)
|
|
|
|
est_significatif = True
|
2024-02-27 16:18:08 +01:00
|
|
|
# else:
|
|
|
|
# print(f"{colonne} manquante")
|
2024-02-24 12:21:42 +01:00
|
|
|
colonne = pe_moytag.get_colonne_df(
|
2024-02-27 16:18:08 +01:00
|
|
|
aggregat, tag, comp, "Groupe", "rang"
|
2024-02-24 12:21:42 +01:00
|
|
|
)
|
|
|
|
if colonne in df.columns:
|
|
|
|
valeur = df.loc[etudid, colonne]
|
2024-02-26 12:03:19 +01:00
|
|
|
if valeur and str(valeur) != "nan":
|
2024-02-27 14:39:14 +01:00
|
|
|
moy[comp]["rang_groupe"] = valeur
|
2024-02-24 12:21:42 +01:00
|
|
|
colonne = pe_moytag.get_colonne_df(
|
2024-02-27 16:18:08 +01:00
|
|
|
aggregat, tag, comp, "Promo", "rang"
|
2024-02-24 12:21:42 +01:00
|
|
|
)
|
|
|
|
if colonne in df.columns:
|
|
|
|
valeur = df.loc[etudid, colonne]
|
2024-02-26 12:03:19 +01:00
|
|
|
if valeur and str(valeur) != "nan":
|
2024-02-27 14:39:14 +01:00
|
|
|
moy[comp]["rang_promo"] = valeur
|
|
|
|
|
|
|
|
if est_significatif:
|
|
|
|
moyennes[tag][descr] = moy
|
2024-02-24 12:21:42 +01:00
|
|
|
|
|
|
|
html = template.render(
|
|
|
|
nom=nom,
|
|
|
|
prenom=prenom,
|
2024-02-27 16:18:08 +01:00
|
|
|
parcours=parcours,
|
2024-02-24 12:21:42 +01:00
|
|
|
colonnes_html=colonnes_html,
|
|
|
|
tags=tags,
|
|
|
|
moyennes=moyennes,
|
|
|
|
)
|
2024-02-02 11:49:24 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
return (nom, prenom, html)
|
2024-01-25 17:17:01 +01:00
|
|
|
|
2024-02-08 22:09:11 +01:00
|
|
|
|
2024-02-17 03:30:19 +01:00
|
|
|
def get_formsemestres_etudiants(etudiants: pe_etudiant.EtudiantsJuryPE) -> dict:
|
2024-02-05 12:58:09 +01:00
|
|
|
"""Ayant connaissance des étudiants dont il faut calculer les moyennes pour
|
2024-02-17 02:35:43 +01:00
|
|
|
le jury PE (attribut `self.etudiant_ids) et de leurs trajectoires (semestres
|
|
|
|
parcourus), renvoie un dictionnaire ``{fid: FormSemestre(fid)}``
|
2024-02-05 12:58:09 +01:00
|
|
|
contenant l'ensemble des formsemestres de leurs cursus, dont il faudra calculer
|
|
|
|
la moyenne.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
etudiants: Les étudiants du jury PE
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Un dictionnaire de la forme `{fid: FormSemestre(fid)}`
|
|
|
|
"""
|
|
|
|
semestres = {}
|
|
|
|
for etudid in etudiants.etudiants_ids:
|
2024-02-20 16:22:22 +01:00
|
|
|
for cle in etudiants.cursus[etudid]:
|
2024-02-05 12:58:09 +01:00
|
|
|
if cle.startswith("S"):
|
2024-02-20 16:22:22 +01:00
|
|
|
semestres = semestres | etudiants.cursus[etudid][cle]
|
2024-02-05 12:58:09 +01:00
|
|
|
return semestres
|
2024-02-03 10:46:14 +01:00
|
|
|
|
2024-02-08 22:09:11 +01:00
|
|
|
|
2024-02-24 10:48:38 +01:00
|
|
|
def convert_colonnes_to_multiindex(df):
|
|
|
|
"""Convertit les colonnes d'un df pour obtenir des colonnes
|
|
|
|
multiindex"""
|
|
|
|
colonnes = list(df.columns)
|
|
|
|
colonnes = [tuple(col.split("|")) for col in colonnes]
|
2024-02-27 16:30:00 +01:00
|
|
|
# modifie le nom du semestre par sa descr
|
|
|
|
colonnes_verbose = []
|
|
|
|
for col in colonnes:
|
|
|
|
if col[0] in pe_rcs.TYPES_RCS:
|
2024-02-27 16:35:36 +01:00
|
|
|
descr = pe_rcs.get_descr_rcs(col[0])
|
|
|
|
col_verbose = [descr] + list(col[1:])
|
2024-02-27 16:30:00 +01:00
|
|
|
col_verbose = tuple(col_verbose)
|
|
|
|
else:
|
|
|
|
col_verbose = col
|
|
|
|
colonnes_verbose.append(col)
|
|
|
|
df.columns = pd.MultiIndex.from_tuples(colonnes_verbose)
|
2024-02-24 10:48:38 +01:00
|
|
|
return df
|