1
0
forked from ScoDoc/ScoDoc

formsemestre_description:coefs et poids vers UEs

This commit is contained in:
Emmanuel Viennet 2022-09-22 23:25:12 +02:00
parent 8e336b8818
commit 9656f3f37e

View File

@ -38,7 +38,7 @@ from flask_login import current_user
from app import log from app import log
from app.comp import res_sem from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat from app.comp.res_compat import NotesTableCompat
from app.models import Module from app.models import Evaluation, Module
from app.models.formsemestre import FormSemestre from app.models.formsemestre import FormSemestre
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import ModuleType from app.scodoc.sco_utils import ModuleType
@ -606,77 +606,108 @@ def formsemestre_description_table(
0 0
] ]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"]) parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
Mlist = sco_moduleimpl.moduleimpl_withmodule_list( # --- Colonnes à proposer:
formsemestre_id=formsemestre_id, sort_by_ue=True columns_ids = ["UE", "Code", "Module"]
) if with_parcours:
columns_ids += ["parcours"]
if not formsemestre.formation.is_apc():
columns_ids += ["Coef."]
ues = [] # liste des UE, seulement en APC pour les coefs
else:
ues = formsemestre.query_ues().all()
columns_ids += [f"ue_{ue.id}" for ue in ues]
if sco_preferences.get_preference("bul_show_ects", formsemestre_id):
columns_ids += ["ects"]
columns_ids += ["Inscrits", "Responsable", "Enseignants"]
if with_evals:
columns_ids += [
"jour",
"description",
"coefficient",
"evalcomplete_str",
"publish_incomplete_str",
]
titles = {title: title for title in columns_ids}
titles.update({f"ue_{ue.id}": ue.acronyme for ue in ues})
titles["ects"] = "ECTS"
titles["jour"] = "Evaluation"
titles["description"] = ""
titles["coefficient"] = "Coef. éval."
titles["evalcomplete_str"] = "Complète"
titles["parcours"] = "Parcours"
titles["publish_incomplete_str"] = "Toujours Utilisée"
title = f"{parcours.SESSION_NAME.capitalize()} {formsemestre.titre_mois()}"
R = [] R = []
sum_coef = 0 sum_coef = 0
sum_ects = 0 sum_ects = 0
last_ue_id = None last_ue_id = None
for M in Mlist: for modimpl in formsemestre.modimpls_sorted:
# Ligne UE avec ECTS: # Ligne UE avec ECTS:
ue = M["ue"] ue = modimpl.module.ue
if ue["ue_id"] != last_ue_id: if ue.id != last_ue_id:
last_ue_id = ue["ue_id"] last_ue_id = ue.id
if ue["ects"] is None: if ue.ects is None:
ects_str = "-" ects_str = "-"
else: else:
sum_ects += ue["ects"] sum_ects += ue.ects
ects_str = ue["ects"] ects_str = ue.ects
ue_info = { ue_info = {
"UE": ue["acronyme"], "UE": ue.acronyme,
"ects": ects_str, "ects": ects_str,
"Module": ue["titre"], "Module": ue.titre,
"_css_row_class": "table_row_ue", "_css_row_class": "table_row_ue",
} }
if use_ue_coefs: if use_ue_coefs:
ue_info["Coef."] = ue["coefficient"] ue_info["Coef."] = ue.coefficient
ue_info["Coef._class"] = "ue_coef" ue_info["Coef._class"] = "ue_coef"
R.append(ue_info) R.append(ue_info)
mod_inscrits = sco_moduleimpl.do_moduleimpl_inscription_list( mod_inscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
moduleimpl_id=M["moduleimpl_id"] moduleimpl_id=modimpl.id
)
enseignants = ", ".join(
[sco_users.user_info(m["ens_id"])["nomprenom"] for m in M["ens"]]
) )
enseignants = ", ".join(ens.get_prenomnom() for ens in modimpl.enseignants)
l = { l = {
"UE": M["ue"]["acronyme"], "UE": modimpl.module.ue.acronyme,
"Code": M["module"]["code"] or "", "Code": modimpl.module.code or "",
"Module": M["module"]["abbrev"] or M["module"]["titre"], "Module": modimpl.module.abbrev or modimpl.module.titre,
"_Module_class": "scotext", "_Module_class": "scotext",
"Inscrits": len(mod_inscrits), "Inscrits": len(mod_inscrits),
"Responsable": sco_users.user_info(M["responsable_id"])["nomprenom"], "Responsable": sco_users.user_info(modimpl.responsable_id)["nomprenom"],
"_Responsable_class": "scotext", "_Responsable_class": "scotext",
"Enseignants": enseignants, "Enseignants": enseignants,
"_Enseignants_class": "scotext", "_Enseignants_class": "scotext",
"Coef.": M["module"]["coefficient"], "Coef.": modimpl.module.coefficient,
# 'ECTS' : M['module']['ects'], # 'ECTS' : M['module']['ects'],
# Lien sur titre -> module # Lien sur titre -> module
"_Module_target": url_for( "_Module_target": url_for(
"notes.moduleimpl_status", "notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
moduleimpl_id=M["moduleimpl_id"], moduleimpl_id=modimpl.id,
), ),
"_Code_target": url_for( "_Code_target": url_for(
"notes.moduleimpl_status", "notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
moduleimpl_id=M["moduleimpl_id"], moduleimpl_id=modimpl.id,
), ),
} }
if M["module"]["coefficient"]: if modimpl.module.coefficient is not None:
sum_coef += M["module"]["coefficient"] sum_coef += modimpl.module.coefficient
coef_dict = modimpl.module.get_ue_coef_dict()
for ue in ues:
l[f"ue_{ue.id}"] = coef_dict.get(ue.id, 0.0) or ""
if with_parcours: if with_parcours:
module = Module.query.get(M["module_id"]) l["parcours"] = ", ".join(
l["parcours"] = ", ".join(sorted([pa.code for pa in module.parcours])) sorted([pa.code for pa in modimpl.module.parcours])
)
R.append(l) R.append(l)
if with_evals: if with_evals:
# Ajoute lignes pour evaluations # Ajoute lignes pour evaluations
evals = nt.get_mod_evaluation_etat_list(M["moduleimpl_id"]) evals = nt.get_mod_evaluation_etat_list(modimpl.id)
evals.reverse() # ordre chronologique evals.reverse() # ordre chronologique
# Ajoute etat: # Ajoute etat:
for e in evals: for e in evals:
@ -694,45 +725,21 @@ def formsemestre_description_table(
else: else:
e["publish_incomplete_str"] = "Non" e["publish_incomplete_str"] = "Non"
e["_publish_incomplete_str_td_attrs"] = 'style="color: red;"' e["_publish_incomplete_str_td_attrs"] = 'style="color: red;"'
# Poids vers UEs (en APC)
evaluation: Evaluation = Evaluation.query.get(e["evaluation_id"])
for ue_id, poids in evaluation.get_ue_poids_dict().items():
e[f"ue_{ue_id}"] = poids or ""
R += evals R += evals
sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef} sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef}
R.append(sums) R.append(sums)
columns_ids = ["UE", "Code", "Module"]
if with_parcours:
columns_ids += ["parcours"]
if not formsemestre.formation.is_apc():
columns_ids += ["Coef."]
if sco_preferences.get_preference("bul_show_ects", formsemestre_id):
columns_ids += ["ects"]
columns_ids += ["Inscrits", "Responsable", "Enseignants"]
if with_evals:
columns_ids += [
"jour",
"description",
"coefficient",
"evalcomplete_str",
"publish_incomplete_str",
]
titles = {title: title for title in columns_ids}
titles["ects"] = "ECTS"
titles["jour"] = "Evaluation"
titles["description"] = ""
titles["coefficient"] = "Coef. éval."
titles["evalcomplete_str"] = "Complète"
titles["parcours"] = "Parcours"
titles["publish_incomplete_str"] = "Toujours Utilisée"
title = "%s %s" % (parcours.SESSION_NAME.capitalize(), formsemestre.titre_mois())
return GenTable( return GenTable(
columns_ids=columns_ids, columns_ids=columns_ids,
rows=R, rows=R,
titles=titles, titles=titles,
origin="Généré par %s le " % sco_version.SCONAME origin=f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}",
+ scu.timedate_human_repr()
+ "",
caption=title, caption=title,
html_caption=title, html_caption=title,
html_class="table_leftalign formsemestre_description", html_class="table_leftalign formsemestre_description",