feat(practice): store code submissions and practice states apart from attempts

This commit is contained in:
shira committed 2026-10-11 14:58:04 +03:00
1 parent d5e169e71b
commit 51770eea6c
61 files changed
+8584 -135

No files matched your search

@@ -230,6 +230,39 @@ type Handler interface {
//
// POST /api/v1/me/assessment-attempts
CreateMyAssessmentAttempt(ctx context.Context, req AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
// CreateMyAssessmentPracticeRun implements CreateMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
// an allowed Origin, and an Idempotency-Key. The body names the practice item of the attempt and
// carries the language, the source, and up to ten tests of the candidate.
//
// A debug run executes the solution in the isolated sandbox against the public examples of the task
// and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes
// neither the practice state, the verdict, nor the attempt version; the graded solution is submitted
// with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed
// asynchronously: the response is 202 with the run `queued`, and the client polls
// GetMyAssessmentPracticeRun. The source is never echoed.
//
// The practice must be the current item: the attempt is in `practice_pending` for the main practice or
// `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the
// server answers 409 state_conflict.
//
// Availability. When code practice is not enabled on this server, the server answers 503
// service_unavailable and stores nothing.
//
// Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in
// its current state with 202, without starting another run. A different body with the same key answers
// 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are
// evaluated again.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422,
// replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of
// another candidate), the state (409), then the solution against the item (400 with a pointer such as
// `/language` or `/source_code`).
//
// POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs
CreateMyAssessmentPracticeRun(ctx context.Context, req *PracticeRunCreate, params CreateMyAssessmentPracticeRunParams) (CreateMyAssessmentPracticeRunRes, error)
// CreateMySupportCase implements CreateMySupportCase operation.
//
// Requires the session cookie, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and
@@ -627,6 +660,19 @@ type Handler interface {
//
// GET /api/v1/me/assessment-availability
GetMyAssessmentAvailability(ctx context.Context) (GetMyAssessmentAvailabilityRes, error)
// GetMyAssessmentPracticeRun implements GetMyAssessmentPracticeRun operation.
//
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
// CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of
// the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source.
// This GET is read-only.
//
// A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer
// 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is
// not readable here.
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}
GetMyAssessmentPracticeRun(ctx context.Context, params GetMyAssessmentPracticeRunParams) (GetMyAssessmentPracticeRunRes, error)
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
//
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal