2022-02-21 17:36:50 +01:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2022-02-21 17:36:50 +01:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Calcul des moyennes de matières
|
|
|
|
"""
|
|
|
|
|
|
|
|
# C'est un recalcul (optionnel) effectué _après_ le calcul standard.
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
from app.comp import moy_ue
|
|
|
|
from app.models.formsemestre import FormSemestre
|
|
|
|
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc.codes_cursus import UE_SPORT
|
2022-02-21 17:36:50 +01:00
|
|
|
from app.scodoc.sco_utils import ModuleType
|
|
|
|
|
|
|
|
|
|
|
|
def compute_mat_moys_classic(
|
|
|
|
formsemestre: FormSemestre,
|
|
|
|
sem_matrix: np.array,
|
|
|
|
ues: list,
|
|
|
|
modimpl_inscr_df: pd.DataFrame,
|
|
|
|
modimpl_coefs: np.array,
|
|
|
|
) -> dict:
|
|
|
|
"""Calcul des moyennes par matières.
|
|
|
|
Result: dict, { matiere_id : Series, index etudid }
|
|
|
|
"""
|
|
|
|
modimpls_std = [
|
|
|
|
m
|
|
|
|
for m in formsemestre.modimpls_sorted
|
|
|
|
if (m.module.module_type == ModuleType.STANDARD)
|
|
|
|
and (m.module.ue.type != UE_SPORT)
|
|
|
|
]
|
|
|
|
matiere_ids = {m.module.matiere.id for m in modimpls_std}
|
|
|
|
matiere_moy = {} # { matiere_id : moy pd.Series, index etudid }
|
|
|
|
for matiere_id in matiere_ids:
|
|
|
|
modimpl_mask = np.array(
|
|
|
|
[m.module.matiere.id == matiere_id for m in formsemestre.modimpls_sorted]
|
|
|
|
)
|
2022-02-28 20:02:10 +01:00
|
|
|
etud_moy_mat = moy_ue.compute_mat_moys_classic(
|
2022-02-21 17:36:50 +01:00
|
|
|
sem_matrix=sem_matrix,
|
|
|
|
modimpl_inscr_df=modimpl_inscr_df,
|
|
|
|
modimpl_coefs=modimpl_coefs,
|
|
|
|
modimpl_mask=modimpl_mask,
|
|
|
|
)
|
2022-02-28 20:02:10 +01:00
|
|
|
matiere_moy[matiere_id] = etud_moy_mat
|
2022-02-21 17:36:50 +01:00
|
|
|
return matiere_moy
|