histlearn commited on
Commit
00a6768
verified
1 Parent(s): 1b61773

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -145,7 +145,6 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
145
  def header(self):
146
  self.set_font('Arial', 'B', 12)
147
  self.cell(0, 10, 'Relat贸rio de Tarefas', 0, 1, 'C')
148
- self.cell(0, 10, f'Tempo M茅dio por Tarefa da Turma (ajustado): {media_tempo_medio_turma}', 0, 1, 'C')
149
 
150
  def footer(self):
151
  self.set_y(-15)
@@ -170,11 +169,12 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
170
  ha='center', va='bottom')
171
 
172
  top_students = dataframe.nlargest(5, 'Acertos Absolutos')
 
173
  plt.figure(figsize=(10, 6))
174
  bars = plt.bar(top_students['Nome do Aluno'], top_students['Acertos Absolutos'], color='blue')
175
  plt.xlabel('Nome do Aluno')
176
  plt.ylabel('Acertos Absolutos')
177
- plt.title('Top 5 Alunos - Acertos Absolutos')
178
  plt.xticks(rotation=45, ha='right')
179
  add_bar_labels(bars)
180
  plt.tight_layout()
@@ -186,7 +186,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
186
  bars = plt.bar(top_students['Nome do Aluno'], top_students['M茅dia de Acertos'].str.rstrip('%').astype('float'), color='green')
187
  plt.xlabel('Nome do Aluno')
188
  plt.ylabel('Percentual de Acertos (%)')
189
- plt.title('Top 5 Alunos - Percentual de Acertos')
190
  plt.xticks(rotation=45, ha='right')
191
  add_bar_labels(bars)
192
  plt.tight_layout()
@@ -198,7 +198,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
198
  bars = plt.bar(top_students['Nome do Aluno'], top_students['Tarefas Completadas'], color='red')
199
  plt.xlabel('Nome do Aluno')
200
  plt.ylabel('Tarefas Completadas')
201
- plt.title('Top 5 Alunos - Tarefas Completadas')
202
  plt.xticks(rotation=45, ha='right')
203
  add_bar_labels(bars)
204
  plt.tight_layout()
@@ -210,9 +210,15 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
210
  temp_graphics_pdf = 'temp_graphics.pdf'
211
  pdf.output(temp_graphics_pdf)
212
 
213
- # Converter o HTML para PDF
 
 
 
 
 
 
214
  temp_html_pdf = 'temp_html.pdf'
215
- HTML(html_path).write_pdf(temp_html_pdf)
216
 
217
  # Combinar os PDFs
218
  from PyPDF2 import PdfMerger
@@ -226,6 +232,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
226
  # Remover arquivos tempor谩rios
227
  os.remove(temp_graphics_pdf)
228
  os.remove(temp_html_pdf)
 
229
 
230
  def processar_relatorio(html_file, tarefa_files):
231
  input_directory = "temp_files" # Diret贸rio tempor谩rio para os arquivos
 
145
  def header(self):
146
  self.set_font('Arial', 'B', 12)
147
  self.cell(0, 10, 'Relat贸rio de Tarefas', 0, 1, 'C')
 
148
 
149
  def footer(self):
150
  self.set_y(-15)
 
169
  ha='center', va='bottom')
170
 
171
  top_students = dataframe.nlargest(5, 'Acertos Absolutos')
172
+
173
  plt.figure(figsize=(10, 6))
174
  bars = plt.bar(top_students['Nome do Aluno'], top_students['Acertos Absolutos'], color='blue')
175
  plt.xlabel('Nome do Aluno')
176
  plt.ylabel('Acertos Absolutos')
177
+ plt.title(f'Top 5 Alunos - Acertos Absolutos (Tempo M茅dio da Turma: {media_tempo_medio_turma})')
178
  plt.xticks(rotation=45, ha='right')
179
  add_bar_labels(bars)
180
  plt.tight_layout()
 
186
  bars = plt.bar(top_students['Nome do Aluno'], top_students['M茅dia de Acertos'].str.rstrip('%').astype('float'), color='green')
187
  plt.xlabel('Nome do Aluno')
188
  plt.ylabel('Percentual de Acertos (%)')
189
+ plt.title(f'Top 5 Alunos - Percentual de Acertos (Tempo M茅dio da Turma: {media_tempo_medio_turma})')
190
  plt.xticks(rotation=45, ha='right')
191
  add_bar_labels(bars)
192
  plt.tight_layout()
 
198
  bars = plt.bar(top_students['Nome do Aluno'], top_students['Tarefas Completadas'], color='red')
199
  plt.xlabel('Nome do Aluno')
200
  plt.ylabel('Tarefas Completadas')
201
+ plt.title(f'Top 5 Alunos - Tarefas Completadas (Tempo M茅dio da Turma: {media_tempo_medio_turma})')
202
  plt.xticks(rotation=45, ha='right')
203
  add_bar_labels(bars)
204
  plt.tight_layout()
 
210
  temp_graphics_pdf = 'temp_graphics.pdf'
211
  pdf.output(temp_graphics_pdf)
212
 
213
+ # Converter o HTML para PDF com bordas na tabela
214
+ html_content = open(html_path, 'r', encoding='utf-8').read()
215
+ html_content = html_content.replace('<table border="1" class="dataframe">', '<table style="border-collapse: collapse; width: 100%;" border="1" class="dataframe">')
216
+ temp_html_path = 'temp_html_with_borders.html'
217
+ with open(temp_html_path, 'w', encoding='utf-8') as f:
218
+ f.write(html_content)
219
+
220
  temp_html_pdf = 'temp_html.pdf'
221
+ HTML(temp_html_path).write_pdf(temp_html_pdf)
222
 
223
  # Combinar os PDFs
224
  from PyPDF2 import PdfMerger
 
232
  # Remover arquivos tempor谩rios
233
  os.remove(temp_graphics_pdf)
234
  os.remove(temp_html_pdf)
235
+ os.remove(temp_html_path)
236
 
237
  def processar_relatorio(html_file, tarefa_files):
238
  input_directory = "temp_files" # Diret贸rio tempor谩rio para os arquivos