Assiduites : metrique interne externe

This commit is contained in:
iziram 2023-08-14 10:04:08 +02:00
parent 22cfdc59f1
commit afe2caac2d
10 changed files with 29 additions and 47 deletions

View File

@ -387,11 +387,9 @@ class BulletinBUT:
semestre_infos["absences"] = { semestre_infos["absences"] = {
"injustifie": nbabs - nbabsjust, "injustifie": nbabs - nbabsjust,
"total": nbabs, "total": nbabs,
"metrique": { "metrique": sco_preferences.ASSIDUITES_METRIC_LABEL_LONG.get(
"H.": "Heure(s)", sco_preferences.get_preference("assi_metrique")
"J.": "Journée(s)", ),
"1/2 J.": "1/2 Jour.",
}.get(sco_preferences.get_preference("assi_metrique")),
} }
decisions_ues = self.res.get_etud_decisions_ue(etud.id) or {} decisions_ues = self.res.get_etud_decisions_ue(etud.id) or {}
if self.prefs["bul_show_ects"]: if self.prefs["bul_show_ects"]:

View File

@ -39,11 +39,9 @@ from app.models.validations import ScolarFormSemestreValidation
from app.scodoc import codes_cursus, sco_preferences from app.scodoc import codes_cursus, sco_preferences
from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_utils import MONTH_NAMES_ABBREV, translate_assiduites_metric from app.scodoc.sco_utils import MONTH_NAMES_ABBREV
from app.scodoc.sco_vdi import ApoEtapeVDI from app.scodoc.sco_vdi import ApoEtapeVDI
from app.scodoc.sco_utils import translate_assiduites_metric
GROUPS_AUTO_ASSIGNMENT_DATA_MAX = 1024 * 1024 # bytes GROUPS_AUTO_ASSIGNMENT_DATA_MAX = 1024 * 1024 # bytes
@ -718,10 +716,7 @@ class FormSemestre(db.Model):
metrique = sco_preferences.get_preference("assi_metrique", self.id) metrique = sco_preferences.get_preference("assi_metrique", self.id)
return sco_assiduites.get_assiduites_count_in_interval( return sco_assiduites.get_assiduites_count_in_interval(
etudid, etudid, self.date_debut.isoformat(), self.date_fin.isoformat(), metrique
self.date_debut.isoformat(),
self.date_fin.isoformat(),
translate_assiduites_metric(metrique),
) )
def get_codes_apogee(self, category=None) -> set[str]: def get_codes_apogee(self, category=None) -> set[str]:

View File

@ -122,7 +122,7 @@ def sidebar(etudid: int = None):
nbabs, nbabsjust = sco_assiduites.get_assiduites_count(etudid, cur_sem) nbabs, nbabsjust = sco_assiduites.get_assiduites_count(etudid, cur_sem)
nbabsnj = nbabs - nbabsjust nbabsnj = nbabs - nbabsjust
H.append( H.append(
f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">({sco_preferences.get_preference("assi_metrique", None)}) f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">({sco_preferences.ASSIDUITES_METRIC_LABEL_SHORT.get(sco_preferences.get_preference("assi_metrique", "demi"))})
<br>{ nbabsjust } J., { nbabsnj } N.J.</span>""" <br>{ nbabsjust } J., { nbabsnj } N.J.</span>"""
) )
H.append("<ul>") H.append("<ul>")

View File

@ -66,11 +66,7 @@ def abs_notify(etudid, date):
etudid, etudid,
formsemestre.date_debut.isoformat(), formsemestre.date_debut.isoformat(),
formsemestre.date_fin.isoformat(), formsemestre.date_fin.isoformat(),
scu.translate_assiduites_metric( sco_preferences.get_preference("assi_metrique", formsemestre.formsemestre_id),
sco_preferences.get_preference(
"assi_metrique", formsemestre.formsemestre_id
)
),
) )
do_abs_notify(formsemestre, etudid, date, nbabs, nbabsjust) do_abs_notify(formsemestre, etudid, date, nbabs, nbabsjust)

View File

@ -373,7 +373,7 @@ def get_assiduites_count(etudid, sem):
etudid, etudid,
sem["date_debut_iso"], sem["date_debut_iso"],
sem["date_fin_iso"], sem["date_fin_iso"],
scu.translate_assiduites_metric(metrique), metrique,
) )
@ -427,7 +427,7 @@ def invalidate_assiduites_count(etudid, sem):
"""Invalidate (clear) cached counts""" """Invalidate (clear) cached counts"""
date_debut = sem["date_debut_iso"] date_debut = sem["date_debut_iso"]
date_fin = sem["date_fin_iso"] date_fin = sem["date_fin_iso"]
for met in sco_preferences.ASSIDUITES_METRIC_LABEL.values(): for met in sco_preferences.ASSIDUITES_METRIC_LABEL_SHORT.values():
key = str(etudid) + "_" + date_debut + "_" + date_fin + f"{met}_assiduites" key = str(etudid) + "_" + date_debut + "_" + date_fin + f"{met}_assiduites"
sco_cache.AbsSemEtudCache.delete(key) sco_cache.AbsSemEtudCache.delete(key)

View File

@ -198,11 +198,17 @@ def _get_pref_default_value_from_config(name, pref_spec):
_INSTALLED_FONTS = ", ".join(sco_pdf.get_available_font_names()) _INSTALLED_FONTS = ", ".join(sco_pdf.get_available_font_names())
ASSIDUITES_METRIC_LABEL = { ASSIDUITES_METRIC_LABEL_LONG = {
# l'ordre est important, c'est celui-du menu. Le defaut en 1er donc. # l'ordre est important, c'est celui-du menu. Le defaut en 1er donc.
"1/2 J.": "demi", "demi": "Demi-Journée",
"J.": "journee", "journee": "Journée",
"H.": "heure", "heure": "Heure",
}
ASSIDUITES_METRIC_LABEL_SHORT = {
# l'ordre est important, c'est celui-du menu. Le defaut en 1er donc.
"demi": "1/2 J.",
"journee": "J.",
"heure": "H.",
} }
PREF_CATEGORIES = ( PREF_CATEGORIES = (
@ -664,10 +670,10 @@ class BasePreferences(object):
( (
"assi_metrique", "assi_metrique",
{ {
"initvalue": "1/2 J.", "initvalue": "demi",
"input_type": "menu", "input_type": "menu",
"labels": list(ASSIDUITES_METRIC_LABEL.keys()), "labels": list(ASSIDUITES_METRIC_LABEL_LONG.values()),
"allowed_values": list(ASSIDUITES_METRIC_LABEL.keys()), "allowed_values": list(ASSIDUITES_METRIC_LABEL_LONG.keys()),
"title": "Métrique de l'assiduité", "title": "Métrique de l'assiduité",
"explanation": "Unité utilisée dans la fiche étudiante, les bilans et les calculs", "explanation": "Unité utilisée dans la fiche étudiante, les bilans et les calculs",
"category": "assi", "category": "assi",

View File

@ -251,17 +251,6 @@ def is_period_overlapping(
return p_deb < i_fin and p_fin > i_deb return p_deb < i_fin and p_fin > i_deb
def translate_assiduites_metric(hr_metric) -> str:
if hr_metric == "1/2 J.":
return "demi"
if hr_metric == "J.":
return "journee"
if hr_metric == "N.":
return "compte"
if hr_metric == "H.":
return "heure"
# Types de modules # Types de modules
class ModuleType(IntEnum): class ModuleType(IntEnum):
"""Code des types de module.""" """Code des types de module."""

View File

@ -125,8 +125,8 @@ class RowAssi(tb.Row):
"absent": ["Absences", 0.0, 0.0], "absent": ["Absences", 0.0, 0.0],
} }
assi_metric = sco_preferences.ASSIDUITES_METRIC_LABEL.get( assi_metric = sco_preferences.get_preference(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id) "assi_metrique", dept_id=g.scodoc_dept_id
) )
for etat, valeur in retour.items(): for etat, valeur in retour.items():

View File

@ -79,9 +79,7 @@ class ScoData:
etud.id, etud.id,
self.etud_cur_sem.date_debut.isoformat(), self.etud_cur_sem.date_debut.isoformat(),
self.etud_cur_sem.date_fin.isoformat(), self.etud_cur_sem.date_fin.isoformat(),
scu.translate_assiduites_metric( sco_preferences.get_preference("assi_metrique"),
sco_preferences.get_preference("assi_metrique")
),
) )
self.nbabsnj = self.nbabs - self.nbabsjust self.nbabsnj = self.nbabs - self.nbabsjust
else: else:

View File

@ -327,8 +327,8 @@ def bilan_etud():
date_debut: str = f"{scu.annee_scolaire()}-09-01" date_debut: str = f"{scu.annee_scolaire()}-09-01"
date_fin: str = f"{scu.annee_scolaire()+1}-06-30" date_fin: str = f"{scu.annee_scolaire()+1}-06-30"
assi_metric = sco_preferences.ASSIDUITES_METRIC_LABEL.get( assi_metric = sco_preferences.get_preference(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id) "assi_metrique", dept_id=g.scodoc_dept_id
) )
return HTMLBuilder( return HTMLBuilder(
@ -840,8 +840,8 @@ def visu_assi_group():
return render_template( return render_template(
"assiduites/pages/visu_assi.j2", "assiduites/pages/visu_assi.j2",
assi_metric=sco_preferences.ASSIDUITES_METRIC_LABEL.get( assi_metric=sco_preferences.get_preference(
sco_preferences.get_preference("assi_metrique", dept_id=g.scodoc_dept_id) "assi_metrique", dept_id=g.scodoc_dept_id
), ),
date_debut=dates["debut"], date_debut=dates["debut"],
date_fin=dates["fin"], date_fin=dates["fin"],