Spaces:
Sleeping
Sleeping
Restore original student_interface.py from backup
Browse filesFiles changed (2)
- app.py+2-2
- student_interface.py+60-46
30 unmodified lines31323334353637383930 unmodified linesif os.getenv("no_proxy"):os.environ["no_proxy"] = os.getenv("no_proxy")logger.info("π Launching Legacy Code Challenge (Full featured Tabs version)...")from student_interface_tabs import demologger.info("β Demo imported successfully!")30 unmodified lines31323334353637383930 unmodified linesif os.getenv("no_proxy"):os.environ["no_proxy"] = os.getenv("no_proxy")logger.info("π Launching Legacy Code Challenge (Original version)...")from student_interface import demologger.info("β Demo imported successfully!")
1566 unmodified lines15671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615975 unmodified lines1603160416051606160716081609161016111612161316141615161631 unmodified lines164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821566 unmodified lineslogger.info(f"Trigger: {trigger}, User: {user_name}, Hints: {hints_used}, Submit#: {submit_count}")logger.info(f"Workspace: {workspace_path}")# STEP 1: Change page visibility IMMEDIATELY (like on_login - simple update)yield (gr.update(visible=False), # challenge_pagegr.update(visible=True), # results_page"", # score_html - empty for now"", # changes_html"", # test_html"", # hints_htmlsubmit_count, # no change yet"", # debug console"Starting submission evaluation...", # live debug)# STEP 2: Show loading message_loading = '<p style="text-align:center;padding:40px;color:#888;font-size:1.2em;">β³ Running testsβ¦</p>'yield (gr.update(), # challenge_page - already hiddengr.update(), # results_page - already visible_loading, # score_html"", # changes_html"", # test_html"", # hints_htmlsubmit_count,"", # debug console"Evaluating code...", # live debug)# Capture all print statements for debug console5 unmodified linesif not workspace_path:sys.stdout = original_stdoutyield (gr.update(), # challenge_pagegr.update(), # results_page"No challenge loaded.", "", "", "",submit_count,log_capture.getvalue(),"β No workspace loaded")returnprint(f"[{datetime.now().strftime('%H:%M:%S')}] π Starting submission evaluation...")31 unmodified linesdebug_logs = log_capture.getvalue()sys.stdout = original_stdout # Restore stdout# STEP 3: Return final resultsyield (gr.update(), # challenge_page - no changegr.update(), # results_page - no changescore_html,combined_diff,test_html,hints_html,new_count,debug_logs,debug_logs, # live debug)logger.info("Final yield complete!")except Exception as exc:import tracebackerror_details = traceback.format_exc()debug_logs = log_capture.getvalue() + f"\n\nβ ERROR:\n{error_details}"sys.stdout = original_stdout # Restore stdouterr = f"<p style='color:#ef4444;padding:20px;font-family:monospace;'>β Error during evaluation:<br>{exc}</p>"yield (gr.update(), # challenge_pagegr.update(), # results_pageerr, "", "", "",submit_count,debug_logs,debug_logs)finally:sys.stdout = original_stdout # Always restore stdout1566 unmodified lines1567156815691570157115721573157415751576157715781579158015815 unmodified lines158715881589159015911592159331 unmodified lines1625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961566 unmodified lineslogger.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_loading = '<p style="text-align:center;padding:40px;color:#888;font-size:1.2em;">β³ Running testsβ¦</p>'yield (gr.update(), # challenge_page - no change yetgr.update(), # results_page - no change yet_loading, "", "", "", # Show loading message in results areasubmit_count,"", # debug console"Starting submission evaluation...", # live debug)# Capture all print statements for debug console5 unmodified linesif not workspace_path:sys.stdout = original_stdoutyield (gr.update(visible=False), gr.update(visible=True), "No challenge loaded.", "", "", "", submit_count, log_capture.getvalue(), "β No workspace loaded")returnprint(f"[{datetime.now().strftime('%H:%M:%S')}] π Starting submission evaluation...")31 unmodified linesdebug_logs = log_capture.getvalue()sys.stdout = original_stdout # Restore stdout# Return results to user IMMEDIATELYyield (gr.update(visible=False), gr.update(visible=True),score_html, combined_diff, test_html, hints_html,new_count,debug_logs,debug_logs, # live debug (same))# Upload to cloud services in BACKGROUND THREAD (non-blocking)# TEMPORARILY DISABLED - Testing without cloud uploads"""def _background_upload():student_name = user_name.strip() if user_name else "Anonymous"# Google Sheets (fast summary)if GOOGLE_SHEETS_AVAILABLE:try:print("π Uploading to Google Sheets...")log_to_google_sheets(student_name=student_name,repo_url=cs.github_url,hints_used=hints_used,score=result["total_score"],total_tests=result["total_tests"],passed_tests=result["passed"],all_passed=result["all_passed"],chat_history=hint_log or [],)print(f"β Logged to Google Sheets: {student_name}")except Exception as e:print(f"β οΈ Google Sheets logging failed: {e}")# Git Submissions (detailed backup with all code)if GIT_SUBMISSIONS_AVAILABLE:try:print("π Pushing to Git repository...")push_submission_to_git(student_name=student_name,repo_url=cs.github_url,original_code=cs.original_code,buggy_code=cs.sabotaged_code,student_code=submitted_code,chat_history=hint_log or [],score=result["total_score"],total_tests=result["total_tests"],passed_tests=result["passed"],hints_used=hints_used,challenge_prompt=cs.readme(),target_file=cs.target_file,)print(f"β Pushed to Git: {student_name}")except Exception as e:print(f"β οΈ Git submission backup failed: {e}")# Start background upload (won't block UI)upload_thread = threading.Thread(target=_background_upload, daemon=True)upload_thread.start()"""except Exception as exc:import tracebackerror_details = traceback.format_exc()debug_logs = log_capture.getvalue() + f"\n\nβ ERROR:\n{error_details}"sys.stdout = original_stdout # Restore stdouterr = 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)finally:sys.stdout = original_stdout # Always restore stdout
app.py+2-2
student_interface.py+60-46