Skip to content

feat(admin): import a problem from JSON in the new-problem form - #129

Merged
barunaniket merged 1 commit into
mainfrom
feat/admin-json-import
Aug 17, 2026
Merged

feat(admin): import a problem from JSON in the new-problem form#129
barunaniket merged 1 commit into
mainfrom
feat/admin-json-import

Conversation

@barunaniket

Copy link
Copy Markdown
Collaborator

What

The admin New Problem page gains an "Import from JSON" panel: paste a problem in the challenge JSON schema (same shape as challenges/*.json) — or upload a .json file — and it fills the entire form: title / slug / date / difficulty / tags / limits, the Markdown statement / input / output / constraints, samples, hidden tests, and checker.

Behaviour

  • Parses defensively — invalid JSON, or a missing title / date / statement / samples / tests, is surfaced inline before anything loads.
  • Derives the slug from the title when the JSON omits it; falls back to Unrated / token for an unknown difficulty / checker.
  • Pre-fills only — the admin reviews the populated fields and clicks Create, and the server's AdminChallengeSchema still runs full validation on save. So a slightly-off import surfaces as the usual field-level errors, not a bad row.
  • Create mode only (the edit form keeps the slug locked). Purely client-side — no new endpoint or dependency.

Verified

tsc / eslint / next build green; the JSON → form mapping checked against a sample (slug derivation, tag join, samples/tests, float checker + epsilon, invalid-difficulty fallback).

Refs #82

The admin New Problem page now has an "Import from JSON" panel: paste a problem in
the challenge JSON schema (the same shape as challenges/*.json) or upload a .json
file, and it fills the whole form — title/slug/date/difficulty/tags/limits, the
Markdown prose, samples, hidden tests, and checker.

- Parses defensively (bad JSON or a missing title/date/statement/samples/tests is
  surfaced inline), derives the slug from the title when absent, and falls back for
  an unknown difficulty/checker. The server's AdminChallengeSchema still validates
  fully on save, so the import only pre-fills — the admin reviews before creating.
- Create mode only (edit keeps the slug locked). Purely client-side; no new endpoint.

tsc / eslint / next build green; the JSON -> form mapping verified against a sample.
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-chef-pesuecc-chapter Ready Ready Preview Aug 17, 2026 1:11am

@barunaniket
barunaniket merged commit 9b868ae into main Aug 17, 2026
3 checks passed
@barunaniket
barunaniket deleted the feat/admin-json-import branch August 17, 2026 07:07
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