Skip to content

feat(web): add Solution tab to the web UI - #31

Open
laitifranz wants to merge 2 commits into
duoan:masterfrom
laitifranz:feat/solution-web-tab
Open

laitifranz wants to merge 2 commits into
duoan:masterfrom
laitifranz:feat/solution-web-tab

Conversation

@laitifranz

Copy link
Copy Markdown
Contributor

Summary

Adds a Solution tab next to Problem and Test Results in the web UI. It shows the reference solution notebook for the current exercise, so users no longer have to open the solution notebooks by hand.

Changes

Backend (api/)

  • New endpoint GET /api/tasks/{task_id}/solution, which returns the solution as an ordered list of cells ({"cells": [{"type": "markdown" | "code", "source": "..."}]}). It returns 404 if the task has no solution.
  • New get_all_solutions() in api/parser.py, which parses every notebook in solutions/ once at startup.
    • The task id comes from the notebook's check("<id>") call, which is the judge id used in torch_judge.tasks. This is more reliable than the filename (e.g. 06_multihead_attention_solution.ipynb → mha). If a notebook has no check() call, the filename is used instead.
    • Notebook boilerplate is filtered out: Colab setup cells, the Colab badge, imports-only cells, # Verify / # Demo cells and the judge check(...) calls. Cells marked # ✅ SOLUTION are always kept.
  • All 41 tasks get a solution.

Frontend (web/)

  • New Solution tab. The solution is loaded only when the tab is opened, not when the exercise loads.
  • Markdown cells render with GFM and KaTeX, the same as the Problem tab.
  • Code cells are shown in read-only Monaco editors.
  • Icons added to all three tabs.

Screenshots

Screenshot 2026-10-06 at 13 32 54 Screenshot 2026-10-06 at 13 33 13

Notes

  • The solution is shown with no "reveal" step.
  • Tested by me during these months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant