feat(assessment): define corrective and training attempt contracts
This commit is contained in:
1 parent
fade4e76e4
commit
20c03288d6
71 files changed
+14786
-1743
No files matched your search
@@ -785,27 +785,33 @@ func (s *Server) handleConfirmEmailRequest(args [0]string, argsEscaped bool, w h
|
||||
// handleCreateMyAssessmentAttemptRequest handles CreateMyAssessmentAttempt 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 category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
// an allowed Origin, and an Idempotency-Key. The request is one of three disjoint shapes. A real
|
||||
// assessment names a specialization, target grade, and task language; the server picks `demo_basic` or
|
||||
// `adaptive` and fixes the policy, bank, and algorithm versions, limits, and item variants. A
|
||||
// corrective real assessment also names `root_attempt_id`; the server verifies the lower-grade chain
|
||||
// and reuses its fixed quota and deadline. The client never sends a real mode, a seed, a version, or a
|
||||
// chain deadline. Explicit `demo_express` starts a separate interactive training run that lasts 3 to 5
|
||||
// minutes, has no category or target grade, and creates no qualification evidence or percentile.
|
||||
// Creation starts session 1. The self-assessed grade only chooses where a real test starts and adds no
|
||||
// points. An adaptive retest starts from the previous ability estimate of the specialization, adjusted
|
||||
// for the time passed, so a new attempt adds evidence instead of starting the measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
// A specialization has at most one active real attempt. A new root attempt cannot start while one is
|
||||
// active, during a retry or promotion interval, past the root quota, or when the bank is insufficient;
|
||||
// each such preflight refusal answers 409 state_conflict and creates nothing or consumes no root slot.
|
||||
// Starting a root attempt reserves one slot in the root quota. A corrective attempt must reference its
|
||||
// root, target a strictly lower grade not already attempted in that chain, and remain inside the
|
||||
// root's fixed quota and deadline (72 hours from the root start in the current policy). It gets its
|
||||
// own item, practice, and session limits, but spends no additional root slot and cannot reset the
|
||||
// chain deadline or any 30/90-day timer. After a failure, including the first test, a lower grade can
|
||||
// be tested at once. An expired or incomplete attempt does not create a free new chain; an
|
||||
// insufficient bank or sandbox failure does not grant another root slot. `demo_express` is outside
|
||||
// real-assessment availability, quotas, retry intervals, and qualification history.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
// clock never extends them, and after them the attempt accepts no work command. For a corrective
|
||||
// attempt, `expires_at` is no later than the root's immutable `chain_deadline`. Within these limits
|
||||
// the attempt is also bounded by the item limit of its policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
@@ -988,7 +994,7 @@ func (s *Server) handleCreateMyAssessmentAttemptRequest(args [0]string, argsEsca
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: CreateMyAssessmentAttemptOperation,
|
||||
OperationSummary: "Start an assessment attempt for a category of the current candidate.",
|
||||
OperationSummary: "Start a real, corrective, or training assessment attempt.",
|
||||
OperationID: "CreateMyAssessmentAttempt",
|
||||
Body: request,
|
||||
RawBody: rawBody,
|
||||
@@ -1002,7 +1008,7 @@ func (s *Server) handleCreateMyAssessmentAttemptRequest(args [0]string, argsEsca
|
||||
}
|
||||
|
||||
type (
|
||||
Request = *AssessmentAttemptCreate
|
||||
Request = AssessmentAttemptCreate
|
||||
Params = CreateMyAssessmentAttemptParams
|
||||
Response = CreateMyAssessmentAttemptRes
|
||||
)
|
||||
@@ -2466,6 +2472,11 @@ func (s *Server) handleDeclineMyInvitationRequest(args [1]string, argsEscaped bo
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Finalize is a work command and requires an active session. After `idle_timeout_seconds` of
|
||||
// inactivity, the candidate first calls StartMyAssessmentAttemptSession with the latest
|
||||
// `expected_version`; finalize never starts a session. GET attempt and result operations do not change
|
||||
// state. A command or background transition may commit a due deadline outcome.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
@@ -2487,9 +2498,9 @@ func (s *Server) handleDeclineMyInvitationRequest(args [1]string, argsEscaped bo
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
// once. When `expires_at` passes or the session limit is reached, a command or background transition
|
||||
// finalizes `ready_to_finalize` without offering an additional practice. A finalize after this
|
||||
// transition answers 200 with the stored `completed` attempt; a GET never commits it.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
@@ -2498,8 +2509,9 @@ func (s *Server) handleDeclineMyInvitationRequest(args [1]string, argsEscaped bo
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the attempt (404 not_found; a due deadline transition may be committed, but this request never
|
||||
// starts a work session), the repeat on a `completed` attempt (200), the version (412), then the state
|
||||
// (409 state_conflict, including an ended idle session). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
@@ -3408,24 +3420,25 @@ func (s *Server) handleGetHealthzRequest(args [0]string, argsEscaped bool, w htt
|
||||
|
||||
// handleGetMyAssessmentAttemptRequest handles GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
// Requires the session cookie of a candidate account. Returns the stored attempt projection with its
|
||||
// state, fixed versions, time and session limits, progress, the item to answer now, and the practices.
|
||||
// This GET is read-only: it never starts or resumes a work session, consumes session quota, advances
|
||||
// the version, or commits expiry or finalization. A reload, a retried request, or a new session
|
||||
// returns the same item instance with the same text and option order; a lost connection never creates
|
||||
// a new attempt. After `idle_timeout_seconds`, the candidate explicitly starts or resumes work with
|
||||
// StartMyAssessmentAttemptSession. The response never says whether an earlier answer was correct and
|
||||
// never contains answer keys, item scores, family or variant identifiers, seeds, hidden checks, or
|
||||
// anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
// When the deadline passes, this read still returns the stored state and deadline. A command or
|
||||
// background transition commits the due outcome; if the stored state is still active,
|
||||
// GetMyAssessmentResult answers 409 until that transition is committed. The client polls this
|
||||
// operation while a practice is `pending`, but polling alone never changes attempt state.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
// answers 403 forbidden; no operation gives an employer the answers, qualification evidence, or
|
||||
// attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
func (s *Server) handleGetMyAssessmentAttemptRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -3563,7 +3576,7 @@ func (s *Server) handleGetMyAssessmentAttemptRequest(args [1]string, argsEscaped
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: GetMyAssessmentAttemptOperation,
|
||||
OperationSummary: "Read or resume an assessment attempt of the current candidate.",
|
||||
OperationSummary: "Read an assessment attempt of the current candidate.",
|
||||
OperationID: "GetMyAssessmentAttempt",
|
||||
Body: nil,
|
||||
RawBody: rawBody,
|
||||
@@ -3826,21 +3839,25 @@ func (s *Server) handleGetMyAssessmentAvailabilityRequest(args [0]string, argsEs
|
||||
// handleGetMyAssessmentResultRequest handles GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. A real result records the mode, policy,
|
||||
// bank, and algorithm versions, decision, previously confirmed grade, calibration status and
|
||||
// limitations, uncertainty where the method computes it, practice verdicts, weak domains, working time
|
||||
// as a separate label, and allowed next steps. A corrective result also carries the root attempt and
|
||||
// its immutable chain deadline. A `demo_express` result is a short educational summary only: it has no
|
||||
// category, percentile, confirmed grade, score, uncertainty, or qualification evidence. A later
|
||||
// policy, bank, or algorithm version never changes a result.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
// and has no result yet. This GET is read-only and never commits a due transition. If a deadline has
|
||||
// passed but the due transition is not yet stored by a command or background worker, the attempt
|
||||
// remains active for this read and answers 409; wait for the transition and retry. An attempt of
|
||||
// another candidate answers 404 not_found, the same as an unknown identifier. An employer account
|
||||
// answers 403 forbidden; employers see only the current category through a separate projection, never
|
||||
// this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
func (s *Server) handleGetMyAssessmentResultRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -10876,6 +10893,262 @@ func (s *Server) handleSetMySearchStatusRequest(args [0]string, argsEscaped bool
|
||||
}
|
||||
}
|
||||
|
||||
// handleStartMyAssessmentAttemptSessionRequest handles StartMyAssessmentAttemptSession operation.
|
||||
//
|
||||
// Requires a candidate session, its CSRF token in X-CSRF-Token, an allowed Origin, and an
|
||||
// Idempotency-Key. The body carries the attempt version the candidate last read. The server checks
|
||||
// ownership, idempotency, and `expected_version` atomically before starting a session; a stale version
|
||||
// answers 412 and consumes no session. Repeating the same key and body within 24 hours replays the
|
||||
// stored response.
|
||||
//
|
||||
// Creation starts session 1. After `idle_timeout_seconds` of inactivity, the candidate uses this
|
||||
// command to start the next session. Calling it while a session is already active returns the current
|
||||
// attempt without consuming another session or advancing its version. Starting a session advances the
|
||||
// version once. The command cannot extend `expires_at` or `chain_deadline`.
|
||||
//
|
||||
// If the attempt deadline or session budget has passed, this command commits the due terminal
|
||||
// transition and returns the resulting attempt. A pending practice submitted before the limit is
|
||||
// graded first. `GetMyAssessmentAttempt` and `GetMyAssessmentResult` remain read-only: they never
|
||||
// start a session or commit a due transition. A background transition may persist a due outcome
|
||||
// independently; after that, this command returns the stored terminal attempt without changing it.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session. An attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier. An employer account answers 403 forbidden; no
|
||||
// operation gives an employer answers, qualification evidence, or attempt history.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/sessions
|
||||
func (s *Server) handleStartMyAssessmentAttemptSessionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("StartMyAssessmentAttemptSession"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/me/assessment-attempts/{attempt_id}/sessions"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), StartMyAssessmentAttemptSessionOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Add Labeler to context.
|
||||
labeler := &Labeler{attrs: otelAttrs}
|
||||
ctx = contextWithLabeler(ctx, labeler)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
code := statusWriter.status
|
||||
if code != 0 {
|
||||
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||
attrs = append(attrs, codeAttr)
|
||||
span.SetAttributes(attrs...)
|
||||
}
|
||||
attrOpt := metric.WithAttributes(attrs...)
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, attrOpt)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||
}()
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
|
||||
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
if code != 0 {
|
||||
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||
}
|
||||
|
||||
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: StartMyAssessmentAttemptSessionOperation,
|
||||
ID: "StartMyAssessmentAttemptSession",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCookie(ctx, StartMyAssessmentAttemptSessionOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCookie",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCookie", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 0
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCsrf(ctx, StartMyAssessmentAttemptSessionOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCsrf",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCsrf", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 1
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
|
||||
if ok := func() bool {
|
||||
nextRequirement:
|
||||
for _, requirement := range []bitset{
|
||||
{0b00000011},
|
||||
} {
|
||||
for i, mask := range requirement {
|
||||
if satisfied[i]&mask != mask {
|
||||
continue nextRequirement
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}(); !ok {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
params, err := decodeStartMyAssessmentAttemptSessionParams(args, argsEscaped, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
defer recordError("DecodeParams", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
var rawBody []byte
|
||||
request, rawBody, close, err := s.decodeStartMyAssessmentAttemptSessionRequest(r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeRequestError{
|
||||
OperationContext: opErrContext,
|
||||
Err: err,
|
||||
}
|
||||
defer recordError("DecodeRequest", err)
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
if err := close(); err != nil {
|
||||
recordError("CloseRequest", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var response StartMyAssessmentAttemptSessionRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: StartMyAssessmentAttemptSessionOperation,
|
||||
OperationSummary: "Start or resume a work session for the current candidate's attempt.",
|
||||
OperationID: "StartMyAssessmentAttemptSession",
|
||||
Body: request,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}: params.AttemptID,
|
||||
{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}: params.IdempotencyKey,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = *AssessmentAttemptSessionStart
|
||||
Params = StartMyAssessmentAttemptSessionParams
|
||||
Response = StartMyAssessmentAttemptSessionRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackStartMyAssessmentAttemptSessionParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.StartMyAssessmentAttemptSession(ctx, request, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.StartMyAssessmentAttemptSession(ctx, request, params)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
|
||||
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ht.ErrNotImplemented) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeStartMyAssessmentAttemptSessionResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleSubmitMyAssessmentAnswerRequest handles SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -10888,6 +11161,12 @@ func (s *Server) handleSetMySearchStatusRequest(args [0]string, argsEscaped bool
|
||||
// The response is the attempt with the next item to answer. It never says whether the answer was
|
||||
// correct. Items are answered in order and each answer is final.
|
||||
//
|
||||
// A work command requires an active session. After `idle_timeout_seconds` of inactivity, the candidate
|
||||
// calls StartMyAssessmentAttemptSession to explicitly start or resume a session; this answer command
|
||||
// never starts one or consumes session quota. Reading the attempt or result is always read-only. A
|
||||
// command that finds a due deadline transition may commit it before returning; a command that finds an
|
||||
// expired idle session answers 409 until the candidate explicitly starts the next session.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
@@ -10921,15 +11200,14 @@ func (s *Server) handleSetMySearchStatusRequest(args [0]string, argsEscaped bool
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; a due deadline
|
||||
// transition may be committed, but this request never starts a work session), the repeat of the stored
|
||||
// answer (200, skipped for a practice whose latest verdict is `failed`), the version (412), the state
|
||||
// (409 state_conflict: the attempt is terminal, the work session ended, the item is not current, the
|
||||
// item has a different answer, or the practice verdict is pending or finished), then the answer
|
||||
// against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`). Following
|
||||
// the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and replayed;
|
||||
// 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
func (s *Server) handleSubmitMyAssessmentAnswerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -185,6 +185,10 @@ type SetMySearchStatusRes interface {
|
||||
setMySearchStatusRes()
|
||||
}
|
||||
|
||||
type StartMyAssessmentAttemptSessionRes interface {
|
||||
startMyAssessmentAttemptSessionRes()
|
||||
}
|
||||
|
||||
type SubmitMyAssessmentAnswerRes interface {
|
||||
submitMyAssessmentAnswerRes()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -54,6 +54,7 @@ const (
|
||||
SendOrganizationInvitationOperation OperationName = "SendOrganizationInvitation"
|
||||
SetMyPublicationOperation OperationName = "SetMyPublication"
|
||||
SetMySearchStatusOperation OperationName = "SetMySearchStatus"
|
||||
StartMyAssessmentAttemptSessionOperation OperationName = "StartMyAssessmentAttemptSession"
|
||||
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
|
||||
UnhideOrganizationOperation OperationName = "UnhideOrganization"
|
||||
UpdateOrganizationOperation OperationName = "UpdateOrganization"
|
||||
|
||||
@@ -4415,6 +4415,155 @@ func decodeSendOrganizationInvitationParams(args [2]string, argsEscaped bool, r
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// StartMyAssessmentAttemptSessionParams is parameters of StartMyAssessmentAttemptSession operation.
|
||||
type StartMyAssessmentAttemptSessionParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
// unknown identifier both answer 404 not_found, so identifiers cannot be enumerated.
|
||||
AttemptID uuid.UUID
|
||||
// Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value
|
||||
// is sent without quotes. The server scopes the key by caller and operation and fingerprints the
|
||||
// request by method, path, and body.
|
||||
//
|
||||
// Stored for 24 hours after the first request and replayed with the same status, headers, and body:
|
||||
// the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404
|
||||
// not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
//
|
||||
// Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for
|
||||
// the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428
|
||||
// precondition_required (nothing changed; read the resource again and retry), 422
|
||||
// idempotency_key_reused, 429, and every 5xx.
|
||||
//
|
||||
// Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then
|
||||
// the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused
|
||||
// before any other key check; a running request with the same fingerprint returns 409
|
||||
// idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that
|
||||
// does the server check If-Match, so a retry of a completed change replays its outcome instead of
|
||||
// failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
func unpackStartMyAssessmentAttemptSessionParams(packed middleware.Parameters) (params StartMyAssessmentAttemptSessionParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
}
|
||||
params.AttemptID = packed[key].(uuid.UUID)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}
|
||||
params.IdempotencyKey = packed[key].(string)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeStartMyAssessmentAttemptSessionParams(args [1]string, argsEscaped bool, r *http.Request) (params StartMyAssessmentAttemptSessionParams, _ error) {
|
||||
h := uri.NewHeaderDecoder(r.Header)
|
||||
// Decode path: attempt_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "attempt_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.AttemptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "attempt_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode header: Idempotency-Key.
|
||||
if err := func() error {
|
||||
cfg := uri.HeaderParameterDecodingConfig{
|
||||
Name: "Idempotency-Key",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.HasParam(cfg); err == nil {
|
||||
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.IdempotencyKey = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 255,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(params.IdempotencyKey)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentAnswerParams is parameters of SubmitMyAssessmentAnswer operation.
|
||||
type SubmitMyAssessmentAnswerParams struct {
|
||||
// Identifier of an assessment attempt of the current candidate. An attempt of another candidate and an
|
||||
|
||||
@@ -252,7 +252,7 @@ func (s *Server) decodeConfirmEmailRequest(r *http.Request) (
|
||||
}
|
||||
|
||||
func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) (
|
||||
req *AssessmentAttemptCreate,
|
||||
req AssessmentAttemptCreate,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
@@ -324,7 +324,7 @@ func (s *Server) decodeCreateMyAssessmentAttemptRequest(r *http.Request) (
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
return request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
@@ -1515,6 +1515,85 @@ func (s *Server) decodeSetMySearchStatusRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeStartMyAssessmentAttemptSessionRequest(r *http.Request) (
|
||||
req *AssessmentAttemptSessionStart,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request AssessmentAttemptSessionStart
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSubmitMyAssessmentAnswerRequest(r *http.Request) (
|
||||
req *AssessmentAnswerSubmission,
|
||||
rawBody []byte,
|
||||
|
||||
@@ -4190,6 +4190,157 @@ func encodeSetMySearchStatusResponse(response SetMySearchStatusRes, w http.Respo
|
||||
}
|
||||
}
|
||||
|
||||
func encodeStartMyAssessmentAttemptSessionResponse(response StartMyAssessmentAttemptSessionRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionPreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *StartMyAssessmentAttemptSessionUnprocessableEntity:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(422)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *TooManyRequestsHeaders:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Retry-After" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Retry-After",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := response.RetryAfter.Get(); ok {
|
||||
return e.EncodeValue(conv.Int32ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Retry-After header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(429)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
|
||||
@@ -29,12 +29,15 @@ var (
|
||||
rn9AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn65AllowedHeaders = map[string]string{
|
||||
rn66AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn20AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn65AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn3AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
@@ -44,7 +47,7 @@ var (
|
||||
rn17AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn66AllowedHeaders = map[string]string{
|
||||
rn67AllowedHeaders = map[string]string{
|
||||
"POST": "X-Csrf-Token",
|
||||
}
|
||||
rn46AllowedHeaders = map[string]string{
|
||||
@@ -84,7 +87,7 @@ var (
|
||||
rn61AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn67AllowedHeaders = map[string]string{
|
||||
rn68AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn16AllowedHeaders = map[string]string{
|
||||
@@ -501,7 +504,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn65AllowedHeaders,
|
||||
allowedHeaders: rn66AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -564,6 +567,33 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
case 's': // Prefix: "sessions"
|
||||
|
||||
if l := len("sessions"); len(elem) >= l && elem[0:l] == "sessions" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
s.handleStartMyAssessmentAttemptSessionRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn65AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -792,7 +822,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn66AllowedHeaders,
|
||||
allowedHeaders: rn67AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1500,7 +1530,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn67AllowedHeaders,
|
||||
allowedHeaders: rn68AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -2003,7 +2033,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = CreateMyAssessmentAttemptOperation
|
||||
r.summary = "Start an assessment attempt for a category of the current candidate."
|
||||
r.summary = "Start a real, corrective, or training assessment attempt."
|
||||
r.operationID = "CreateMyAssessmentAttempt"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts"
|
||||
@@ -2036,7 +2066,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyAssessmentAttemptOperation
|
||||
r.summary = "Read or resume an assessment attempt of the current candidate."
|
||||
r.summary = "Read an assessment attempt of the current candidate."
|
||||
r.operationID = "GetMyAssessmentAttempt"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}"
|
||||
@@ -2135,6 +2165,31 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
|
||||
case 's': // Prefix: "sessions"
|
||||
|
||||
if l := len("sessions"); len(elem) >= l && elem[0:l] == "sessions" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = StartMyAssessmentAttemptSessionOperation
|
||||
r.summary = "Start or resume a work session for the current candidate's attempt."
|
||||
r.operationID = "StartMyAssessmentAttemptSession"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/assessment-attempts/{attempt_id}/sessions"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -97,6 +97,7 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SetMyPublicationOperation: []string{},
|
||||
SetMySearchStatusOperation: []string{},
|
||||
StartMyAssessmentAttemptSessionOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
UnhideOrganizationOperation: []string{},
|
||||
UpdateOrganizationOperation: []string{},
|
||||
@@ -146,6 +147,7 @@ var operationRolesSessionCsrf = map[string][]string{
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SetMyPublicationOperation: []string{},
|
||||
SetMySearchStatusOperation: []string{},
|
||||
StartMyAssessmentAttemptSessionOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
UnhideOrganizationOperation: []string{},
|
||||
UpdateOrganizationOperation: []string{},
|
||||
|
||||
@@ -135,27 +135,33 @@ type Handler interface {
|
||||
// CreateMyAssessmentAttempt implements CreateMyAssessmentAttempt 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 category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
// an allowed Origin, and an Idempotency-Key. The request is one of three disjoint shapes. A real
|
||||
// assessment names a specialization, target grade, and task language; the server picks `demo_basic` or
|
||||
// `adaptive` and fixes the policy, bank, and algorithm versions, limits, and item variants. A
|
||||
// corrective real assessment also names `root_attempt_id`; the server verifies the lower-grade chain
|
||||
// and reuses its fixed quota and deadline. The client never sends a real mode, a seed, a version, or a
|
||||
// chain deadline. Explicit `demo_express` starts a separate interactive training run that lasts 3 to 5
|
||||
// minutes, has no category or target grade, and creates no qualification evidence or percentile.
|
||||
// Creation starts session 1. The self-assessed grade only chooses where a real test starts and adds no
|
||||
// points. An adaptive retest starts from the previous ability estimate of the specialization, adjusted
|
||||
// for the time passed, so a new attempt adds evidence instead of starting the measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
// A specialization has at most one active real attempt. A new root attempt cannot start while one is
|
||||
// active, during a retry or promotion interval, past the root quota, or when the bank is insufficient;
|
||||
// each such preflight refusal answers 409 state_conflict and creates nothing or consumes no root slot.
|
||||
// Starting a root attempt reserves one slot in the root quota. A corrective attempt must reference its
|
||||
// root, target a strictly lower grade not already attempted in that chain, and remain inside the
|
||||
// root's fixed quota and deadline (72 hours from the root start in the current policy). It gets its
|
||||
// own item, practice, and session limits, but spends no additional root slot and cannot reset the
|
||||
// chain deadline or any 30/90-day timer. After a failure, including the first test, a lower grade can
|
||||
// be tested at once. An expired or incomplete attempt does not create a free new chain; an
|
||||
// insufficient bank or sandbox failure does not grant another root slot. `demo_express` is outside
|
||||
// real-assessment availability, quotas, retry intervals, and qualification history.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
// clock never extends them, and after them the attempt accepts no work command. For a corrective
|
||||
// attempt, `expires_at` is no later than the root's immutable `chain_deadline`. Within these limits
|
||||
// the attempt is also bounded by the item limit of its policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
@@ -170,7 +176,7 @@ type Handler interface {
|
||||
// Retry-After before any of them; it is not stored.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts
|
||||
CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
|
||||
CreateMyAssessmentAttempt(ctx context.Context, req AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
|
||||
// CreateMySupportCase implements CreateMySupportCase operation.
|
||||
//
|
||||
// Requires the session cookie, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and
|
||||
@@ -442,6 +448,11 @@ type Handler interface {
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Finalize is a work command and requires an active session. After `idle_timeout_seconds` of
|
||||
// inactivity, the candidate first calls StartMyAssessmentAttemptSession with the latest
|
||||
// `expected_version`; finalize never starts a session. GET attempt and result operations do not change
|
||||
// state. A command or background transition may commit a due deadline outcome.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
@@ -463,9 +474,9 @@ type Handler interface {
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
// once. When `expires_at` passes or the session limit is reached, a command or background transition
|
||||
// finalizes `ready_to_finalize` without offering an additional practice. A finalize after this
|
||||
// transition answers 200 with the stored `completed` attempt; a GET never commits it.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
@@ -474,8 +485,9 @@ type Handler interface {
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the attempt (404 not_found; a due deadline transition may be committed, but this request never
|
||||
// starts a work session), the repeat on a `completed` attempt (200), the version (412), then the state
|
||||
// (409 state_conflict, including an ended idle session). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
@@ -518,24 +530,25 @@ type Handler interface {
|
||||
GetHealthz(ctx context.Context) (*HealthResponse, error)
|
||||
// GetMyAssessmentAttempt implements GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
// Requires the session cookie of a candidate account. Returns the stored attempt projection with its
|
||||
// state, fixed versions, time and session limits, progress, the item to answer now, and the practices.
|
||||
// This GET is read-only: it never starts or resumes a work session, consumes session quota, advances
|
||||
// the version, or commits expiry or finalization. A reload, a retried request, or a new session
|
||||
// returns the same item instance with the same text and option order; a lost connection never creates
|
||||
// a new attempt. After `idle_timeout_seconds`, the candidate explicitly starts or resumes work with
|
||||
// StartMyAssessmentAttemptSession. The response never says whether an earlier answer was correct and
|
||||
// never contains answer keys, item scores, family or variant identifiers, seeds, hidden checks, or
|
||||
// anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
// When the deadline passes, this read still returns the stored state and deadline. A command or
|
||||
// background transition commits the due outcome; if the stored state is still active,
|
||||
// GetMyAssessmentResult answers 409 until that transition is committed. The client polls this
|
||||
// operation while a practice is `pending`, but polling alone never changes attempt state.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
// answers 403 forbidden; no operation gives an employer the answers, qualification evidence, or
|
||||
// attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
GetMyAssessmentAttempt(ctx context.Context, params GetMyAssessmentAttemptParams) (GetMyAssessmentAttemptRes, error)
|
||||
@@ -563,21 +576,25 @@ type Handler interface {
|
||||
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. A real result records the mode, policy,
|
||||
// bank, and algorithm versions, decision, previously confirmed grade, calibration status and
|
||||
// limitations, uncertainty where the method computes it, practice verdicts, weak domains, working time
|
||||
// as a separate label, and allowed next steps. A corrective result also carries the root attempt and
|
||||
// its immutable chain deadline. A `demo_express` result is a short educational summary only: it has no
|
||||
// category, percentile, confirmed grade, score, uncertainty, or qualification evidence. A later
|
||||
// policy, bank, or algorithm version never changes a result.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
// and has no result yet. This GET is read-only and never commits a due transition. If a deadline has
|
||||
// passed but the due transition is not yet stored by a command or background worker, the attempt
|
||||
// remains active for this read and answers 409; wait for the transition and retry. An attempt of
|
||||
// another candidate answers 404 not_found, the same as an unknown identifier. An employer account
|
||||
// answers 403 forbidden; employers see only the current category through a separate projection, never
|
||||
// this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (GetMyAssessmentResultRes, error)
|
||||
@@ -1418,6 +1435,31 @@ type Handler interface {
|
||||
//
|
||||
// PUT /api/v1/me/privacy/search-status
|
||||
SetMySearchStatus(ctx context.Context, req *SearchStatusUpdate) (SetMySearchStatusRes, error)
|
||||
// StartMyAssessmentAttemptSession implements StartMyAssessmentAttemptSession operation.
|
||||
//
|
||||
// Requires a candidate session, its CSRF token in X-CSRF-Token, an allowed Origin, and an
|
||||
// Idempotency-Key. The body carries the attempt version the candidate last read. The server checks
|
||||
// ownership, idempotency, and `expected_version` atomically before starting a session; a stale version
|
||||
// answers 412 and consumes no session. Repeating the same key and body within 24 hours replays the
|
||||
// stored response.
|
||||
//
|
||||
// Creation starts session 1. After `idle_timeout_seconds` of inactivity, the candidate uses this
|
||||
// command to start the next session. Calling it while a session is already active returns the current
|
||||
// attempt without consuming another session or advancing its version. Starting a session advances the
|
||||
// version once. The command cannot extend `expires_at` or `chain_deadline`.
|
||||
//
|
||||
// If the attempt deadline or session budget has passed, this command commits the due terminal
|
||||
// transition and returns the resulting attempt. A pending practice submitted before the limit is
|
||||
// graded first. `GetMyAssessmentAttempt` and `GetMyAssessmentResult` remain read-only: they never
|
||||
// start a session or commit a due transition. A background transition may persist a due outcome
|
||||
// independently; after that, this command returns the stored terminal attempt without changing it.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session. An attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier. An employer account answers 403 forbidden; no
|
||||
// operation gives an employer answers, qualification evidence, or attempt history.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/sessions
|
||||
StartMyAssessmentAttemptSession(ctx context.Context, req *AssessmentAttemptSessionStart, params StartMyAssessmentAttemptSessionParams) (StartMyAssessmentAttemptSessionRes, error)
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -1430,6 +1472,12 @@ type Handler interface {
|
||||
// The response is the attempt with the next item to answer. It never says whether the answer was
|
||||
// correct. Items are answered in order and each answer is final.
|
||||
//
|
||||
// A work command requires an active session. After `idle_timeout_seconds` of inactivity, the candidate
|
||||
// calls StartMyAssessmentAttemptSession to explicitly start or resume a session; this answer command
|
||||
// never starts one or consumes session quota. Reading the attempt or result is always read-only. A
|
||||
// command that finds a due deadline transition may commit it before returning; a command that finds an
|
||||
// expired idle session answers 409 until the candidate explicitly starts the next session.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
@@ -1463,15 +1511,14 @@ type Handler interface {
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; a due deadline
|
||||
// transition may be committed, but this request never starts a work session), the repeat of the stored
|
||||
// answer (200, skipped for a practice whose latest verdict is `failed`), the version (412), the state
|
||||
// (409 state_conflict: the attempt is terminal, the work session ended, the item is not current, the
|
||||
// item has a different answer, or the practice verdict is pending or finished), then the answer
|
||||
// against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`). Following
|
||||
// the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and replayed;
|
||||
// 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error)
|
||||
|
||||
@@ -149,27 +149,33 @@ func (UnimplementedHandler) ConfirmEmail(ctx context.Context, req *EmailVerifica
|
||||
// CreateMyAssessmentAttempt implements CreateMyAssessmentAttempt 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 category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
// an allowed Origin, and an Idempotency-Key. The request is one of three disjoint shapes. A real
|
||||
// assessment names a specialization, target grade, and task language; the server picks `demo_basic` or
|
||||
// `adaptive` and fixes the policy, bank, and algorithm versions, limits, and item variants. A
|
||||
// corrective real assessment also names `root_attempt_id`; the server verifies the lower-grade chain
|
||||
// and reuses its fixed quota and deadline. The client never sends a real mode, a seed, a version, or a
|
||||
// chain deadline. Explicit `demo_express` starts a separate interactive training run that lasts 3 to 5
|
||||
// minutes, has no category or target grade, and creates no qualification evidence or percentile.
|
||||
// Creation starts session 1. The self-assessed grade only chooses where a real test starts and adds no
|
||||
// points. An adaptive retest starts from the previous ability estimate of the specialization, adjusted
|
||||
// for the time passed, so a new attempt adds evidence instead of starting the measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
// A specialization has at most one active real attempt. A new root attempt cannot start while one is
|
||||
// active, during a retry or promotion interval, past the root quota, or when the bank is insufficient;
|
||||
// each such preflight refusal answers 409 state_conflict and creates nothing or consumes no root slot.
|
||||
// Starting a root attempt reserves one slot in the root quota. A corrective attempt must reference its
|
||||
// root, target a strictly lower grade not already attempted in that chain, and remain inside the
|
||||
// root's fixed quota and deadline (72 hours from the root start in the current policy). It gets its
|
||||
// own item, practice, and session limits, but spends no additional root slot and cannot reset the
|
||||
// chain deadline or any 30/90-day timer. After a failure, including the first test, a lower grade can
|
||||
// be tested at once. An expired or incomplete attempt does not create a free new chain; an
|
||||
// insufficient bank or sandbox failure does not grant another root slot. `demo_express` is outside
|
||||
// real-assessment availability, quotas, retry intervals, and qualification history.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
// clock never extends them, and after them the attempt accepts no work command. For a corrective
|
||||
// attempt, `expires_at` is no later than the root's immutable `chain_deadline`. Within these limits
|
||||
// the attempt is also bounded by the item limit of its policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
@@ -184,7 +190,7 @@ func (UnimplementedHandler) ConfirmEmail(ctx context.Context, req *EmailVerifica
|
||||
// Retry-After before any of them; it is not stored.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts
|
||||
func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (r CreateMyAssessmentAttemptRes, _ error) {
|
||||
func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (r CreateMyAssessmentAttemptRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
@@ -474,6 +480,11 @@ func (UnimplementedHandler) DeclineMyInvitation(ctx context.Context, req *Invita
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Finalize is a work command and requires an active session. After `idle_timeout_seconds` of
|
||||
// inactivity, the candidate first calls StartMyAssessmentAttemptSession with the latest
|
||||
// `expected_version`; finalize never starts a session. GET attempt and result operations do not change
|
||||
// state. A command or background transition may commit a due deadline outcome.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
@@ -495,9 +506,9 @@ func (UnimplementedHandler) DeclineMyInvitation(ctx context.Context, req *Invita
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
// once. When `expires_at` passes or the session limit is reached, a command or background transition
|
||||
// finalizes `ready_to_finalize` without offering an additional practice. A finalize after this
|
||||
// transition answers 200 with the stored `completed` attempt; a GET never commits it.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
@@ -506,8 +517,9 @@ func (UnimplementedHandler) DeclineMyInvitation(ctx context.Context, req *Invita
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the attempt (404 not_found; a due deadline transition may be committed, but this request never
|
||||
// starts a work session), the repeat on a `completed` attempt (200), the version (412), then the state
|
||||
// (409 state_conflict, including an ended idle session). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
@@ -565,24 +577,25 @@ func (UnimplementedHandler) GetHealthz(ctx context.Context) (r *HealthResponse,
|
||||
|
||||
// GetMyAssessmentAttempt implements GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
// Requires the session cookie of a candidate account. Returns the stored attempt projection with its
|
||||
// state, fixed versions, time and session limits, progress, the item to answer now, and the practices.
|
||||
// This GET is read-only: it never starts or resumes a work session, consumes session quota, advances
|
||||
// the version, or commits expiry or finalization. A reload, a retried request, or a new session
|
||||
// returns the same item instance with the same text and option order; a lost connection never creates
|
||||
// a new attempt. After `idle_timeout_seconds`, the candidate explicitly starts or resumes work with
|
||||
// StartMyAssessmentAttemptSession. The response never says whether an earlier answer was correct and
|
||||
// never contains answer keys, item scores, family or variant identifiers, seeds, hidden checks, or
|
||||
// anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
// When the deadline passes, this read still returns the stored state and deadline. A command or
|
||||
// background transition commits the due outcome; if the stored state is still active,
|
||||
// GetMyAssessmentResult answers 409 until that transition is committed. The client polls this
|
||||
// operation while a practice is `pending`, but polling alone never changes attempt state.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
// answers 403 forbidden; no operation gives an employer the answers, qualification evidence, or
|
||||
// attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
func (UnimplementedHandler) GetMyAssessmentAttempt(ctx context.Context, params GetMyAssessmentAttemptParams) (r GetMyAssessmentAttemptRes, _ error) {
|
||||
@@ -616,21 +629,25 @@ func (UnimplementedHandler) GetMyAssessmentAvailability(ctx context.Context) (r
|
||||
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. A real result records the mode, policy,
|
||||
// bank, and algorithm versions, decision, previously confirmed grade, calibration status and
|
||||
// limitations, uncertainty where the method computes it, practice verdicts, weak domains, working time
|
||||
// as a separate label, and allowed next steps. A corrective result also carries the root attempt and
|
||||
// its immutable chain deadline. A `demo_express` result is a short educational summary only: it has no
|
||||
// category, percentile, confirmed grade, score, uncertainty, or qualification evidence. A later
|
||||
// policy, bank, or algorithm version never changes a result.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
// and has no result yet. This GET is read-only and never commits a due transition. If a deadline has
|
||||
// passed but the due transition is not yet stored by a command or background worker, the attempt
|
||||
// remains active for this read and answers 409; wait for the transition and retry. An attempt of
|
||||
// another candidate answers 404 not_found, the same as an unknown identifier. An employer account
|
||||
// answers 403 forbidden; employers see only the current category through a separate projection, never
|
||||
// this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
func (UnimplementedHandler) GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (r GetMyAssessmentResultRes, _ error) {
|
||||
@@ -1567,6 +1584,34 @@ func (UnimplementedHandler) SetMySearchStatus(ctx context.Context, req *SearchSt
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// StartMyAssessmentAttemptSession implements StartMyAssessmentAttemptSession operation.
|
||||
//
|
||||
// Requires a candidate session, its CSRF token in X-CSRF-Token, an allowed Origin, and an
|
||||
// Idempotency-Key. The body carries the attempt version the candidate last read. The server checks
|
||||
// ownership, idempotency, and `expected_version` atomically before starting a session; a stale version
|
||||
// answers 412 and consumes no session. Repeating the same key and body within 24 hours replays the
|
||||
// stored response.
|
||||
//
|
||||
// Creation starts session 1. After `idle_timeout_seconds` of inactivity, the candidate uses this
|
||||
// command to start the next session. Calling it while a session is already active returns the current
|
||||
// attempt without consuming another session or advancing its version. Starting a session advances the
|
||||
// version once. The command cannot extend `expires_at` or `chain_deadline`.
|
||||
//
|
||||
// If the attempt deadline or session budget has passed, this command commits the due terminal
|
||||
// transition and returns the resulting attempt. A pending practice submitted before the limit is
|
||||
// graded first. `GetMyAssessmentAttempt` and `GetMyAssessmentResult` remain read-only: they never
|
||||
// start a session or commit a due transition. A background transition may persist a due outcome
|
||||
// independently; after that, this command returns the stored terminal attempt without changing it.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session. An attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier. An employer account answers 403 forbidden; no
|
||||
// operation gives an employer answers, qualification evidence, or attempt history.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/sessions
|
||||
func (UnimplementedHandler) StartMyAssessmentAttemptSession(ctx context.Context, req *AssessmentAttemptSessionStart, params StartMyAssessmentAttemptSessionParams) (r StartMyAssessmentAttemptSessionRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -1579,6 +1624,12 @@ func (UnimplementedHandler) SetMySearchStatus(ctx context.Context, req *SearchSt
|
||||
// The response is the attempt with the next item to answer. It never says whether the answer was
|
||||
// correct. Items are answered in order and each answer is final.
|
||||
//
|
||||
// A work command requires an active session. After `idle_timeout_seconds` of inactivity, the candidate
|
||||
// calls StartMyAssessmentAttemptSession to explicitly start or resume a session; this answer command
|
||||
// never starts one or consumes session quota. Reading the attempt or result is always read-only. A
|
||||
// command that finds a due deadline transition may commit it before returning; a command that finds an
|
||||
// expired idle session answers 409 until the candidate explicitly starts the next session.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
@@ -1612,15 +1663,14 @@ func (UnimplementedHandler) SetMySearchStatus(ctx context.Context, req *SearchSt
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay),
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
// the attempt (404 not_found for an unknown attempt or one of another candidate; a due deadline
|
||||
// transition may be committed, but this request never starts a work session), the repeat of the stored
|
||||
// answer (200, skipped for a practice whose latest verdict is `failed`), the version (412), the state
|
||||
// (409 state_conflict: the attempt is terminal, the work session ended, the item is not current, the
|
||||
// item has a different answer, or the practice verdict is pending or finished), then the answer
|
||||
// against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`). Following
|
||||
// the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and replayed;
|
||||
// 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (r SubmitMyAssessmentAnswerRes, _ error) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user