Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,13 +87,22 @@ def match_alunos(tarefas_csv_path, alunos_csv_path, contador_df):
|
|
87 |
def process_all_tarefas_in_directory(directory, alunos_csv_path, contador_csv_path, relatorio_csv_path):
|
88 |
tarefas_files = [os.path.join(directory, f) for f in os.listdir(directory) if f.endswith('.csv') and f not in ['alunos_fim.csv', 'contador_tarefas.csv', 'relatorio_final.csv']]
|
89 |
|
90 |
-
|
|
|
|
|
|
|
91 |
|
92 |
for i, tarefas_file in enumerate(tarefas_files):
|
93 |
print(f"Processando arquivo {i+1}/{len(tarefas_files)}: {tarefas_file}")
|
94 |
contador_df = match_alunos(tarefas_file, alunos_csv_path, contador_df)
|
95 |
print(f"Arquivo {tarefas_file} processado.")
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
contador_df.to_csv(contador_csv_path, index=False)
|
98 |
process_relatorios(contador_csv_path, relatorio_csv_path)
|
99 |
|
@@ -135,22 +144,4 @@ def process_inputs(html_file, tarefa_files):
|
|
135 |
return df.to_html(index=False), html_output_path
|
136 |
|
137 |
def download_html_file(file_path):
|
138 |
-
return file_path
|
139 |
-
|
140 |
-
# --- Interface Gradio ---
|
141 |
-
|
142 |
-
with gr.Blocks() as interface:
|
143 |
-
gr.Markdown("# Processamento de Relat贸rios de Tarefas")
|
144 |
-
html_file = gr.File(label="Upload HTML File (alunos.htm)", type="binary")
|
145 |
-
excel_files = gr.Files(label="Upload Excel Files (Relat贸rios de Tarefas)", type="binary", file_count="multiple")
|
146 |
-
generate_btn = gr.Button("Generate Report")
|
147 |
-
output_html = gr.HTML()
|
148 |
-
download_btn = gr.File(label="Download Report")
|
149 |
-
|
150 |
-
def process_and_prepare_download(html_file, tarefa_files):
|
151 |
-
html_content, file_path = process_inputs(html_file, tarefa_files)
|
152 |
-
return html_content, file_path
|
153 |
-
|
154 |
-
generate_btn.click(fn=process_and_prepare_download, inputs=[html_file, excel_files], outputs=[output_html, download_btn])
|
155 |
-
|
156 |
-
interface.launch()
|
|
|
87 |
def process_all_tarefas_in_directory(directory, alunos_csv_path, contador_csv_path, relatorio_csv_path):
|
88 |
tarefas_files = [os.path.join(directory, f) for f in os.listdir(directory) if f.endswith('.csv') and f not in ['alunos_fim.csv', 'contador_tarefas.csv', 'relatorio_final.csv']]
|
89 |
|
90 |
+
try:
|
91 |
+
contador_df = pd.read_csv(contador_csv_path)
|
92 |
+
except FileNotFoundError:
|
93 |
+
contador_df = pd.DataFrame(columns=['Nome do Aluno', 'Tarefas Completadas', 'Acertos Absolutos', 'Total Tempo'])
|
94 |
|
95 |
for i, tarefas_file in enumerate(tarefas_files):
|
96 |
print(f"Processando arquivo {i+1}/{len(tarefas_files)}: {tarefas_file}")
|
97 |
contador_df = match_alunos(tarefas_file, alunos_csv_path, contador_df)
|
98 |
print(f"Arquivo {tarefas_file} processado.")
|
99 |
|
100 |
+
# Recontar as tarefas completadas para garantir a contagem correta
|
101 |
+
aluno_counts = tarefas_df['Aluno_Pattern'].value_counts()
|
102 |
+
for aluno_pattern, count in aluno_counts.items():
|
103 |
+
if aluno_pattern in contador_df['Nome do Aluno'].values:
|
104 |
+
contador_df.loc[contador_df['Nome do Aluno'] == aluno_pattern, 'Tarefas Completadas'] = count
|
105 |
+
|
106 |
contador_df.to_csv(contador_csv_path, index=False)
|
107 |
process_relatorios(contador_csv_path, relatorio_csv_path)
|
108 |
|
|
|
144 |
return df.to_html(index=False), html_output_path
|
145 |
|
146 |
def download_html_file(file_path):
|
147 |
+
return file_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|