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

@@ -9746,6 +9746,30 @@ type CreateMyAssessmentAttemptUnprocessableEntity Problem
func (*CreateMyAssessmentAttemptUnprocessableEntity) createMyAssessmentAttemptRes() {}
type CreateMyAssessmentPracticeRunBadRequest Problem
func (*CreateMyAssessmentPracticeRunBadRequest) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunConflict Problem
func (*CreateMyAssessmentPracticeRunConflict) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunForbidden Problem
func (*CreateMyAssessmentPracticeRunForbidden) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunNotFound Problem
func (*CreateMyAssessmentPracticeRunNotFound) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunUnauthorized Problem
func (*CreateMyAssessmentPracticeRunUnauthorized) createMyAssessmentPracticeRunRes() {}
type CreateMyAssessmentPracticeRunUnprocessableEntity Problem
func (*CreateMyAssessmentPracticeRunUnprocessableEntity) createMyAssessmentPracticeRunRes() {}
type CreateMySupportCaseBadRequest Problem
func (*CreateMySupportCaseBadRequest) createMySupportCaseRes() {}
@@ -10991,6 +11015,18 @@ type GetMyAssessmentAvailabilityUnauthorized Problem
func (*GetMyAssessmentAvailabilityUnauthorized) getMyAssessmentAvailabilityRes() {}
type GetMyAssessmentPracticeRunForbidden Problem
func (*GetMyAssessmentPracticeRunForbidden) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentPracticeRunNotFound Problem
func (*GetMyAssessmentPracticeRunNotFound) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentPracticeRunUnauthorized Problem
func (*GetMyAssessmentPracticeRunUnauthorized) getMyAssessmentPracticeRunRes() {}
type GetMyAssessmentResultConflict Problem
func (*GetMyAssessmentResultConflict) getMyAssessmentResultRes() {}
@@ -19952,6 +19988,51 @@ func (o NilPracticeFailureReason) Or(d PracticeFailureReason) PracticeFailureRea
return d
}
// NewNilPracticeRunResult returns new NilPracticeRunResult with value set to v.
func NewNilPracticeRunResult(v PracticeRunResult) NilPracticeRunResult {
return NilPracticeRunResult{
Value: v,
}
}
// NilPracticeRunResult is nullable PracticeRunResult.
type NilPracticeRunResult struct {
Value PracticeRunResult
Null bool
}
// SetTo sets value to v.
func (o *NilPracticeRunResult) SetTo(v PracticeRunResult) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilPracticeRunResult) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilPracticeRunResult) SetToNull() {
o.Null = true
var v PracticeRunResult
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilPracticeRunResult) Get() (v PracticeRunResult, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilPracticeRunResult) Or(d PracticeRunResult) PracticeRunResult {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilPracticeVerdict returns new NilPracticeVerdict with value set to v.
func NewNilPracticeVerdict(v PracticeVerdict) NilPracticeVerdict {
return NilPracticeVerdict{
@@ -25883,6 +25964,505 @@ func (s *PracticeKind) UnmarshalText(data []byte) error {
}
}
// 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.
// Ref: #/components/schemas/PracticeRun
type PracticeRun struct {
// Identifier of the run.
ID uuid.UUID `json:"id"`
ItemID AssessmentItemId `json:"item_id"`
State PracticeRunState `json:"state"`
CreatedAt Timestamp `json:"created_at"`
// Time the run reached `finished` or `failed`, or null.
FinishedAt NilTimestamp `json:"finished_at"`
// `sandbox_error` when `state` is `failed`, otherwise null.
FailureReason NilPracticeFailureReason `json:"failure_reason"`
// The result when `state` is `finished`, otherwise null.
Result NilPracticeRunResult `json:"result"`
}
// GetID returns the value of ID.
func (s *PracticeRun) GetID() uuid.UUID {
return s.ID
}
// GetItemID returns the value of ItemID.
func (s *PracticeRun) GetItemID() AssessmentItemId {
return s.ItemID
}
// GetState returns the value of State.
func (s *PracticeRun) GetState() PracticeRunState {
return s.State
}
// GetCreatedAt returns the value of CreatedAt.
func (s *PracticeRun) GetCreatedAt() Timestamp {
return s.CreatedAt
}
// GetFinishedAt returns the value of FinishedAt.
func (s *PracticeRun) GetFinishedAt() NilTimestamp {
return s.FinishedAt
}
// GetFailureReason returns the value of FailureReason.
func (s *PracticeRun) GetFailureReason() NilPracticeFailureReason {
return s.FailureReason
}
// GetResult returns the value of Result.
func (s *PracticeRun) GetResult() NilPracticeRunResult {
return s.Result
}
// SetID sets the value of ID.
func (s *PracticeRun) SetID(val uuid.UUID) {
s.ID = val
}
// SetItemID sets the value of ItemID.
func (s *PracticeRun) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// SetState sets the value of State.
func (s *PracticeRun) SetState(val PracticeRunState) {
s.State = val
}
// SetCreatedAt sets the value of CreatedAt.
func (s *PracticeRun) SetCreatedAt(val Timestamp) {
s.CreatedAt = val
}
// SetFinishedAt sets the value of FinishedAt.
func (s *PracticeRun) SetFinishedAt(val NilTimestamp) {
s.FinishedAt = val
}
// SetFailureReason sets the value of FailureReason.
func (s *PracticeRun) SetFailureReason(val NilPracticeFailureReason) {
s.FailureReason = val
}
// SetResult sets the value of Result.
func (s *PracticeRun) SetResult(val NilPracticeRunResult) {
s.Result = val
}
// 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.
// Ref: #/components/schemas/PracticeRunCreate
type PracticeRunCreate struct {
ItemID AssessmentItemId `json:"item_id"`
// One of the `languages` of the practice item, or null when the item offers none.
Language NilTaskLanguage `json:"language"`
SourceCode string `json:"source_code"`
// Tests of the candidate, run after the public examples.
Tests []PracticeRunTest `json:"tests"`
}
// GetItemID returns the value of ItemID.
func (s *PracticeRunCreate) GetItemID() AssessmentItemId {
return s.ItemID
}
// GetLanguage returns the value of Language.
func (s *PracticeRunCreate) GetLanguage() NilTaskLanguage {
return s.Language
}
// GetSourceCode returns the value of SourceCode.
func (s *PracticeRunCreate) GetSourceCode() string {
return s.SourceCode
}
// GetTests returns the value of Tests.
func (s *PracticeRunCreate) GetTests() []PracticeRunTest {
return s.Tests
}
// SetItemID sets the value of ItemID.
func (s *PracticeRunCreate) SetItemID(val AssessmentItemId) {
s.ItemID = val
}
// SetLanguage sets the value of Language.
func (s *PracticeRunCreate) SetLanguage(val NilTaskLanguage) {
s.Language = val
}
// SetSourceCode sets the value of SourceCode.
func (s *PracticeRunCreate) SetSourceCode(val string) {
s.SourceCode = val
}
// SetTests sets the value of Tests.
func (s *PracticeRunCreate) SetTests(val []PracticeRunTest) {
s.Tests = val
}
// PracticeRunHeaders wraps PracticeRun with response headers.
type PracticeRunHeaders struct {
CacheControl CacheControlNoStore
Response PracticeRun
}
// GetCacheControl returns the value of CacheControl.
func (s *PracticeRunHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *PracticeRunHeaders) GetResponse() PracticeRun {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *PracticeRunHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *PracticeRunHeaders) SetResponse(val PracticeRun) {
s.Response = val
}
func (*PracticeRunHeaders) createMyAssessmentPracticeRunRes() {}
func (*PracticeRunHeaders) getMyAssessmentPracticeRunRes() {}
// 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.
// Ref: #/components/schemas/PracticeRunOutcome
type PracticeRunOutcome string
const (
PracticeRunOutcomeAccepted PracticeRunOutcome = "accepted"
PracticeRunOutcomeWrongAnswer PracticeRunOutcome = "wrong_answer"
PracticeRunOutcomeCompileError PracticeRunOutcome = "compile_error"
PracticeRunOutcomeTimeLimitExceeded PracticeRunOutcome = "time_limit_exceeded"
PracticeRunOutcomeMemoryLimitExceeded PracticeRunOutcome = "memory_limit_exceeded"
PracticeRunOutcomeOutputLimitExceeded PracticeRunOutcome = "output_limit_exceeded"
PracticeRunOutcomeRuntimeError PracticeRunOutcome = "runtime_error"
)
// AllValues returns all PracticeRunOutcome values.
func (PracticeRunOutcome) AllValues() []PracticeRunOutcome {
return []PracticeRunOutcome{
PracticeRunOutcomeAccepted,
PracticeRunOutcomeWrongAnswer,
PracticeRunOutcomeCompileError,
PracticeRunOutcomeTimeLimitExceeded,
PracticeRunOutcomeMemoryLimitExceeded,
PracticeRunOutcomeOutputLimitExceeded,
PracticeRunOutcomeRuntimeError,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunOutcome) MarshalText() ([]byte, error) {
switch s {
case PracticeRunOutcomeAccepted:
return []byte(s), nil
case PracticeRunOutcomeWrongAnswer:
return []byte(s), nil
case PracticeRunOutcomeCompileError:
return []byte(s), nil
case PracticeRunOutcomeTimeLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeMemoryLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeOutputLimitExceeded:
return []byte(s), nil
case PracticeRunOutcomeRuntimeError:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunOutcome) UnmarshalText(data []byte) error {
switch PracticeRunOutcome(data) {
case PracticeRunOutcomeAccepted:
*s = PracticeRunOutcomeAccepted
return nil
case PracticeRunOutcomeWrongAnswer:
*s = PracticeRunOutcomeWrongAnswer
return nil
case PracticeRunOutcomeCompileError:
*s = PracticeRunOutcomeCompileError
return nil
case PracticeRunOutcomeTimeLimitExceeded:
*s = PracticeRunOutcomeTimeLimitExceeded
return nil
case PracticeRunOutcomeMemoryLimitExceeded:
*s = PracticeRunOutcomeMemoryLimitExceeded
return nil
case PracticeRunOutcomeOutputLimitExceeded:
*s = PracticeRunOutcomeOutputLimitExceeded
return nil
case PracticeRunOutcomeRuntimeError:
*s = PracticeRunOutcomeRuntimeError
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// 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.
// Ref: #/components/schemas/PracticeRunResult
type PracticeRunResult struct {
Outcome PracticeRunOutcome `json:"outcome"`
// The compiler message when `outcome` is `compile_error`, otherwise null.
CompileDiagnostic NilString `json:"compile_diagnostic"`
Tests []PracticeRunTestResult `json:"tests"`
}
// GetOutcome returns the value of Outcome.
func (s *PracticeRunResult) GetOutcome() PracticeRunOutcome {
return s.Outcome
}
// GetCompileDiagnostic returns the value of CompileDiagnostic.
func (s *PracticeRunResult) GetCompileDiagnostic() NilString {
return s.CompileDiagnostic
}
// GetTests returns the value of Tests.
func (s *PracticeRunResult) GetTests() []PracticeRunTestResult {
return s.Tests
}
// SetOutcome sets the value of Outcome.
func (s *PracticeRunResult) SetOutcome(val PracticeRunOutcome) {
s.Outcome = val
}
// SetCompileDiagnostic sets the value of CompileDiagnostic.
func (s *PracticeRunResult) SetCompileDiagnostic(val NilString) {
s.CompileDiagnostic = val
}
// SetTests sets the value of Tests.
func (s *PracticeRunResult) SetTests(val []PracticeRunTestResult) {
s.Tests = val
}
// 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.
// Ref: #/components/schemas/PracticeRunState
type PracticeRunState string
const (
PracticeRunStateQueued PracticeRunState = "queued"
PracticeRunStateRunning PracticeRunState = "running"
PracticeRunStateFinished PracticeRunState = "finished"
PracticeRunStateFailed PracticeRunState = "failed"
)
// AllValues returns all PracticeRunState values.
func (PracticeRunState) AllValues() []PracticeRunState {
return []PracticeRunState{
PracticeRunStateQueued,
PracticeRunStateRunning,
PracticeRunStateFinished,
PracticeRunStateFailed,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunState) MarshalText() ([]byte, error) {
switch s {
case PracticeRunStateQueued:
return []byte(s), nil
case PracticeRunStateRunning:
return []byte(s), nil
case PracticeRunStateFinished:
return []byte(s), nil
case PracticeRunStateFailed:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunState) UnmarshalText(data []byte) error {
switch PracticeRunState(data) {
case PracticeRunStateQueued:
*s = PracticeRunStateQueued
return nil
case PracticeRunStateRunning:
*s = PracticeRunStateRunning
return nil
case PracticeRunStateFinished:
*s = PracticeRunStateFinished
return nil
case PracticeRunStateFailed:
*s = PracticeRunStateFailed
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// 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.
// Ref: #/components/schemas/PracticeRunTest
type PracticeRunTest struct {
Input string `json:"input"`
ExpectedOutput string `json:"expected_output"`
}
// GetInput returns the value of Input.
func (s *PracticeRunTest) GetInput() string {
return s.Input
}
// GetExpectedOutput returns the value of ExpectedOutput.
func (s *PracticeRunTest) GetExpectedOutput() string {
return s.ExpectedOutput
}
// SetInput sets the value of Input.
func (s *PracticeRunTest) SetInput(val string) {
s.Input = val
}
// SetExpectedOutput sets the value of ExpectedOutput.
func (s *PracticeRunTest) SetExpectedOutput(val string) {
s.ExpectedOutput = val
}
// 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.
// Ref: #/components/schemas/PracticeRunTestResult
type PracticeRunTestResult struct {
Source PracticeRunTestSource `json:"source"`
// Position of the test in its source, from 1.
Index int32 `json:"index"`
Outcome PracticeRunOutcome `json:"outcome"`
TimeMs int64 `json:"time_ms"`
MemoryKB int64 `json:"memory_kb"`
// Truncated error output of a failed test, or null.
Diagnostic NilString `json:"diagnostic"`
}
// GetSource returns the value of Source.
func (s *PracticeRunTestResult) GetSource() PracticeRunTestSource {
return s.Source
}
// GetIndex returns the value of Index.
func (s *PracticeRunTestResult) GetIndex() int32 {
return s.Index
}
// GetOutcome returns the value of Outcome.
func (s *PracticeRunTestResult) GetOutcome() PracticeRunOutcome {
return s.Outcome
}
// GetTimeMs returns the value of TimeMs.
func (s *PracticeRunTestResult) GetTimeMs() int64 {
return s.TimeMs
}
// GetMemoryKB returns the value of MemoryKB.
func (s *PracticeRunTestResult) GetMemoryKB() int64 {
return s.MemoryKB
}
// GetDiagnostic returns the value of Diagnostic.
func (s *PracticeRunTestResult) GetDiagnostic() NilString {
return s.Diagnostic
}
// SetSource sets the value of Source.
func (s *PracticeRunTestResult) SetSource(val PracticeRunTestSource) {
s.Source = val
}
// SetIndex sets the value of Index.
func (s *PracticeRunTestResult) SetIndex(val int32) {
s.Index = val
}
// SetOutcome sets the value of Outcome.
func (s *PracticeRunTestResult) SetOutcome(val PracticeRunOutcome) {
s.Outcome = val
}
// SetTimeMs sets the value of TimeMs.
func (s *PracticeRunTestResult) SetTimeMs(val int64) {
s.TimeMs = val
}
// SetMemoryKB sets the value of MemoryKB.
func (s *PracticeRunTestResult) SetMemoryKB(val int64) {
s.MemoryKB = val
}
// SetDiagnostic sets the value of Diagnostic.
func (s *PracticeRunTestResult) SetDiagnostic(val NilString) {
s.Diagnostic = val
}
// Where a test of a debug run comes from: a public example of the task or a test of the candidate.
// Ref: #/components/schemas/PracticeRunTestSource
type PracticeRunTestSource string
const (
PracticeRunTestSourceExample PracticeRunTestSource = "example"
PracticeRunTestSourceCandidate PracticeRunTestSource = "candidate"
)
// AllValues returns all PracticeRunTestSource values.
func (PracticeRunTestSource) AllValues() []PracticeRunTestSource {
return []PracticeRunTestSource{
PracticeRunTestSourceExample,
PracticeRunTestSourceCandidate,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s PracticeRunTestSource) MarshalText() ([]byte, error) {
switch s {
case PracticeRunTestSourceExample:
return []byte(s), nil
case PracticeRunTestSourceCandidate:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *PracticeRunTestSource) UnmarshalText(data []byte) error {
switch PracticeRunTestSource(data) {
case PracticeRunTestSourceExample:
*s = PracticeRunTestSourceExample
return nil
case PracticeRunTestSourceCandidate:
*s = PracticeRunTestSourceCandidate
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// State of a practice.
//
// - not_started: no solution was submitted yet.
@@ -29631,6 +30211,34 @@ type SendOrganizationInvitationUnprocessableEntity Problem
func (*SendOrganizationInvitationUnprocessableEntity) sendOrganizationInvitationRes() {}
// ServiceUnavailableHeaders wraps Problem with response headers.
type ServiceUnavailableHeaders struct {
RetryAfter OptInt32
Response Problem
}
// GetRetryAfter returns the value of RetryAfter.
func (s *ServiceUnavailableHeaders) GetRetryAfter() OptInt32 {
return s.RetryAfter
}
// GetResponse returns the value of Response.
func (s *ServiceUnavailableHeaders) GetResponse() Problem {
return s.Response
}
// SetRetryAfter sets the value of RetryAfter.
func (s *ServiceUnavailableHeaders) SetRetryAfter(val OptInt32) {
s.RetryAfter = val
}
// SetResponse sets the value of Response.
func (s *ServiceUnavailableHeaders) SetResponse(val Problem) {
s.Response = val
}
func (*ServiceUnavailableHeaders) createMyAssessmentPracticeRunRes() {}
// Current session as the client may see it: the account and the CSRF token. The session identifier
// itself travels only in the HttpOnly session cookie and never appears in a body.
// Ref: #/components/schemas/Session