1
0
forked from ScoDoc/ScoDoc

Ajout colonne parcours sur table description semestre

This commit is contained in:
Emmanuel Viennet 2022-05-22 07:02:01 +02:00
parent 40f0bca74d
commit 6030d12aca

View File

@ -40,6 +40,7 @@ from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import Module
from app.models.formsemestre import FormSemestre
from app.models.moduleimpls import ModuleImpl
import app.scodoc.sco_utils as scu
from app.scodoc.sco_utils import ModuleType
import app.scodoc.notesdb as ndb
@ -578,7 +579,9 @@ def fill_formsemestre(sem):
# Description du semestre sous forme de table exportable
def formsemestre_description_table(formsemestre_id, with_evals=False):
def formsemestre_description_table(
formsemestre_id, with_evals=False, with_parcours=False
):
"""Description du semestre sous forme de table exportable
Liste des modules et de leurs coefficients
"""
@ -618,7 +621,7 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
ue_info["Coef._class"] = "ue_coef"
R.append(ue_info)
ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
mod_inscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
moduleimpl_id=M["moduleimpl_id"]
)
enseignants = ", ".join(
@ -629,7 +632,7 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
"Code": M["module"]["code"] or "",
"Module": M["module"]["abbrev"] or M["module"]["titre"],
"_Module_class": "scotext",
"Inscrits": len(ModInscrits),
"Inscrits": len(mod_inscrits),
"Responsable": sco_users.user_info(M["responsable_id"])["nomprenom"],
"_Responsable_class": "scotext",
"Enseignants": enseignants,
@ -648,10 +651,15 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
moduleimpl_id=M["moduleimpl_id"],
),
}
R.append(l)
if M["module"]["coefficient"]:
sum_coef += M["module"]["coefficient"]
if with_parcours:
module = Module.query.get(M["module_id"])
l["parcours"] = ", ".join(sorted([pa.code for pa in module.parcours]))
R.append(l)
if with_evals:
# Ajoute lignes pour evaluations
evals = nt.get_mod_evaluation_etat_list(M["moduleimpl_id"])
@ -676,7 +684,10 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef}
R.append(sums)
columns_ids = ["UE", "Code", "Module", "Coef."]
columns_ids = ["UE", "Code", "Module"]
if with_parcours:
columns_ids += ["parcours"]
columns_ids += ["Coef."]
if sco_preferences.get_preference("bul_show_ects", formsemestre_id):
columns_ids += ["ects"]
columns_ids += ["Inscrits", "Responsable", "Enseignants"]
@ -696,6 +707,7 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
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())
@ -720,21 +732,26 @@ def formsemestre_description_table(formsemestre_id, with_evals=False):
)
def formsemestre_description(formsemestre_id, format="html", with_evals=False):
def formsemestre_description(
formsemestre_id, format="html", with_evals=False, with_parcours=False
):
"""Description du semestre sous forme de table exportable
Liste des modules et de leurs coefficients
"""
with_evals = int(with_evals)
tab = formsemestre_description_table(formsemestre_id, with_evals=with_evals)
tab.html_before_table = """<form name="f" method="get" action="%s">
<input type="hidden" name="formsemestre_id" value="%s"></input>
<input type="checkbox" name="with_evals" value="1" onchange="document.f.submit()" """ % (
request.base_url,
formsemestre_id,
tab = formsemestre_description_table(
formsemestre_id, with_evals=with_evals, with_parcours=with_parcours
)
if with_evals:
tab.html_before_table += "checked"
tab.html_before_table += ">indiquer les évaluations</input></form>"
tab.html_before_table = f"""
<form name="f" method="get" action="{request.base_url}">
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"></input>
<input type="checkbox" name="with_evals" value="1" onchange="document.f.submit()"
{ "checked" if with_evals else "" }
>indiquer les évaluations</input>
<input type="checkbox" name="with_parcours" value="1" onchange="document.f.submit()"
{ "checked" if with_parcours else "" }
>indiquer les parcours BUT</input>
"""
return tab.make_page(format=format)