Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -158,10 +158,10 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
|
|
158 |
pdf = PDF(orientation='L', unit='mm', format='A4')
|
159 |
|
160 |
# Gerar gráficos e adicionar ao PDF
|
161 |
-
def add_bar_labels(bars):
|
162 |
-
for bar in bars:
|
163 |
height = bar.get_height()
|
164 |
-
plt.annotate(f'{
|
165 |
xy=(bar.get_x() + bar.get_width() / 2, height),
|
166 |
xytext=(0, 3), # 3 points vertical offset
|
167 |
textcoords="offset points",
|
@@ -175,7 +175,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
|
|
175 |
plt.ylabel('Acertos Absolutos')
|
176 |
plt.title(f'Top 5 Alunos - Acertos Absolutos (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
177 |
plt.xticks(rotation=45, ha='right')
|
178 |
-
add_bar_labels(bars)
|
179 |
plt.tight_layout()
|
180 |
graph_path = 'top_5_acertos_absolutos.png'
|
181 |
plt.savefig(graph_path)
|
@@ -187,7 +187,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
|
|
187 |
plt.ylabel('Percentual de Acertos (%)')
|
188 |
plt.title(f'Top 5 Alunos - Percentual de Acertos (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
189 |
plt.xticks(rotation=45, ha='right')
|
190 |
-
add_bar_labels(bars)
|
191 |
plt.tight_layout()
|
192 |
graph_path = 'top_5_percentual_acertos.png'
|
193 |
plt.savefig(graph_path)
|
@@ -199,7 +199,7 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
|
|
199 |
plt.ylabel('Tarefas Completadas')
|
200 |
plt.title(f'Top 5 Alunos - Tarefas Completadas (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
201 |
plt.xticks(rotation=45, ha='right')
|
202 |
-
add_bar_labels(bars)
|
203 |
plt.tight_layout()
|
204 |
graph_path = 'top_5_tarefas_completadas.png'
|
205 |
plt.savefig(graph_path)
|
@@ -209,12 +209,12 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, html_path, output_pd
|
|
209 |
dataframe['Total Tempo'] = pd.to_timedelta(dataframe['Total Tempo'])
|
210 |
top_time_students = dataframe.nlargest(5, 'Total Tempo')
|
211 |
plt.figure(figsize=(10, 6))
|
212 |
-
bars = plt.bar(top_time_students['Nome do Aluno'], top_time_students['Total Tempo'].dt.total_seconds()
|
213 |
plt.xlabel('Nome do Aluno')
|
214 |
-
plt.ylabel('Tempo Total (
|
215 |
plt.title(f'Top 5 Alunos - Tempo Total (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
216 |
plt.xticks(rotation=45, ha='right')
|
217 |
-
add_bar_labels(bars)
|
218 |
plt.tight_layout()
|
219 |
graph_path = 'top_5_tempo_total.png'
|
220 |
plt.savefig(graph_path)
|
|
|
158 |
pdf = PDF(orientation='L', unit='mm', format='A4')
|
159 |
|
160 |
# Gerar gráficos e adicionar ao PDF
|
161 |
+
def add_bar_labels(bars, labels):
|
162 |
+
for bar, label in zip(bars, labels):
|
163 |
height = bar.get_height()
|
164 |
+
plt.annotate(f'{label}',
|
165 |
xy=(bar.get_x() + bar.get_width() / 2, height),
|
166 |
xytext=(0, 3), # 3 points vertical offset
|
167 |
textcoords="offset points",
|
|
|
175 |
plt.ylabel('Acertos Absolutos')
|
176 |
plt.title(f'Top 5 Alunos - Acertos Absolutos (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
177 |
plt.xticks(rotation=45, ha='right')
|
178 |
+
add_bar_labels(bars, top_students['Acertos Absolutos'])
|
179 |
plt.tight_layout()
|
180 |
graph_path = 'top_5_acertos_absolutos.png'
|
181 |
plt.savefig(graph_path)
|
|
|
187 |
plt.ylabel('Percentual de Acertos (%)')
|
188 |
plt.title(f'Top 5 Alunos - Percentual de Acertos (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
189 |
plt.xticks(rotation=45, ha='right')
|
190 |
+
add_bar_labels(bars, top_students['Média de Acertos'].str.rstrip('%').astype('float'))
|
191 |
plt.tight_layout()
|
192 |
graph_path = 'top_5_percentual_acertos.png'
|
193 |
plt.savefig(graph_path)
|
|
|
199 |
plt.ylabel('Tarefas Completadas')
|
200 |
plt.title(f'Top 5 Alunos - Tarefas Completadas (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
201 |
plt.xticks(rotation=45, ha='right')
|
202 |
+
add_bar_labels(bars, top_students['Tarefas Completadas'])
|
203 |
plt.tight_layout()
|
204 |
graph_path = 'top_5_tarefas_completadas.png'
|
205 |
plt.savefig(graph_path)
|
|
|
209 |
dataframe['Total Tempo'] = pd.to_timedelta(dataframe['Total Tempo'])
|
210 |
top_time_students = dataframe.nlargest(5, 'Total Tempo')
|
211 |
plt.figure(figsize=(10, 6))
|
212 |
+
bars = plt.bar(top_time_students['Nome do Aluno'], top_time_students['Total Tempo'].dt.total_seconds(), color='purple')
|
213 |
plt.xlabel('Nome do Aluno')
|
214 |
+
plt.ylabel('Tempo Total (segundos)')
|
215 |
plt.title(f'Top 5 Alunos - Tempo Total (Tempo Médio da Turma: {media_tempo_medio_turma})')
|
216 |
plt.xticks(rotation=45, ha='right')
|
217 |
+
add_bar_labels(bars, top_time_students['Total Tempo'].dt.total_seconds().astype(int))
|
218 |
plt.tight_layout()
|
219 |
graph_path = 'top_5_tempo_total.png'
|
220 |
plt.savefig(graph_path)
|