Gestion calcul moy gen et capit. BUT si ECTS manquants

This commit is contained in:
Emmanuel Viennet 2022-02-28 11:00:24 +01:00
parent 68680e89d3
commit ef408e5d8e
6 changed files with 20 additions and 19 deletions

View File

@ -30,8 +30,7 @@
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from flask import g, url_for from flask import flash
from app.scodoc.sco_exceptions import ScoValueError
def compute_sem_moys_apc_using_coefs( def compute_sem_moys_apc_using_coefs(
@ -66,12 +65,8 @@ def compute_sem_moys_apc_using_ects(
moy_gen = (etud_moy_ue_df * ects).sum(axis=1) / sum(ects) moy_gen = (etud_moy_ue_df * ects).sum(axis=1) / sum(ects)
except TypeError: except TypeError:
if None in ects: if None in ects:
raise ScoValueError( flash(f"""Calcul moyenne générale impossible: ECTS des UE manquants !""")
f"""Calcul impossible: ECTS des UE manquants ! moy_gen = pd.Series(np.NaN, index=etud_moy_ue_df.index)
voir <a href="{url_for("notes.ue_table", scodoc_dept=g.scodoc_dept,
formation_id=formation_id)}">la page du programme</a>.
"""
)
else: else:
raise raise
return moy_gen return moy_gen

View File

@ -259,9 +259,8 @@ class ResultatsSemestre(ResultatsCache):
cur_moy_ue = self.etud_moy_ue[ue_id][etudid] cur_moy_ue = self.etud_moy_ue[ue_id][etudid]
moy_ue = cur_moy_ue moy_ue = cur_moy_ue
is_capitalized = False # si l'UE prise en compte est une UE capitalisée is_capitalized = False # si l'UE prise en compte est une UE capitalisée
was_capitalized = ( # s'il y a precedemment une UE capitalisée (pas forcement meilleure):
False # s'il y a precedemment une UE capitalisée (pas forcement meilleure) was_capitalized = False
)
if etudid in self.validations.ue_capitalisees.index: if etudid in self.validations.ue_capitalisees.index:
ue_cap = self._get_etud_ue_cap(etudid, ue) ue_cap = self._get_etud_ue_cap(etudid, ue)
if ue_cap and not np.isnan(ue_cap["moy_ue"]): if ue_cap and not np.isnan(ue_cap["moy_ue"]):

View File

@ -54,13 +54,15 @@ class UniteEns(db.Model):
'EXTERNE' if self.is_external else ''})>""" 'EXTERNE' if self.is_external else ''})>"""
def to_dict(self): def to_dict(self):
"""as a dict, with the same conversions as in ScoDoc7""" """as a dict, with the same conversions as in ScoDoc7
(except ECTS: keep None)
"""
e = dict(self.__dict__) e = dict(self.__dict__)
e.pop("_sa_instance_state", None) e.pop("_sa_instance_state", None)
# ScoDoc7 output_formators # ScoDoc7 output_formators
e["ue_id"] = self.id e["ue_id"] = self.id
e["numero"] = e["numero"] if e["numero"] else 0 e["numero"] = e["numero"] if e["numero"] else 0
e["ects"] = e["ects"] if e["ects"] else 0.0 e["ects"] = e["ects"]
e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0 e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0
e["code_apogee"] = e["code_apogee"] or "" # pas de None e["code_apogee"] = e["code_apogee"] or "" # pas de None
return e return e

View File

@ -89,6 +89,7 @@ _ueEditor = ndb.EditableTable(
input_formators={ input_formators={
"type": ndb.int_null_is_zero, "type": ndb.int_null_is_zero,
"is_external": ndb.bool_or_str, "is_external": ndb.bool_or_str,
"ects": ndb.float_null_is_null,
}, },
output_formators={ output_formators={
"numero": ndb.int_null_is_zero, "numero": ndb.int_null_is_zero,
@ -347,6 +348,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
"type": "float", "type": "float",
"title": "ECTS", "title": "ECTS",
"explanation": "nombre de crédits ECTS", "explanation": "nombre de crédits ECTS",
"allow_null": not is_apc, # ects requis en APC
}, },
), ),
( (
@ -933,10 +935,10 @@ def _ue_table_ues(
cur_ue_semestre_id = None cur_ue_semestre_id = None
iue = 0 iue = 0
for ue in ues: for ue in ues:
if ue["ects"]: if ue["ects"] is None:
ue["ects_str"] = ", %g ECTS" % ue["ects"]
else:
ue["ects_str"] = "" ue["ects_str"] = ""
else:
ue["ects_str"] = ", %g ECTS" % ue["ects"]
if editable: if editable:
klass = "span_apo_edit" klass = "span_apo_edit"
else: else:
@ -1295,7 +1297,6 @@ def do_ue_edit(args, bypass_lock=False, dont_invalidate_cache=False):
f"""Acronyme d'UE "{args['acronyme']}" déjà utilisé ! f"""Acronyme d'UE "{args['acronyme']}" déjà utilisé !
(chaque UE doit avoir un acronyme unique dans la formation)""" (chaque UE doit avoir un acronyme unique dans la formation)"""
) )
# On ne peut pas supprimer le code UE: # On ne peut pas supprimer le code UE:
if "ue_code" in args and not args["ue_code"]: if "ue_code" in args and not args["ue_code"]:
del args["ue_code"] del args["ue_code"]

View File

@ -1671,7 +1671,10 @@ div.formation_list_modules ul.notes_module_list {
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
} }
span.missing_ue_ects {
color: red;
font-weight: bold;
}
li.module_malus span.formation_module_tit { li.module_malus span.formation_module_tit {
color: red; color: red;
font-weight: bold; font-weight: bold;

View File

@ -38,7 +38,8 @@
{% set virg = joiner(", ") %} {% set virg = joiner(", ") %}
<span class="ue_code">( <span class="ue_code">(
{%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%} {%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%}
{{ virg() }}{{ue.ects or 0}} ECTS) {{ virg() }}{{ue.ects if ue.ects is not none
else '<span class="missing_ue_ects">aucun</span>'|safe}} ECTS)
</span> </span>
</span> </span>