From ca1df8abe51c25b9f3d2effee9c8baa721b9c570 Mon Sep 17 00:00:00 2001 From: jmpla Date: Wed, 31 Jan 2024 07:43:35 +0100 Subject: [PATCH] finalisation statistiques --- app/scodoc/sco_recapcomplet.py | 46 ++++++++++++++++++++++++++++------ app/tables/jury_recap.py | 39 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index d17f37c79..2a58173f4 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -54,7 +54,7 @@ from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre_status from app.scodoc import sco_preferences from app.tables.recap import TableRecap -from app.tables.jury_recap import TableJury +from app.tables.jury_recap import TableJury, StatsLille def formsemestre_recapcomplet( @@ -110,7 +110,12 @@ def formsemestre_recapcomplet( force_publishing=force_publishing, ) - table_html, table, freq_codes_annuels = _formsemestre_recapcomplet_to_html( + ( + table_html, + table, + freq_codes_annuels, + stats_lille, + ) = _formsemestre_recapcomplet_to_html( formsemestre, filename=filename, mode_jury=mode_jury, @@ -180,7 +185,6 @@ def formsemestre_recapcomplet( ) H.append(table_html) # La table - if len(formsemestre.inscriptions) > 0: H.append("""""") # Légende H.append( @@ -295,7 +319,12 @@ def _formsemestre_recapcomplet_to_html( if tabformat not in ("html", "evals"): raise ScoValueError("invalid table format") res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) - table_html, table, freq_codes_annuels = gen_formsemestre_recapcomplet_html_table( + ( + table_html, + table, + freq_codes_annuels, + stats_lille, + ) = gen_formsemestre_recapcomplet_html_table( formsemestre, res, include_evaluations=(tabformat == "evals"), @@ -303,7 +332,7 @@ def _formsemestre_recapcomplet_to_html( filename=filename, selected_etudid=selected_etudid, ) - return table_html, table, freq_codes_annuels + return table_html, table, freq_codes_annuels, stats_lille def _formsemestre_recapcomplet_to_file( @@ -500,11 +529,12 @@ def gen_formsemestre_recapcomplet_html_table( freq_codes_annuels = ( table.freq_codes_annuels if hasattr(table, "freq_codes_annuels") else None ) - cache_class.set(formsemestre.id, (table_html, freq_codes_annuels)) + stats_lille = table.stats_lille if hasattr(table, "stats_lille") else None + cache_class.set(formsemestre.id, (table_html, freq_codes_annuels, stats_lille)) else: - table_html, freq_codes_annuels = table_html_cached + table_html, freq_codes_annuels, stats_lille = table_html_cached - return table_html, table, freq_codes_annuels + return table_html, table, freq_codes_annuels, stats_lille def _gen_formsemestre_recapcomplet_table( diff --git a/app/tables/jury_recap.py b/app/tables/jury_recap.py index abe11e740..4792b191e 100644 --- a/app/tables/jury_recap.py +++ b/app/tables/jury_recap.py @@ -9,6 +9,8 @@ import collections import time +from enum import Enum + import numpy as np from flask import g, url_for @@ -31,6 +33,14 @@ from app.scodoc import sco_utils as scu from app.tables.recap import RowRecap, TableRecap +class StatsLille(Enum): + TOTAL = ("Effectifs étudiés",) + ABSENTS = ("Etudiants ayant 5 absences ou plus",) + PARFAIT = ("Etudiants ayant toutes leurs UEs",) + DANGER = ("Etudiant ayant la moitié des UEs ou moins",) + ECHEC = ("Etudiants ayant au moins une UE < 8",) + + class TableJury(TableRecap): """Cette table recap reprend les colonnes du tableau recap, sauf les évaluations, et ajoute: @@ -49,6 +59,35 @@ class TableJury(TableRecap): self.rows: list["RowJury"] = self.rows self.res: NotesTableCompat = self.res self.read_only = read_only + # calcul Stats Lille + self.stats_lille = {} + for stat in StatsLille: + self.stats_lille[stat] = 0 + # compute ues_id + ues_columns = [f"moy_ue_{ue.id}" for ue in self.res.ues] + for row in self.rows: + nb_ues_etud_parcours = row.nb_ues_etud_parcours + if nb_ues_etud_parcours is not None: + self.stats_lille[StatsLille.TOTAL] += 1 + nbabs = row.cells["nbabs"].raw_content + nbabsjust = row.cells["nbabsjust"].raw_content + nb_ues_validables = row.nb_ues_validables + nb_ues_lt_8 = 0 + for ue in ues_columns: + if ue in row.cells: + try: + if float(row.cells[ue].raw_content) < 8: + nb_ues_lt_8 += 1 + except ValueError: + pass + if nbabs - nbabsjust > 5: + self.stats_lille[StatsLille.ABSENTS] += 1 + if nb_ues_validables == nb_ues_etud_parcours: + self.stats_lille[StatsLille.PARFAIT] += 1 + if nb_ues_validables * 2 <= nb_ues_etud_parcours: + self.stats_lille[StatsLille.DANGER] += 1 + if nb_ues_lt_8 > 0: + self.stats_lille[StatsLille.ECHEC] += 1 # Stats jury: fréquence de chaque code enregistré self.freq_codes_annuels = collections.Counter() # Ajout colonnes spécifiques à la table jury: