This commit is contained in:
Emmanuel Viennet 2023-02-22 00:28:33 +01:00
parent 175b865288
commit e8accaf6a0
2 changed files with 107 additions and 29 deletions

View File

@ -476,6 +476,7 @@ def groups_table(
"bourse_str": "Boursier", "bourse_str": "Boursier",
"etape": "Etape", "etape": "Etape",
"semestre_groupe": "Semestre-Groupe", # pour Moodle "semestre_groupe": "Semestre-Groupe", # pour Moodle
"annee": "annee_admission",
} }
# ajoute colonnes pour groupes # ajoute colonnes pour groupes
@ -770,6 +771,7 @@ def groups_table(
"villelycee", "villelycee",
"codepostallycee", "codepostallycee",
"codelycee", "codelycee",
"annee",
"type_admission", "type_admission",
"boursier_prec", "boursier_prec",
"boursier", "boursier",
@ -793,10 +795,9 @@ def groups_table(
) )
m["parcours"] = Se.get_cursus_descr() m["parcours"] = Se.get_cursus_descr()
m["code_cursus"], _ = sco_report.get_code_cursus_etud(etud) m["code_cursus"], _ = sco_report.get_code_cursus_etud(etud)
rows = [[m.get(k, "") for k in keys] for m in groups_infos.members]
L = [[m.get(k, "") for k in keys] for m in groups_infos.members]
title = "etudiants_%s" % groups_infos.groups_filename title = "etudiants_%s" % groups_infos.groups_filename
xls = sco_excel.excel_simple_table(titles=titles, lines=L, sheet_name=title) xls = sco_excel.excel_simple_table(titles=titles, lines=rows, sheet_name=title)
filename = title filename = title
return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE)
else: else:

View File

@ -84,6 +84,7 @@ def formsemestre_etuds_stats(sem: dict, only_primo=False):
etudid = t[-1] etudid = t[-1]
etudiant: Identite = Identite.query.get(etudid) etudiant: Identite = Identite.query.get(etudid)
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud["annee_admission"] = etud["annee"] # plus explicite
decision = nt.get_etud_decision_sem(etudid) decision = nt.get_etud_decision_sem(etudid)
if decision: if decision:
etud["codedecision"] = decision["code"] etud["codedecision"] = decision["code"]
@ -346,6 +347,7 @@ def formsemestre_report_counts(
"qualite", "qualite",
"villelycee", "villelycee",
"statut", "statut",
"annee_admission",
"type_admission", "type_admission",
"boursier_prec", "boursier_prec",
] ]
@ -419,6 +421,7 @@ def table_suivi_cohorte(
bac="", # selection sur type de bac bac="", # selection sur type de bac
bacspecialite="", bacspecialite="",
annee_bac="", annee_bac="",
annee_admission="",
civilite=None, civilite=None,
statut="", statut="",
only_primo=False, only_primo=False,
@ -457,16 +460,21 @@ def table_suivi_cohorte(
bacs = set() bacs = set()
bacspecialites = set() bacspecialites = set()
annee_bacs = set() annee_bacs = set()
annee_admissions = set()
civilites = set() civilites = set()
statuts = set() statuts = set()
for etudid in etudids: for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud["annee_admission"] = etud["annee"]
bacspe = etud["bac"] + " / " + etud["specialite"] bacspe = etud["bac"] + " / " + etud["specialite"]
# sélection sur bac: # sélection sur bac:
if ( if (
(not bac or (bac == etud["bac"])) (not bac or (bac == etud["bac"]))
and (not bacspecialite or (bacspecialite == bacspe)) and (not bacspecialite or (bacspecialite == bacspe))
and (not annee_bac or (annee_bac == str(etud["annee_bac"]))) and (not annee_bac or (annee_bac == str(etud["annee_bac"])))
and (
not annee_admission or (annee_admission == str(etud["annee_admission"]))
)
and (not civilite or (civilite == etud["civilite"])) and (not civilite or (civilite == etud["civilite"]))
and (not statut or (statut == etud["statut"])) and (not statut or (statut == etud["statut"]))
and (not only_primo or is_primo_etud(etud, sem)) and (not only_primo or is_primo_etud(etud, sem))
@ -481,6 +489,7 @@ def table_suivi_cohorte(
bacs.add(etud["bac"]) bacs.add(etud["bac"])
bacspecialites.add(bacspe) bacspecialites.add(bacspe)
annee_bacs.add(str(etud["annee_bac"])) annee_bacs.add(str(etud["annee_bac"]))
annee_admissions.add(str(etud["annee_admission"]))
civilites.add(etud["civilite"]) civilites.add(etud["civilite"])
if etud["statut"]: # ne montre pas les statuts non renseignés if etud["statut"]: # ne montre pas les statuts non renseignés
statuts.add(etud["statut"]) statuts.add(etud["statut"])
@ -671,6 +680,8 @@ def table_suivi_cohorte(
dbac += " (spécialité %s)" % bacspecialite dbac += " (spécialité %s)" % bacspecialite
if annee_bac: if annee_bac:
dbac += " (année bac %s)" % annee_bac dbac += " (année bac %s)" % annee_bac
if annee_admission:
dbac += " (année admission %s)" % annee_admission
if civilite: if civilite:
dbac += " civilité: %s" % civilite dbac += " civilité: %s" % civilite
if statut: if statut:
@ -707,13 +718,13 @@ def table_suivi_cohorte(
) )
expl.append(", ".join(ls) + "</li>") expl.append(", ".join(ls) + "</li>")
expl.append("</ul>") expl.append("</ul>")
logt("Z: table_suivi_cohorte done")
return ( return (
tab, tab,
"\n".join(expl), "\n".join(expl),
bacs, bacs,
bacspecialites, bacspecialites,
annee_bacs, annee_bacs,
annee_admissions,
civilites, civilites,
statuts, statuts,
) )
@ -726,12 +737,14 @@ def formsemestre_suivi_cohorte(
bac="", bac="",
bacspecialite="", bacspecialite="",
annee_bac="", annee_bac="",
annee_admission="",
civilite=None, civilite=None,
statut="", statut="",
only_primo=False, only_primo=False,
): ):
"""Affiche suivi cohortes par numero de semestre""" """Affiche suivi cohortes par numero de semestre"""
annee_bac = str(annee_bac) annee_bac = str(annee_bac or "")
annee_admission = str(annee_admission or "")
percent = int(percent) percent = int(percent)
( (
tab, tab,
@ -739,6 +752,7 @@ def formsemestre_suivi_cohorte(
bacs, bacs,
bacspecialites, bacspecialites,
annee_bacs, annee_bacs,
annee_admissions,
civilites, civilites,
statuts, statuts,
) = table_suivi_cohorte( ) = table_suivi_cohorte(
@ -747,6 +761,7 @@ def formsemestre_suivi_cohorte(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
only_primo=only_primo, only_primo=only_primo,
@ -795,11 +810,13 @@ def formsemestre_suivi_cohorte(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
bacs=bacs, bacs=bacs,
bacspecialites=bacspecialites, bacspecialites=bacspecialites,
annee_bacs=annee_bacs, annee_bacs=annee_bacs,
annee_admissions=annee_admissions,
civilites=civilites, civilites=civilites,
statuts=statuts, statuts=statuts,
percent=percent, percent=percent,
@ -819,15 +836,19 @@ def _gen_form_selectetuds(
bac=None, bac=None,
bacspecialite=None, bacspecialite=None,
annee_bac=None, annee_bac=None,
annee_admission=None,
civilite=None, civilite=None,
statut=None, statut=None,
bacs=None, bacs=None,
bacspecialites=None, bacspecialites=None,
annee_bacs=None, annee_bacs=None,
annee_admissions=None,
civilites=None, civilites=None,
statuts=None, statuts=None,
): ):
"""HTML form pour choix criteres selection etudiants""" """HTML form pour choix criteres selection etudiants"""
annee_bacs = annee_bacs or []
annee_admissions = annee_admissions or []
bacs = list(bacs) bacs = list(bacs)
bacs.sort(key=scu.heterogeneous_sorting_key) bacs.sort(key=scu.heterogeneous_sorting_key)
bacspecialites = list(bacspecialites) bacspecialites = list(bacspecialites)
@ -835,6 +856,8 @@ def _gen_form_selectetuds(
# on peut avoir un mix de chaines vides et d'entiers: # on peut avoir un mix de chaines vides et d'entiers:
annee_bacs = [int(x) if x else 0 for x in annee_bacs] annee_bacs = [int(x) if x else 0 for x in annee_bacs]
annee_bacs.sort() annee_bacs.sort()
annee_admissions = [int(x) if x else 0 for x in annee_admissions]
annee_admissions.sort()
civilites = list(civilites) civilites = list(civilites)
civilites.sort() civilites.sort()
statuts = list(statuts) statuts = list(statuts)
@ -876,23 +899,13 @@ def _gen_form_selectetuds(
F.append('<option value="%s" %s>%s</option>' % (b, selected, b)) F.append('<option value="%s" %s>%s</option>' % (b, selected, b))
F.append("</select>") F.append("</select>")
# #
if annee_bac:
selected = ""
else:
selected = 'selected="selected"'
F.append( F.append(
"""&nbsp; Année bac: <select name="annee_bac" onchange="javascript: submit(this);"> "&nbsp; Année bac: " + _gen_select_annee("annee_bac", annee_bacs, annee_bac)
<option value="" %s>tous</option> )
""" F.append(
% selected "&nbsp; Année admission: "
+ _gen_select_annee("annee_admission", annee_admissions, annee_admission)
) )
for b in annee_bacs:
if str(annee_bac) == str(b):
selected = 'selected="selected"'
else:
selected = ""
F.append('<option value="%s" %s>%s</option>' % (b, selected, b))
F.append("</select>")
# #
F.append( F.append(
"""&nbsp; Genre: <select name="civilite" onchange="javascript: submit(this);"> """&nbsp; Genre: <select name="civilite" onchange="javascript: submit(this);">
@ -938,11 +951,24 @@ def _gen_form_selectetuds(
return "\n".join(F) return "\n".join(F)
def _gen_select_annee(field, values, value) -> str:
"une menu html select"
menu_html = f"""<select name="{field}" onchange="javascript: submit(this);">
<option value="" {'' if value else 'selected="selected"'}>tous</option>
"""
for val in values:
selected = 'selected="selected"' if str(value) == str(val) else ""
menu_html += f"""<option value="{val}" {selected}>{val}</option>"""
return menu_html + "</select>"
def _descr_etud_set(etudids): def _descr_etud_set(etudids):
"textual html description of a set of etudids" "textual html description of a set of etudids"
etuds = [] etuds = []
for etudid in etudids: for etudid in etudids:
etuds.append(sco_etud.get_etud_info(etudid=etudid, filled=True)[0]) etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud["annee_admission"] = etud["annee"] # plus explicite
etuds.append(etud)
# sort by name # sort by name
etuds.sort(key=itemgetter("nom")) etuds.sort(key=itemgetter("nom"))
return ", ".join([e["nomprenom"] for e in etuds]) return ", ".join([e["nomprenom"] for e in etuds])
@ -1059,6 +1085,7 @@ def tsp_etud_list(
bac="", # selection sur type de bac bac="", # selection sur type de bac
bacspecialite="", bacspecialite="",
annee_bac="", annee_bac="",
annee_admission="",
civilite="", civilite="",
statut="", statut="",
): ):
@ -1074,16 +1101,21 @@ def tsp_etud_list(
bacs = set() bacs = set()
bacspecialites = set() bacspecialites = set()
annee_bacs = set() annee_bacs = set()
annee_admissions = set()
civilites = set() civilites = set()
statuts = set() statuts = set()
for etudid in etudids: for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud["annee_admission"] = etud["annee"] # plus explicite
bacspe = etud["bac"] + " / " + etud["specialite"] bacspe = etud["bac"] + " / " + etud["specialite"]
# sélection sur bac, primo, ...: # sélection sur bac, primo, ...:
if ( if (
(not bac or (bac == etud["bac"])) (not bac or (bac == etud["bac"]))
and (not bacspecialite or (bacspecialite == bacspe)) and (not bacspecialite or (bacspecialite == bacspe))
and (not annee_bac or (annee_bac == str(etud["annee_bac"]))) and (not annee_bac or (annee_bac == str(etud["annee_bac"])))
and (
not annee_admission or (annee_admission == str(etud["annee_admission"]))
)
and (not civilite or (civilite == etud["civilite"])) and (not civilite or (civilite == etud["civilite"]))
and (not statut or (statut == etud["statut"])) and (not statut or (statut == etud["statut"]))
and (not only_primo or is_primo_etud(etud, sem)) and (not only_primo or is_primo_etud(etud, sem))
@ -1093,11 +1125,12 @@ def tsp_etud_list(
bacs.add(etud["bac"]) bacs.add(etud["bac"])
bacspecialites.add(bacspe) bacspecialites.add(bacspe)
annee_bacs.add(etud["annee_bac"]) annee_bacs.add(etud["annee_bac"])
annee_admissions.add(etud["annee_admission"])
civilites.add(etud["civilite"]) civilites.add(etud["civilite"])
if etud["statut"]: # ne montre pas les statuts non renseignés if etud["statut"]: # ne montre pas les statuts non renseignés
statuts.add(etud["statut"]) statuts.add(etud["statut"])
# log('tsp_etud_list: %s etuds' % len(etuds)) # log('tsp_etud_list: %s etuds' % len(etuds))
return etuds, bacs, bacspecialites, annee_bacs, civilites, statuts return etuds, bacs, bacspecialites, annee_bacs, annee_admissions, civilites, statuts
def tsp_grouped_list(codes_etuds): def tsp_grouped_list(codes_etuds):
@ -1120,9 +1153,15 @@ def tsp_grouped_list(codes_etuds):
def table_suivi_cursus(formsemestre_id, only_primo=False, grouped_parcours=True): def table_suivi_cursus(formsemestre_id, only_primo=False, grouped_parcours=True):
"""Tableau recapitulant tous les parcours""" """Tableau recapitulant tous les parcours"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds, bacs, bacspecialites, annee_bacs, civilites, statuts = tsp_etud_list( (
formsemestre_id, only_primo=only_primo etuds,
) bacs,
bacspecialites,
annee_bacs,
annee_admissions,
civilites,
statuts,
) = tsp_etud_list(formsemestre_id, only_primo=only_primo)
codes_etuds = scu.DictDefault(defaultvalue=[]) codes_etuds = scu.DictDefault(defaultvalue=[])
for etud in etuds: for etud in etuds:
etud["code_cursus"], etud["decisions_jury"] = get_code_cursus_etud(etud) etud["code_cursus"], etud["decisions_jury"] = get_code_cursus_etud(etud)
@ -1276,22 +1315,41 @@ def graph_cursus(
bac="", # selection sur type de bac bac="", # selection sur type de bac
bacspecialite="", bacspecialite="",
annee_bac="", annee_bac="",
annee_admission="",
civilite="", civilite="",
statut="", statut="",
): ):
"""""" """"""
etuds, bacs, bacspecialites, annee_bacs, civilites, statuts = tsp_etud_list( (
etuds,
bacs,
bacspecialites,
annee_bacs,
annee_admissions,
civilites,
statuts,
) = tsp_etud_list(
formsemestre_id, formsemestre_id,
only_primo=only_primo, only_primo=only_primo,
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
) )
# log('graph_cursus: %s etuds (only_primo=%s)' % (len(etuds), only_primo)) # log('graph_cursus: %s etuds (only_primo=%s)' % (len(etuds), only_primo))
if not etuds: if not etuds:
return "", etuds, bacs, bacspecialites, annee_bacs, civilites, statuts return (
"",
etuds,
bacs,
bacspecialites,
annee_bacs,
annee_admissions,
civilites,
statuts,
)
edges = scu.DictDefault( edges = scu.DictDefault(
defaultvalue=set() defaultvalue=set()
) # {("SEM"formsemestre_id_origin, "SEM"formsemestre_id_dest) : etud_set} ) # {("SEM"formsemestre_id_origin, "SEM"formsemestre_id_dest) : etud_set}
@ -1490,7 +1548,16 @@ def graph_cursus(
# cf http://groups.google.com/group/pydot/browse_thread/thread/b3704c53e331e2ec # cf http://groups.google.com/group/pydot/browse_thread/thread/b3704c53e331e2ec
data = data.replace("font-family:Arial", "font-family:Helvetica") data = data.replace("font-family:Arial", "font-family:Helvetica")
return data, etuds, bacs, bacspecialites, annee_bacs, civilites, statuts return (
data,
etuds,
bacs,
bacspecialites,
annee_bacs,
annee_admissions,
civilites,
statuts,
)
def formsemestre_graph_cursus( def formsemestre_graph_cursus(
@ -1500,12 +1567,14 @@ def formsemestre_graph_cursus(
bac="", # selection sur type de bac bac="", # selection sur type de bac
bacspecialite="", bacspecialite="",
annee_bac="", annee_bac="",
annee_admission="",
civilite="", civilite="",
statut="", statut="",
allkeys=False, # unused allkeys=False, # unused
): ):
"""Graphe suivi cohortes""" """Graphe suivi cohortes"""
annee_bac = str(annee_bac) annee_bac = str(annee_bac or "")
annee_admission = str(annee_admission or "")
# log("formsemestre_graph_cursus") # log("formsemestre_graph_cursus")
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if format == "pdf": if format == "pdf":
@ -1515,6 +1584,7 @@ def formsemestre_graph_cursus(
bacs, bacs,
bacspecialites, bacspecialites,
annee_bacs, annee_bacs,
annee_admissions,
civilites, civilites,
statuts, statuts,
) = graph_cursus( ) = graph_cursus(
@ -1524,6 +1594,7 @@ def formsemestre_graph_cursus(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
) )
@ -1537,6 +1608,7 @@ def formsemestre_graph_cursus(
bacs, bacs,
bacspecialites, bacspecialites,
annee_bacs, annee_bacs,
annee_admissions,
civilites, civilites,
statuts, statuts,
) = graph_cursus( ) = graph_cursus(
@ -1546,6 +1618,7 @@ def formsemestre_graph_cursus(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
) )
@ -1573,6 +1646,7 @@ def formsemestre_graph_cursus(
bacs, bacs,
bacspecialites, bacspecialites,
annee_bacs, annee_bacs,
annee_admissions,
civilites, civilites,
statuts, statuts,
) = graph_cursus( ) = graph_cursus(
@ -1581,6 +1655,7 @@ def formsemestre_graph_cursus(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
) )
@ -1599,11 +1674,13 @@ def formsemestre_graph_cursus(
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
annee_bac=annee_bac, annee_bac=annee_bac,
annee_admission=annee_admission,
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
bacs=bacs, bacs=bacs,
bacspecialites=bacspecialites, bacspecialites=bacspecialites,
annee_bacs=annee_bacs, annee_bacs=annee_bacs,
annee_admissions=annee_admissions,
civilites=civilites, civilites=civilites,
statuts=statuts, statuts=statuts,
percent=0, percent=0,