feat(admin): import a problem from JSON in the new-problem form - #129
Merged
Conversation
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.
barunaniket
requested review from
hagemaruwu,
shivanshpap and
vaibhavtulsian
as code owners
August 17, 2026 01:10
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonfile — and it fills the entire form: title / slug / date / difficulty / tags / limits, the Markdown statement / input / output / constraints, samples, hidden tests, and checker.Behaviour
title/date/statement/samples/tests, is surfaced inline before anything loads.Unrated/tokenfor an unknown difficulty / checker.AdminChallengeSchemastill runs full validation on save. So a slightly-off import surfaces as the usual field-level errors, not a bad row.Verified
tsc/eslint/next buildgreen; the JSON → form mapping checked against a sample (slug derivation, tag join, samples/tests, float checker + epsilon, invalid-difficulty fallback).Refs #82