Update app.py
Browse files175 unmodified lines17617717817918018118218318474 unmodified lines2592602612622632642652662672682692702712722732 unmodified lines27627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530625 unmodified lines332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367175 unmodified linesrun.font.size = Pt(9)def creer_tableau_recapitulatif(self):# Ajouter un espace avant le tableau récapitulatifself.document.add_paragraph().space_after = Pt(8)note_table = self.document.add_table(rows=3, cols=13)note_table.style = 'Table Grid'note_table.alignment = WD_TABLE_ALIGNMENT.CENTER74 unmodified linesrun.font.size = Pt(8)def ajouter_zone_note(self):# Créer un paragraphe pour l'espacementself.document.add_paragraph().space_after = Pt(6)# Créer le tableau pour la note finalezone_note = self.document.add_table(rows=1, cols=2)zone_note.style = 'Table Grid'zone_note.alignment = WD_TABLE_ALIGNMENT.RIGHT# Configurer la cellule du libellécell_libelle = zone_note.cell(0, 0)cell_libelle.text = "Note finale"cell_libelle.paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT2 unmodified linesrun.font.size = Pt(12)run.font.color.rgb = RGBColor(0, 32, 96)# Configurer la cellule de saisie (format plus carré)cell_saisie = zone_note.cell(0, 1)# Définir une largeur plus petitecell_saisie.width = Cm(1)zone_note.rows[0].height = Cm(1)# Ajouter le fond grisshading_elm = parse_xml(f'<w:shd {nsdecls("w")} w:fill="F2F2F2"/>')cell_saisie._tc.get_or_add_tcPr().append(shading_elm)# Ajouter le textecell_saisie.text = "/20"cell_saisie.paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTERrun = cell_saisie.paragraphs[0].runs[0]run.bold = Truerun.font.size = Pt(12)# Ajouter un espacement après le tableauself.document.add_paragraph()def ajouter_lignes_correcteurs(self):for role in ["Projet", "principal", "ROV"]:para = self.document.add_paragraph()para.space_before = Pt(6) # Augmenter l'espace avantpara.space_after = Pt(6) # Augmenter l'espace aprèsrun = para.add_run(f"Correcteur {role} : ")run.bold = Truepara.add_run(".................................................................")25 unmodified lines})def generer_document(self, nom_fichier="evaluation_gymnastique.docx"):# Génération de l'en-têteself.ajouter_entete_colore()# Tableau des éléments techniquesself.creer_tableau_elements()# Note pour le juryself.ajouter_note_jury()# Séparation avant les lignes de correcteursself.document.add_paragraph().space_after = Pt(6)# Lignes des correcteursself.ajouter_lignes_correcteurs()# Séparation avant le tableau récapitulatifpara_espace = self.document.add_paragraph()para_espace.space_before = Pt(10)para_espace.space_after = Pt(10)# Tableau récapitulatifself.creer_tableau_recapitulatif()# Zone de note finaleself.ajouter_zone_note()# Note pour le candidatself.ajouter_note_candidat_avec_cadre()# Sauvegarde du documentself.document.save(nom_fichier)return nom_fichier175 unmodified lines17617717817918018174 unmodified lines2562572582592602612622632642652 unmodified lines26826927027127227327427527627727827928028128228328428528628728828929029129229329429525 unmodified lines321322323324325326327328329330331332333175 unmodified linesrun.font.size = Pt(9)def creer_tableau_recapitulatif(self):note_table = self.document.add_table(rows=3, cols=13)note_table.style = 'Table Grid'note_table.alignment = WD_TABLE_ALIGNMENT.CENTER74 unmodified linesrun.font.size = Pt(8)def ajouter_zone_note(self):zone_note = self.document.add_table(rows=1, cols=2)zone_note.style = 'Table Grid'zone_note.alignment = WD_TABLE_ALIGNMENT.RIGHTcell_libelle = zone_note.cell(0, 0)cell_libelle.text = "Note finale"cell_libelle.paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT2 unmodified linesrun.font.size = Pt(12)run.font.color.rgb = RGBColor(0, 32, 96)# Réduire la largeur pour que la cellule soit plus carréecell_saisie = zone_note.cell(0, 1)cell_saisie.width = Cm(1.2) # Réduit de 1.5 à 1.2 cmzone_note.rows[0].height = Cm(1.2) # Ajusté pour être carré (même valeur que la largeur)shading_elm = parse_xml(f'<w:shd {nsdecls("w")} w:fill="F2F2F2"/>')cell_saisie._tc.get_or_add_tcPr().append(shading_elm)cell_saisie.text = "/20"cell_saisie.paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTERrun = cell_saisie.paragraphs[0].runs[0]run.bold = Truerun.font.size = Pt(12)# Ajouter un paragraphe vide pour créer de l'espaceself.document.add_paragraph()self.document.add_paragraph() # Un deuxième paragraphe vide pour plus d'espacedef ajouter_lignes_correcteurs(self):# Espace supplémentaire avant les correcteurs ajouté avec le paragraphe ci-dessusfor role in ["Projet", "principal", "ROV"]:para = self.document.add_paragraph()para.space_before = Pt(2)para.space_after = Pt(2)run = para.add_run(f"Correcteur {role} : ")run.bold = Truepara.add_run(".................................................................")25 unmodified lines})def generer_document(self, nom_fichier="evaluation_gymnastique.docx"):self.ajouter_entete_colore()self.creer_tableau_elements()self.ajouter_note_jury()self.creer_tableau_recapitulatif()self.ajouter_lignes_correcteurs()self.ajouter_zone_note()self.ajouter_note_candidat_avec_cadre()self.document.save(nom_fichier)return nom_fichier
app.py+9-43