forked from ScoDoc/DocScoDoc
formsemestre_description:coefs et poids vers UEs
This commit is contained in:
parent
8e336b8818
commit
9656f3f37e
@ -38,7 +38,7 @@ from flask_login import current_user
|
||||
from app import log
|
||||
from app.comp import res_sem
|
||||
from app.comp.res_compat import NotesTableCompat
|
||||
from app.models import Module
|
||||
from app.models import Evaluation, Module
|
||||
from app.models.formsemestre import FormSemestre
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
@ -606,77 +606,108 @@ def formsemestre_description_table(
|
||||
0
|
||||
]
|
||||
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
|
||||
Mlist = sco_moduleimpl.moduleimpl_withmodule_list(
|
||||
formsemestre_id=formsemestre_id, sort_by_ue=True
|
||||
)
|
||||
# --- Colonnes à proposer:
|
||||
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 = []
|
||||
sum_coef = 0
|
||||
sum_ects = 0
|
||||
last_ue_id = None
|
||||
for M in Mlist:
|
||||
for modimpl in formsemestre.modimpls_sorted:
|
||||
# Ligne UE avec ECTS:
|
||||
ue = M["ue"]
|
||||
if ue["ue_id"] != last_ue_id:
|
||||
last_ue_id = ue["ue_id"]
|
||||
if ue["ects"] is None:
|
||||
ue = modimpl.module.ue
|
||||
if ue.id != last_ue_id:
|
||||
last_ue_id = ue.id
|
||||
if ue.ects is None:
|
||||
ects_str = "-"
|
||||
else:
|
||||
sum_ects += ue["ects"]
|
||||
ects_str = ue["ects"]
|
||||
sum_ects += ue.ects
|
||||
ects_str = ue.ects
|
||||
ue_info = {
|
||||
"UE": ue["acronyme"],
|
||||
"UE": ue.acronyme,
|
||||
"ects": ects_str,
|
||||
"Module": ue["titre"],
|
||||
"Module": ue.titre,
|
||||
"_css_row_class": "table_row_ue",
|
||||
}
|
||||
if use_ue_coefs:
|
||||
ue_info["Coef."] = ue["coefficient"]
|
||||
ue_info["Coef."] = ue.coefficient
|
||||
ue_info["Coef._class"] = "ue_coef"
|
||||
R.append(ue_info)
|
||||
|
||||
mod_inscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
|
||||
moduleimpl_id=M["moduleimpl_id"]
|
||||
)
|
||||
enseignants = ", ".join(
|
||||
[sco_users.user_info(m["ens_id"])["nomprenom"] for m in M["ens"]]
|
||||
moduleimpl_id=modimpl.id
|
||||
)
|
||||
enseignants = ", ".join(ens.get_prenomnom() for ens in modimpl.enseignants)
|
||||
|
||||
l = {
|
||||
"UE": M["ue"]["acronyme"],
|
||||
"Code": M["module"]["code"] or "",
|
||||
"Module": M["module"]["abbrev"] or M["module"]["titre"],
|
||||
"UE": modimpl.module.ue.acronyme,
|
||||
"Code": modimpl.module.code or "",
|
||||
"Module": modimpl.module.abbrev or modimpl.module.titre,
|
||||
"_Module_class": "scotext",
|
||||
"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",
|
||||
"Enseignants": enseignants,
|
||||
"_Enseignants_class": "scotext",
|
||||
"Coef.": M["module"]["coefficient"],
|
||||
"Coef.": modimpl.module.coefficient,
|
||||
# 'ECTS' : M['module']['ects'],
|
||||
# Lien sur titre -> module
|
||||
"_Module_target": url_for(
|
||||
"notes.moduleimpl_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
moduleimpl_id=M["moduleimpl_id"],
|
||||
moduleimpl_id=modimpl.id,
|
||||
),
|
||||
"_Code_target": url_for(
|
||||
"notes.moduleimpl_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
moduleimpl_id=M["moduleimpl_id"],
|
||||
moduleimpl_id=modimpl.id,
|
||||
),
|
||||
}
|
||||
if M["module"]["coefficient"]:
|
||||
sum_coef += M["module"]["coefficient"]
|
||||
|
||||
if modimpl.module.coefficient is not None:
|
||||
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:
|
||||
module = Module.query.get(M["module_id"])
|
||||
l["parcours"] = ", ".join(sorted([pa.code for pa in module.parcours]))
|
||||
l["parcours"] = ", ".join(
|
||||
sorted([pa.code for pa in modimpl.module.parcours])
|
||||
)
|
||||
|
||||
R.append(l)
|
||||
|
||||
if with_evals:
|
||||
# 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
|
||||
# Ajoute etat:
|
||||
for e in evals:
|
||||
@ -694,45 +725,21 @@ def formsemestre_description_table(
|
||||
else:
|
||||
e["publish_incomplete_str"] = "Non"
|
||||
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
|
||||
|
||||
sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef}
|
||||
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(
|
||||
columns_ids=columns_ids,
|
||||
rows=R,
|
||||
titles=titles,
|
||||
origin="Généré par %s le " % sco_version.SCONAME
|
||||
+ scu.timedate_human_repr()
|
||||
+ "",
|
||||
origin=f"Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}",
|
||||
caption=title,
|
||||
html_caption=title,
|
||||
html_class="table_leftalign formsemestre_description",
|
||||
|
Loading…
Reference in New Issue
Block a user