finalisation statistiques

This commit is contained in:
Jean-Marie Place 2024-01-31 07:43:35 +01:00
parent 04d1fbe272
commit ca1df8abe5
2 changed files with 77 additions and 8 deletions

View File

@ -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("""<div class="links_under_recap"><ul>""")
if not mode_jury:
@ -259,6 +263,26 @@ def formsemestre_recapcomplet(
</tr>"""
)
H.append("""</table>""")
# TODO Convert stats_lille to html
# Convert stats_lille to html
if stats_lille[StatsLille.TOTAL] > 0:
H.append(
f"""
<div><b>Statistiques Lille:</b></div>
<table class="jury_stats_codes">
"""
)
for item in StatsLille:
H.append(
f"""<tr>
<td>{item.value[0]}</td>
<td style="text-align:right">{stats_lille[item]}</td>
<td style="text-align:right">{
(100*stats_lille[item] / stats_lille[StatsLille.TOTAL]):2.1f}%
</td>
</tr>"""
)
H.append("""</table>""")
H.append("""</div>""")
# 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(

View File

@ -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: