From e8accaf6a0d3a02a40a03a75a6af03fb6e163160 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 22 Feb 2023 00:28:33 +0100 Subject: [PATCH] Implement #601 --- app/scodoc/sco_groups_view.py | 7 +- app/scodoc/sco_report.py | 129 +++++++++++++++++++++++++++------- 2 files changed, 107 insertions(+), 29 deletions(-) diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index a183be4264..bfb7590211 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -476,6 +476,7 @@ def groups_table( "bourse_str": "Boursier", "etape": "Etape", "semestre_groupe": "Semestre-Groupe", # pour Moodle + "annee": "annee_admission", } # ajoute colonnes pour groupes @@ -770,6 +771,7 @@ def groups_table( "villelycee", "codepostallycee", "codelycee", + "annee", "type_admission", "boursier_prec", "boursier", @@ -793,10 +795,9 @@ def groups_table( ) m["parcours"] = Se.get_cursus_descr() m["code_cursus"], _ = sco_report.get_code_cursus_etud(etud) - - L = [[m.get(k, "") for k in keys] for m in groups_infos.members] + rows = [[m.get(k, "") for k in keys] for m in groups_infos.members] 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 return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) else: diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index 7e2e7cfde7..3d8bb3c703 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -84,6 +84,7 @@ def formsemestre_etuds_stats(sem: dict, only_primo=False): etudid = t[-1] etudiant: Identite = Identite.query.get(etudid) 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) if decision: etud["codedecision"] = decision["code"] @@ -346,6 +347,7 @@ def formsemestre_report_counts( "qualite", "villelycee", "statut", + "annee_admission", "type_admission", "boursier_prec", ] @@ -419,6 +421,7 @@ def table_suivi_cohorte( bac="", # selection sur type de bac bacspecialite="", annee_bac="", + annee_admission="", civilite=None, statut="", only_primo=False, @@ -457,16 +460,21 @@ def table_suivi_cohorte( bacs = set() bacspecialites = set() annee_bacs = set() + annee_admissions = set() civilites = set() statuts = set() for etudid in etudids: etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] + etud["annee_admission"] = etud["annee"] bacspe = etud["bac"] + " / " + etud["specialite"] # sélection sur bac: if ( (not bac or (bac == etud["bac"])) and (not bacspecialite or (bacspecialite == bacspe)) 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 statut or (statut == etud["statut"])) and (not only_primo or is_primo_etud(etud, sem)) @@ -481,6 +489,7 @@ def table_suivi_cohorte( bacs.add(etud["bac"]) bacspecialites.add(bacspe) annee_bacs.add(str(etud["annee_bac"])) + annee_admissions.add(str(etud["annee_admission"])) civilites.add(etud["civilite"]) if etud["statut"]: # ne montre pas les statuts non renseignés statuts.add(etud["statut"]) @@ -671,6 +680,8 @@ def table_suivi_cohorte( dbac += " (spécialité %s)" % bacspecialite if annee_bac: dbac += " (année bac %s)" % annee_bac + if annee_admission: + dbac += " (année admission %s)" % annee_admission if civilite: dbac += " civilité: %s" % civilite if statut: @@ -707,13 +718,13 @@ def table_suivi_cohorte( ) expl.append(", ".join(ls) + "") expl.append("") - logt("Z: table_suivi_cohorte done") return ( tab, "\n".join(expl), bacs, bacspecialites, annee_bacs, + annee_admissions, civilites, statuts, ) @@ -726,12 +737,14 @@ def formsemestre_suivi_cohorte( bac="", bacspecialite="", annee_bac="", + annee_admission="", civilite=None, statut="", only_primo=False, ): """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) ( tab, @@ -739,6 +752,7 @@ def formsemestre_suivi_cohorte( bacs, bacspecialites, annee_bacs, + annee_admissions, civilites, statuts, ) = table_suivi_cohorte( @@ -747,6 +761,7 @@ def formsemestre_suivi_cohorte( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, only_primo=only_primo, @@ -795,11 +810,13 @@ def formsemestre_suivi_cohorte( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, bacs=bacs, bacspecialites=bacspecialites, annee_bacs=annee_bacs, + annee_admissions=annee_admissions, civilites=civilites, statuts=statuts, percent=percent, @@ -819,15 +836,19 @@ def _gen_form_selectetuds( bac=None, bacspecialite=None, annee_bac=None, + annee_admission=None, civilite=None, statut=None, bacs=None, bacspecialites=None, annee_bacs=None, + annee_admissions=None, civilites=None, statuts=None, ): """HTML form pour choix criteres selection etudiants""" + annee_bacs = annee_bacs or [] + annee_admissions = annee_admissions or [] bacs = list(bacs) bacs.sort(key=scu.heterogeneous_sorting_key) bacspecialites = list(bacspecialites) @@ -835,6 +856,8 @@ def _gen_form_selectetuds( # 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.sort() + annee_admissions = [int(x) if x else 0 for x in annee_admissions] + annee_admissions.sort() civilites = list(civilites) civilites.sort() statuts = list(statuts) @@ -876,23 +899,13 @@ def _gen_form_selectetuds( F.append('' % (b, selected, b)) F.append("") # - if annee_bac: - selected = "" - else: - selected = 'selected="selected"' F.append( - """  Année bac: ") # F.append( """  Genre: + + """ + for val in values: + selected = 'selected="selected"' if str(value) == str(val) else "" + menu_html += f"""""" + return menu_html + "" + + def _descr_etud_set(etudids): "textual html description of a set of etudids" etuds = [] 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 etuds.sort(key=itemgetter("nom")) return ", ".join([e["nomprenom"] for e in etuds]) @@ -1059,6 +1085,7 @@ def tsp_etud_list( bac="", # selection sur type de bac bacspecialite="", annee_bac="", + annee_admission="", civilite="", statut="", ): @@ -1074,16 +1101,21 @@ def tsp_etud_list( bacs = set() bacspecialites = set() annee_bacs = set() + annee_admissions = set() civilites = set() statuts = set() for etudid in etudids: etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] + etud["annee_admission"] = etud["annee"] # plus explicite bacspe = etud["bac"] + " / " + etud["specialite"] # sélection sur bac, primo, ...: if ( (not bac or (bac == etud["bac"])) and (not bacspecialite or (bacspecialite == bacspe)) 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 statut or (statut == etud["statut"])) and (not only_primo or is_primo_etud(etud, sem)) @@ -1093,11 +1125,12 @@ def tsp_etud_list( bacs.add(etud["bac"]) bacspecialites.add(bacspe) annee_bacs.add(etud["annee_bac"]) + annee_admissions.add(etud["annee_admission"]) civilites.add(etud["civilite"]) if etud["statut"]: # ne montre pas les statuts non renseignés statuts.add(etud["statut"]) # 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): @@ -1120,9 +1153,15 @@ def tsp_grouped_list(codes_etuds): def table_suivi_cursus(formsemestre_id, only_primo=False, grouped_parcours=True): """Tableau recapitulant tous les parcours""" 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=[]) for etud in etuds: etud["code_cursus"], etud["decisions_jury"] = get_code_cursus_etud(etud) @@ -1276,22 +1315,41 @@ def graph_cursus( bac="", # selection sur type de bac bacspecialite="", annee_bac="", + annee_admission="", civilite="", 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, only_primo=only_primo, bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, ) # log('graph_cursus: %s etuds (only_primo=%s)' % (len(etuds), only_primo)) if not etuds: - return "", etuds, bacs, bacspecialites, annee_bacs, civilites, statuts + return ( + "", + etuds, + bacs, + bacspecialites, + annee_bacs, + annee_admissions, + civilites, + statuts, + ) edges = scu.DictDefault( defaultvalue=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 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( @@ -1500,12 +1567,14 @@ def formsemestre_graph_cursus( bac="", # selection sur type de bac bacspecialite="", annee_bac="", + annee_admission="", civilite="", statut="", allkeys=False, # unused ): """Graphe suivi cohortes""" - annee_bac = str(annee_bac) + annee_bac = str(annee_bac or "") + annee_admission = str(annee_admission or "") # log("formsemestre_graph_cursus") sem = sco_formsemestre.get_formsemestre(formsemestre_id) if format == "pdf": @@ -1515,6 +1584,7 @@ def formsemestre_graph_cursus( bacs, bacspecialites, annee_bacs, + annee_admissions, civilites, statuts, ) = graph_cursus( @@ -1524,6 +1594,7 @@ def formsemestre_graph_cursus( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, ) @@ -1537,6 +1608,7 @@ def formsemestre_graph_cursus( bacs, bacspecialites, annee_bacs, + annee_admissions, civilites, statuts, ) = graph_cursus( @@ -1546,6 +1618,7 @@ def formsemestre_graph_cursus( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, ) @@ -1573,6 +1646,7 @@ def formsemestre_graph_cursus( bacs, bacspecialites, annee_bacs, + annee_admissions, civilites, statuts, ) = graph_cursus( @@ -1581,6 +1655,7 @@ def formsemestre_graph_cursus( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, ) @@ -1599,11 +1674,13 @@ def formsemestre_graph_cursus( bac=bac, bacspecialite=bacspecialite, annee_bac=annee_bac, + annee_admission=annee_admission, civilite=civilite, statut=statut, bacs=bacs, bacspecialites=bacspecialites, annee_bacs=annee_bacs, + annee_admissions=annee_admissions, civilites=civilites, statuts=statuts, percent=0,