1
0
forked from ScoDoc/ScoDoc

Améliore affichage coefs sur tableau bord module

This commit is contained in:
Emmanuel Viennet 2022-01-06 22:42:26 +01:00
parent 1b98e5f8dd
commit 54b714fdbc
5 changed files with 52 additions and 24 deletions

View File

@ -129,9 +129,27 @@ class Module(db.Model):
# à redéfinir les relationships... # à redéfinir les relationships...
return sorted(self.ue_coefs, key=lambda x: x.ue.numero) return sorted(self.ue_coefs, key=lambda x: x.ue.numero)
def ue_coefs_descr(self): def ue_coefs_list(self, include_zeros=True):
"""List of tuples [ (ue_acronyme, coef) ]""" """Liste des coefs vers les UE (pour les modules APC).
return [(c.ue.acronyme, c.coef) for c in self.get_ue_coefs_sorted()] Si include_zeros, liste aussi les UE sans coef (donc nul) de ce semestre.
Result: List of tuples [ (ue, coef) ]
"""
if not self.is_apc():
return []
if include_zeros:
# Toutes les UE du même semestre:
ues_semestre = (
self.formation.ues.filter_by(semestre_idx=self.ue.semestre_idx)
.order_by(UniteEns.numero)
.all()
)
coefs_dict = self.get_ue_coef_dict()
coefs_list = []
for ue in ues_semestre:
coefs_list.append((ue, coefs_dict.get(ue.id, 0.0)))
return coefs_list
# Liste seulement les coefs définis:
return [(c.ue, c.coef) for c in self.get_ue_coefs_sorted()]
class ModuleUECoef(db.Model): class ModuleUECoef(db.Model):

View File

@ -554,9 +554,11 @@ def module_edit(module_id=None):
), ),
] ]
if is_apc: if is_apc:
coefs_descr = a_module.ue_coefs_descr() coefs_lst = a_module.ue_coefs_list()
if coefs_descr: if coefs_lst:
coefs_descr_txt = ", ".join(["%s: %s" % x for x in coefs_descr]) coefs_descr_txt = ", ".join(
[f"{ue.acronyme}: {c}" for (ue, c) in coefs_lst]
)
else: else:
coefs_descr_txt = """<span class="missing_value">non définis</span>""" coefs_descr_txt = """<span class="missing_value">non définis</span>"""
descr += [ descr += [

View File

@ -1119,7 +1119,7 @@ def formsemestre_tableau_modules(
mod_descr = "Module " + (mod.titre or "") mod_descr = "Module " + (mod.titre or "")
if mod.is_apc(): if mod.is_apc():
coef_descr = ", ".join( coef_descr = ", ".join(
[f"{ue_acro}: {co}" for ue_acro, co in mod.ue_coefs_descr()] [f"{ue.acronyme}: {co}" for ue, co in mod.ue_coefs_list()]
) )
if coef_descr: if coef_descr:
mod_descr += " Coefs: " + coef_descr mod_descr += " Coefs: " + coef_descr

View File

@ -156,28 +156,29 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0):
return htmlutils.make_menu("actions", menuEval, alone=True) return htmlutils.make_menu("actions", menuEval, alone=True)
def _ue_coefs_html(coefs_descr) -> str: def _ue_coefs_html(coefs_lst) -> str:
""" """ """ """
max_coef = max([x[1] for x in coefs_descr]) if coefs_descr else 1.0 max_coef = max([x[1] for x in coefs_lst]) if coefs_lst else 1.0
H = """ H = """
<div id="modimpl_coefs"> <div id="modimpl_coefs">
<div>Coefficients vers les UE</div> <div>Coefficients vers les UE</div>
""" """
if coefs_descr: if coefs_lst:
H += f""" H += (
f"""
<div class="coefs_histo" style="--max:{max_coef}"> <div class="coefs_histo" style="--max:{max_coef}">
""" + "\n".join( """
+ "\n".join(
[ [
f"""<div style="--coef:{coef}"><div>{coef}</div>{ue_acronyme}</div>""" f"""<div style="--coef:{coef}"><div>{coef}</div>{ue.acronyme}</div>"""
for ue_acronyme, coef in coefs_descr for ue, coef in coefs_lst
] ]
) )
+ "</div>"
)
else: else:
H += """<div class="missing_value">non définis</span>""" H += """<div class="missing_value">non définis</div>"""
H += """ H += "</div>"
</div>
</div>
"""
return H return H
@ -256,7 +257,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append(scu.icontag("lock32_img", title="verrouillé")) H.append(scu.icontag("lock32_img", title="verrouillé"))
H.append("""</td><td class="fichetitre2">""") H.append("""</td><td class="fichetitre2">""")
if modimpl.module.is_apc(): if modimpl.module.is_apc():
H.append(_ue_coefs_html(modimpl.module.ue_coefs_descr())) H.append(_ue_coefs_html(modimpl.module.ue_coefs_list()))
else: else:
H.append(f"Coef. dans le semestre: {modimpl.module.coefficient}") H.append(f"Coef. dans le semestre: {modimpl.module.coefficient}")
H.append("""</td><td></td></tr>""") H.append("""</td><td></td></tr>""")
@ -323,9 +324,10 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
# #
if not modimpl.check_apc_conformity(): if not modimpl.check_apc_conformity():
H.append( H.append(
"""<ul class="tf-msg"><li class="tf-msg warning conformite">Les poids des évaluations de ce module ne sont pas encore conformes au PN. """<div class="warning conformite">Les poids des évaluations de ce module ne sont
pas encore conformes au PN.
Ses notes ne peuvent pas être prises en compte dans les moyennes d'UE. Ses notes ne peuvent pas être prises en compte dans les moyennes d'UE.
</li></ul>""" </div>"""
) )
# #
if has_expression and nt.expr_diagnostics: if has_expression and nt.expr_diagnostics:

View File

@ -1355,7 +1355,13 @@ div.moduleimpl_type_ressource {
div#modimpl_coefs { div#modimpl_coefs {
position: absolute; position: absolute;
border: 1px solid;
padding-top: 3px;
padding-left: 3px;
padding-right: 5px;
background-color: #d3d3d378;
} }
.coefs_histo{ .coefs_histo{
height: 32px; height: 32px;
display: flex; display: flex;