Spaces:
Sleeping
Sleeping
Convert Results page to tab within Challenge
Browse files1277 unmodified lines12781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130728 unmodified lines133613371338131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213391340134135 unmodified lines137713781379138413801381138299 unmodified lines1482148314841490148514861487148873 unmodified lines15621563156415701565156615671573157415681569157015719 unmodified lines1581158215831590158415851586158733 unmodified lines1621162216231630162416251626162756 unmodified lines1684168516861693168716881689169055 unmodified lines174617471748175517491750175117521277 unmodified lines refresh_btn = gr.Button("π Refresh", variant="secondary") revert_btn = gr.Button("β©οΈ Revert to Original", variant="secondary") changes_diff_html = gr.HTML("") # ββ Results Tab (shown after Submit) ββββββββββββββββββ with gr.Tab("π Results", id=4): score_summary_html = gr.HTML("")
with gr.Tabs(): with gr.Tab("π§ͺ Test Results"): results_test_html = gr.HTML("")
with gr.Tab("π Changes & Expected"): results_changes_html = gr.HTML("")
with gr.Tab("π‘ Hints Used"): results_hints_html = gr.HTML("") # Debug console (collapsible) with gr.Accordion("π Debug Console", open=False): debug_console = gr.Textbox( label="Execution Logs", lines=15, max_lines=30, interactive=False, placeholder="Debug logs will appear here...", )
# ββ Right column: AI assistant + submit βββββββββββββββββββ with gr.Column(scale=2, elem_classes=["right-col"]):28 unmodified lines # Hidden trigger for submit (ensures at least 1 UI input) submit_trigger = gr.Number(value=0, visible=False)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ # PAGE 3 β Results (hidden until Submit clicked) # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ with gr.Column(visible=False) as results_page: gr.Markdown("## π Submission Results")
score_summary_html = gr.HTML("")
with gr.Tabs(): with gr.Tab("π§ͺ Test Results"): results_test_html = gr.HTML("")
with gr.Tab("π Changes & Expected"): results_changes_html = gr.HTML("")
with gr.Tab("π‘ Hints Used"): results_hints_html = gr.HTML("") # Debug console (collapsible) with gr.Accordion("π Debug Console", open=False): debug_console = gr.Textbox( label="Execution Logs", lines=15, max_lines=30, interactive=False, placeholder="Debug logs will appear here...", )
# ββ Login callback ββββββββββββββββββββββββββββββββββββββββββββββββ def on_login(name, api_key):35 unmodified lines gr.update(visible=True), # show login gr.update(visible=False), # hide setup gr.update(visible=False), # hide challenge gr.update(visible=False), # hide results gr.update(visible=False), # hide logout "", "", "", "", # clear textboxes "", "" # clear states99 unmodified lines logout_btn.click( on_logout, outputs=[ login_page, setup_page, challenge_page, results_page, logout_btn, login_page, setup_page, challenge_page, logout_btn, login_name, login_api_key, name_box, url_box, user_api_key_state, user_name_state ]73 unmodified lines logger.info(f"Trigger: {trigger}, User: {user_name}, Hints: {hints_used}, Submit#: {submit_count}") logger.info(f"Workspace: {workspace_path}") # First yield IMMEDIATELY (like on_start): Show loading WITHOUT changing visibility # First yield IMMEDIATELY: Show loading in Results tab _loading = '<p style="text-align:center;padding:40px;color:#888;font-size:1.2em;">β³ Running testsβ¦</p>' yield ( gr.update(), # challenge_page - no change yet gr.update(), # results_page - no change yet gr.Tabs(selected=4), # Switch to Results tab _loading, "", "", "", # Show loading message in results area submit_count, "", # debug console9 unmodified lines if not workspace_path: sys.stdout = original_stdout yield (gr.update(visible=False), gr.update(visible=True), "No challenge loaded.", "", "", "", submit_count, log_capture.getvalue(), "β No workspace loaded") yield (gr.Tabs(selected=4), "No challenge loaded.", "", "", "", submit_count, log_capture.getvalue(), "β No workspace loaded") return print(f"[{datetime.now().strftime('%H:%M:%S')}] π Starting submission evaluation...")33 unmodified lines # Return results to user IMMEDIATELY yield ( gr.update(visible=False), gr.update(visible=True), gr.Tabs(selected=4), # Stay on Results tab score_html, combined_diff, test_html, hints_html, new_count, debug_logs,56 unmodified lines debug_logs = log_capture.getvalue() + f"\n\nβ ERROR:\n{error_details}" sys.stdout = original_stdout # Restore stdout err = f"<p style='color:#ef4444;padding:20px;font-family:monospace;'>β Error during evaluation:<br>{exc}</p>" yield (gr.update(visible=False), gr.update(visible=True), err, "", "", "", submit_count, debug_logs, debug_logs) yield (gr.Tabs(selected=4), err, "", "", "", submit_count, debug_logs, debug_logs) finally: sys.stdout = original_stdout # Always restore stdout
55 unmodified lines inputs=[submit_trigger, hints_used_state, submission_count_state, workspace_state, hint_log_state, user_name_state], outputs=[ challenge_page, results_page, left_tabs, # Switch to Results tab score_summary_html, results_changes_html, results_test_html,student_interface.py+31-37