forked from ScoDoc/ScoDoc
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
|
##############################################################################
|
||
|
# ScoDoc
|
||
|
# Copyright (c) 1999 - 2021 Emmanuel Viennet. All rights reserved.
|
||
|
# See LICENSE
|
||
|
##############################################################################
|
||
|
|
||
|
"""Résultats semestres BUT
|
||
|
"""
|
||
|
|
||
|
from app.comp import moy_ue, moy_sem, inscr_mod
|
||
|
from app.comp.res_sem import NotesTableCompat
|
||
|
|
||
|
|
||
|
class ResultatsSemestreBUT(NotesTableCompat):
|
||
|
"""Résultats BUT: organisation des calculs"""
|
||
|
|
||
|
_cached_attrs = NotesTableCompat._cached_attrs + (
|
||
|
"modimpl_coefs_df",
|
||
|
"modimpls_evals_poids",
|
||
|
"sem_cube",
|
||
|
)
|
||
|
|
||
|
def __init__(self, formsemestre):
|
||
|
super().__init__(formsemestre)
|
||
|
|
||
|
if not self.load_cached():
|
||
|
self.compute()
|
||
|
self.store()
|
||
|
|
||
|
def compute(self):
|
||
|
"Charge les notes et inscriptions et calcule les moyennes d'UE et gen."
|
||
|
(
|
||
|
self.sem_cube,
|
||
|
self.modimpls_evals_poids,
|
||
|
self.modimpls_results,
|
||
|
) = moy_ue.notes_sem_load_cube(self.formsemestre)
|
||
|
self.modimpl_inscr_df = inscr_mod.df_load_modimpl_inscr(self.formsemestre)
|
||
|
self.modimpl_coefs_df, _, _ = moy_ue.df_load_modimpl_coefs(
|
||
|
self.formsemestre, ues=self.ues, modimpls=self.modimpls
|
||
|
)
|
||
|
# l'idx de la colonne du mod modimpl.id est
|
||
|
# modimpl_coefs_df.columns.get_loc(modimpl.id)
|
||
|
# idx de l'UE: modimpl_coefs_df.index.get_loc(ue.id)
|
||
|
self.etud_moy_ue = moy_ue.compute_ue_moys_apc(
|
||
|
self.sem_cube,
|
||
|
self.etuds,
|
||
|
self.modimpls,
|
||
|
self.ues,
|
||
|
self.modimpl_inscr_df,
|
||
|
self.modimpl_coefs_df,
|
||
|
)
|
||
|
self.etud_moy_gen = moy_sem.compute_sem_moys_apc(
|
||
|
self.etud_moy_ue, self.modimpl_coefs_df
|
||
|
)
|
||
|
self.etud_moy_gen_ranks = moy_sem.comp_ranks_series(self.etud_moy_gen)
|
||
|
|
||
|
def get_etud_mod_moy(self, moduleimpl_id: int, etudid: int) -> float:
|
||
|
"""La moyenne de l'étudiant dans le moduleimpl
|
||
|
En APC, il s'agit d'une moyenne indicative sans valeur.
|
||
|
Result: valeur float (peut être naN) ou chaîne "NI" (non inscrit ou DEM)
|
||
|
"""
|
||
|
mod_idx = self.modimpl_coefs_df.columns.get_loc(moduleimpl_id)
|
||
|
etud_idx = self.etud_index[etudid]
|
||
|
# moyenne sur les UE:
|
||
|
return self.sem_cube[etud_idx, mod_idx].mean()
|