feat(practice): store code submissions and practice states apart from attempts
This commit is contained in:
1 parent
d5e169e71b
commit
51770eea6c
61 files changed
+8584
-135
No files matched your search
@@ -1281,6 +1281,151 @@ paths:
|
||||
$ref: '#/components/responses/TooManyRequests'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs:
|
||||
post:
|
||||
operationId: CreateMyAssessmentPracticeRun
|
||||
summary: Start a debug run of a practice solution.
|
||||
description: |-
|
||||
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`).
|
||||
security:
|
||||
- sessionCookie: []
|
||||
sessionCsrf: []
|
||||
tags:
|
||||
- assessment
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/AssessmentAttemptId'
|
||||
- $ref: '#/components/parameters/IdempotencyKey'
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PracticeRunCreate'
|
||||
examples:
|
||||
run:
|
||||
summary: A Python solution with one test of the candidate.
|
||||
value:
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
|
||||
language: python
|
||||
source_code: |
|
||||
print(sum(map(int, input().split())))
|
||||
tests:
|
||||
- input: |
|
||||
2 3
|
||||
expected_output: |
|
||||
5
|
||||
responses:
|
||||
'202':
|
||||
description: The run is queued, or this request was already accepted and the stored run is returned.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: '#/components/headers/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PracticeRun'
|
||||
examples:
|
||||
queued:
|
||||
summary: A queued run.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
|
||||
state: queued
|
||||
created_at: '2026-10-05T09:30:00Z'
|
||||
finished_at: null
|
||||
failure_reason: null
|
||||
result: null
|
||||
'400':
|
||||
$ref: '#/components/responses/ValidationFailed'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
'409':
|
||||
$ref: '#/components/responses/StateConflict'
|
||||
'422':
|
||||
$ref: '#/components/responses/UnprocessableContent'
|
||||
'503':
|
||||
$ref: '#/components/responses/ServiceUnavailable'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}:
|
||||
get:
|
||||
operationId: GetMyAssessmentPracticeRun
|
||||
summary: Read a debug run of a practice solution.
|
||||
description: |-
|
||||
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.
|
||||
security:
|
||||
- sessionCookie: []
|
||||
tags:
|
||||
- assessment
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/AssessmentAttemptId'
|
||||
- name: run_id
|
||||
in: path
|
||||
required: true
|
||||
description: Identifier of a debug run of this attempt.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'200':
|
||||
description: The run.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: '#/components/headers/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PracticeRun'
|
||||
examples:
|
||||
finished:
|
||||
summary: A finished run whose test of the candidate failed.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
|
||||
state: finished
|
||||
created_at: '2026-10-05T09:30:00Z'
|
||||
finished_at: '2026-10-05T09:30:04Z'
|
||||
failure_reason: null
|
||||
result:
|
||||
outcome: wrong_answer
|
||||
compile_diagnostic: null
|
||||
tests:
|
||||
- source: example
|
||||
index: 1
|
||||
outcome: accepted
|
||||
time_ms: 21
|
||||
memory_kb: 9216
|
||||
diagnostic: null
|
||||
- source: candidate
|
||||
index: 1
|
||||
outcome: wrong_answer
|
||||
time_ms: 20
|
||||
memory_kb: 9180
|
||||
diagnostic: null
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/finalize:
|
||||
post:
|
||||
operationId: FinalizeMyAssessmentAttempt
|
||||
@@ -5714,6 +5859,175 @@ components:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/PracticeFailureReason'
|
||||
- type: 'null'
|
||||
PracticeRunTest:
|
||||
type: object
|
||||
description: 'One test of the candidate for a debug run: an input and the output the candidate expects. It is compared with the checker of the task.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- input
|
||||
- expected_output
|
||||
properties:
|
||||
input:
|
||||
type: string
|
||||
maxLength: 10000
|
||||
expected_output:
|
||||
type: string
|
||||
maxLength: 10000
|
||||
PracticeRunCreate:
|
||||
type: object
|
||||
description: Debug run of a practice solution against the public examples of the task and up to ten tests of the candidate. It never runs a hidden check and never changes the practice state, the verdict, or the attempt version. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- item_id
|
||||
- language
|
||||
- source_code
|
||||
properties:
|
||||
item_id:
|
||||
$ref: '#/components/schemas/AssessmentItemId'
|
||||
language:
|
||||
description: One of the `languages` of the practice item, or null when the item offers none.
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/TaskLanguage'
|
||||
- type: 'null'
|
||||
source_code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 65536
|
||||
tests:
|
||||
type: array
|
||||
maxItems: 10
|
||||
description: Tests of the candidate, run after the public examples.
|
||||
items:
|
||||
$ref: '#/components/schemas/PracticeRunTest'
|
||||
PracticeRunState:
|
||||
type: string
|
||||
description: |-
|
||||
State of a debug run.
|
||||
|
||||
- queued: the run waits in the sandbox queue.
|
||||
- running: the sandbox runs it.
|
||||
- finished: `result` holds the outcome of the public examples and the tests of the candidate.
|
||||
- failed: the sandbox infrastructure could not run it, independently of the solution; `failure_reason` is `sandbox_error`. Start a new run.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- queued
|
||||
- running
|
||||
- finished
|
||||
- failed
|
||||
PracticeRunOutcome:
|
||||
type: string
|
||||
description: Outcome of a run or one of its tests. Every outcome caused by the solution, such as a compilation error, a crash, or a limit, is a finished run with this outcome; an infrastructure failure is a failed run instead.
|
||||
enum:
|
||||
- accepted
|
||||
- wrong_answer
|
||||
- compile_error
|
||||
- time_limit_exceeded
|
||||
- memory_limit_exceeded
|
||||
- output_limit_exceeded
|
||||
- runtime_error
|
||||
PracticeRunTestSource:
|
||||
type: string
|
||||
description: 'Where a test of a debug run comes from: a public example of the task or a test of the candidate.'
|
||||
enum:
|
||||
- example
|
||||
- candidate
|
||||
PracticeRunTestResult:
|
||||
type: object
|
||||
description: Outcome of one evaluated test. The tests of a source stop at the first failed one, so later tests of that source are not listed.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- source
|
||||
- index
|
||||
- outcome
|
||||
- time_ms
|
||||
- memory_kb
|
||||
- diagnostic
|
||||
properties:
|
||||
source:
|
||||
$ref: '#/components/schemas/PracticeRunTestSource'
|
||||
index:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
description: Position of the test in its source, from 1.
|
||||
outcome:
|
||||
$ref: '#/components/schemas/PracticeRunOutcome'
|
||||
time_ms:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
memory_kb:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
diagnostic:
|
||||
description: Truncated error output of a failed test, or null.
|
||||
oneOf:
|
||||
- type: string
|
||||
maxLength: 2048
|
||||
- type: 'null'
|
||||
PracticeRunResult:
|
||||
type: object
|
||||
description: Result of a debug run on the public examples and the tests of the candidate. It never contains a hidden check, its outcome, or the score.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- outcome
|
||||
- compile_diagnostic
|
||||
- tests
|
||||
properties:
|
||||
outcome:
|
||||
$ref: '#/components/schemas/PracticeRunOutcome'
|
||||
compile_diagnostic:
|
||||
description: The compiler message when `outcome` is `compile_error`, otherwise null.
|
||||
oneOf:
|
||||
- type: string
|
||||
maxLength: 4096
|
||||
- type: 'null'
|
||||
tests:
|
||||
type: array
|
||||
maxItems: 20
|
||||
items:
|
||||
$ref: '#/components/schemas/PracticeRunTestResult'
|
||||
PracticeRun:
|
||||
type: object
|
||||
description: Debug run of a practice solution. It shows only the public examples and the tests of the candidate; hidden checks are never run, listed, or scored by a debug run.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- item_id
|
||||
- state
|
||||
- created_at
|
||||
- finished_at
|
||||
- failure_reason
|
||||
- result
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the run.
|
||||
item_id:
|
||||
$ref: '#/components/schemas/AssessmentItemId'
|
||||
state:
|
||||
$ref: '#/components/schemas/PracticeRunState'
|
||||
created_at:
|
||||
$ref: '#/components/schemas/Timestamp'
|
||||
finished_at:
|
||||
description: Time the run reached `finished` or `failed`, or null.
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/Timestamp'
|
||||
- type: 'null'
|
||||
failure_reason:
|
||||
description: '`sandbox_error` when `state` is `failed`, otherwise null.'
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/PracticeFailureReason'
|
||||
- type: 'null'
|
||||
result:
|
||||
description: The result when `state` is `finished`, otherwise null.
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/PracticeRunResult'
|
||||
- type: 'null'
|
||||
AssessmentAttempt:
|
||||
description: Candidate view of a real assessment, a corrective real assessment, or a demo_express training run. The variants keep training output separate from qualification attempts.
|
||||
oneOf:
|
||||
@@ -12407,6 +12721,23 @@ components:
|
||||
$ref: '#/components/examples/VerificationCodeInvalid'
|
||||
validation_failed:
|
||||
$ref: '#/components/examples/VerificationCodeMalformed'
|
||||
ServiceUnavailable:
|
||||
description: The service cannot serve the request now; code service_unavailable. Retry-After is sent when a retry after that wait can succeed, for example when a queue is full, and omitted when a retry cannot help soon, for example when the feature is not enabled on this server.
|
||||
headers:
|
||||
Retry-After:
|
||||
$ref: '#/components/headers/RetryAfter'
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
service_unavailable:
|
||||
summary: A queue is full.
|
||||
value:
|
||||
type: urn:lincodex:problem:service_unavailable
|
||||
title: Service unavailable
|
||||
status: 503
|
||||
code: service_unavailable
|
||||
securitySchemes:
|
||||
sessionCookie:
|
||||
type: apiKey
|
||||
|
||||
Reference in new issue
Block a user