From a644fd25847804c4187db13ad3d6e667b5c1b44e Mon Sep 17 00:00:00 2001 From: Jean-Marie PLACE Date: Sat, 19 Feb 2022 07:14:32 +0100 Subject: [PATCH] reprise pe --- app/pe/pe_avislatex.py | 118 ++++++++++++++++++++++++++++------------- app/pe/pe_jurype.py | 4 +- app/pe/pe_tagtable.py | 2 +- app/pe/pe_tools.py | 5 +- app/pe/pe_view.py | 7 +-- 5 files changed, 92 insertions(+), 44 deletions(-) diff --git a/app/pe/pe_avislatex.py b/app/pe/pe_avislatex.py index df2f89d2f..5ff20464f 100644 --- a/app/pe/pe_avislatex.py +++ b/app/pe/pe_avislatex.py @@ -225,10 +225,8 @@ def get_annotation_PE(etudid, tag_annotation_pe): (cf. .get_preferences -> pe_tag_annotation_avis_latex). Result: chaine unicode - Modif JMP retourne un dictionnaire { - None : annotation de base - : annotation spécifique pour l'école - } + Modif JMP retourne une liste d'annotations par ecole + ou [""] si pas d'annotation enregistrée """ if tag_annotation_pe: cnx = ndb.GetDBConnexion() @@ -261,15 +259,17 @@ def get_annotation_PE(etudid, tag_annotation_pe): ) # Interprète les retours chariots html # Patch JMP build dictionnary of annotations - annotations = {} split = annotationPE.split("@") - annotations[None] = split[0] + globale = split[0] + if len(split) < 2: + return globale, None + specifiques = {} for specifique in split[1:]: ecole, annotation = specifique.split(":", 1) - annotations[ecole] = specifique + specifiques[ecole] = f"{globale}\n{specifique}\n" + return globale, specifiques - return annotations - return "" # pas d'annotations + return "", None # pas d'annotations # ---------------------------------------------------------------------------------------- @@ -394,44 +394,90 @@ def get_bilanParTag(donnees_etudiant, groupe="groupe"): return code_latex +def get_avis_pousuite_par_etudiant_par_ecole( + jury, + etudid, + template_latex, + footer_latex, + prefs, + ecole, + annotation, +): + civilite_str = jury.syntheseJury[etudid]["civilite_str"] + nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-") + prenom = jury.syntheseJury[etudid]["prenom"].replace(" ", "-") + + nom_fichier = scu.sanitize_filename( + "avis_poursuite_%s_%s_%s_%s" % (nom, prenom, etudid, ecole) + ) + if pe_tools.PE_DEBUG: + pe_tools.pe_print("fichier latex =" + nom_fichier, type(nom_fichier)) + # Entete (commentaire) + + contenu_latex = ( + "%% ---- Etudiant: " + civilite_str + " " + nom + " " + prenom + "\n" + ) + + # le LaTeX + avis = get_code_latex_avis_etudiant( + jury.syntheseJury[etudid], + template_latex, + annotation, + footer_latex, + prefs, + ) + # if pe_tools.PE_DEBUG: pe_tools.pe_print(avis, type(avis)) + contenu_latex += avis + "\n" + + return [nom_fichier, contenu_latex] + + # ---------------------------------------------------------------------------------------- def get_avis_poursuite_par_etudiant( jury, etudid, template_latex, tag_annotation_pe, footer_latex, prefs ): """Renvoie un nom de fichier et le contenu de l'avis latex d'un étudiant dont l'etudid est fourni. result: [ chaine unicode, chaine unicode ] + Patch JMP: Renvoi une liste d'éléments comme décrit ci-dessus (1 élément par destination aka avis spécifique """ if pe_tools.PE_DEBUG: pe_tools.pe_print(jury.syntheseJury[etudid]["nom"] + " " + str(etudid)) - civilite_str = jury.syntheseJury[etudid]["civilite_str"] - nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-") - prenom = jury.syntheseJury[etudid]["prenom"].replace(" ", "-") - - nom_fichier = scu.sanitize_filename( - "avis_poursuite_%s_%s_%s" % (nom, prenom, etudid) - ) - if pe_tools.PE_DEBUG: - pe_tools.pe_print("fichier latex =" + nom_fichier, type(nom_fichier)) - - # Entete (commentaire) - contenu_latex = ( - "%% ---- Etudiant: " + civilite_str + " " + nom + " " + prenom + "\n" - ) - # les annotations - annotations = get_annotation_PE(etudid, tag_annotation_pe=tag_annotation_pe) - if pe_tools.PE_DEBUG: - pe_tools.pe_print(annotations, type(annotations)) - - # le LaTeX - avis = get_code_latex_avis_etudiant( - jury.syntheseJury[etudid], template_latex, annotationPE, footer_latex, prefs + globale, specifiques = get_annotation_PE( + etudid, tag_annotation_pe=tag_annotation_pe ) - # if pe_tools.PE_DEBUG: pe_tools.pe_print(avis, type(avis)) - contenu_latex += avis + "\n" + if pe_tools.PE_DEBUG: + pe_tools.pe_print(globale, type(globale)) + pe_tools.pe_print(specifiques, type(specifiques)) - return [nom_fichier, contenu_latex] + returns = [] + if specifiques is None: + returns.append( + get_avis_pousuite_par_etudiant_par_ecole( + jury, + etudid, + template_latex, + footer_latex, + prefs, + "", + globale, + ) + ) + else: + for ecole in specifiques.keys(): + returns.append( + get_avis_pousuite_par_etudiant_par_ecole( + jury, + etudid, + template_latex, + footer_latex, + prefs, + ecole, + specifiques[ecole], + ) + ) + return returns def get_templates_from_distrib(template="avis"): @@ -515,8 +561,8 @@ def table_syntheseAnnotationPE(syntheseJury, tag_annotation_pe): n += 1 # L'annotation PE - annotationPE = get_annotation_PE(etudid, tag_annotation_pe=tag_annotation_pe)[None] - row["Annotation PE"] = annotationPE + f" + {len(annotationPE)} specifiques" if annotationPE else "" + globale, _ = get_annotation_PE(etudid, tag_annotation_pe=tag_annotation_pe) + row["Annotation PE"] = globale rows.append(row) T = GenTable( diff --git a/app/pe/pe_jurype.py b/app/pe/pe_jurype.py index 2720ad435..9ba7d8767 100644 --- a/app/pe/pe_jurype.py +++ b/app/pe/pe_jurype.py @@ -623,7 +623,7 @@ class JuryPE(object): u" - %d étudiants classés " % (nbinscrit) + ": " + ",".join( - [etudid for etudid in self.semTagDict[fid].get_etudids()] + [str(etudid) for etudid in self.semTagDict[fid].get_etudids()] ) ) if lesEtudidsManquants: @@ -631,7 +631,7 @@ class JuryPE(object): u" - dont %d étudiants manquants ajoutés aux données du jury" % (len(lesEtudidsManquants)) + ": " - + ", ".join(lesEtudidsManquants) + + ", ".join(str(lesEtudidsManquants)) ) pe_tools.pe_print(u" - Export csv") filename = self.NOM_EXPORT_ZIP + self.semTagDict[fid].nom + ".csv" diff --git a/app/pe/pe_tagtable.py b/app/pe/pe_tagtable.py index 0e5045cba..d20afb6e5 100644 --- a/app/pe/pe_tagtable.py +++ b/app/pe/pe_tagtable.py @@ -265,7 +265,7 @@ class TableTag(object): for etudid in self.identdict: descr = delim.join( [ - etudid, + str(etudid), self.identdict[etudid]["nom"], self.identdict[etudid]["prenom"], ] diff --git a/app/pe/pe_tools.py b/app/pe/pe_tools.py index 5f58428bb..3cc51a37b 100644 --- a/app/pe/pe_tools.py +++ b/app/pe/pe_tools.py @@ -48,7 +48,7 @@ import app.scodoc.sco_utils as scu from app import log from app.scodoc.sco_logos import find_logo -PE_DEBUG = 0 +PE_DEBUG = 1 if not PE_DEBUG: # log to notes.log @@ -56,6 +56,7 @@ if not PE_DEBUG: # kw is ignored. log always add a newline log(" ".join(a)) + else: pe_print = print # print function @@ -208,7 +209,7 @@ def add_pe_stuff_to_zip(zipfile, ziproot): logo = find_logo(logoname=name, dept_id=g.scodoc_dept_id) if logo is not None: add_local_file_to_zip( - zipfile, ziproot, logo.filepath, "avis/logos/" + logo.filename + zipfile, ziproot, logo.filepath, "avis/logos/logo_" + logo.filename ) diff --git a/app/pe/pe_view.py b/app/pe/pe_view.py index 5af1a5754..7f9f31d5e 100644 --- a/app/pe/pe_view.py +++ b/app/pe/pe_view.py @@ -145,7 +145,7 @@ def pe_view_sem_recap( latex_pages = {} # Dictionnaire de la forme nom_fichier => contenu_latex for etudid in etudids: - [nom_fichier, contenu_latex] = pe_avislatex.get_avis_poursuite_par_etudiant( + les_avis = pe_avislatex.get_avis_poursuite_par_etudiant( jury, etudid, template_latex, @@ -153,8 +153,9 @@ def pe_view_sem_recap( footer_latex, prefs, ) - jury.add_file_to_zip("avis/" + nom_fichier + ".tex", contenu_latex) - latex_pages[nom_fichier] = contenu_latex # Sauvegarde dans un dico + for nom_fichier, contenu_latex in les_avis: + jury.add_file_to_zip("avis/" + nom_fichier + ".tex", contenu_latex) + latex_pages[nom_fichier] = contenu_latex # Sauvegarde dans un dico # Nouvelle version : 1 fichier par étudiant avec 1 fichier appelant créée ci-dessous doc_latex = "\n% -----\n".join(