feat(assessment): add the review band of attempt signals and the disclosed collector
This commit is contained in:
1 parent
68286af8b7
commit
b3c6dc870b
124 files changed
+13522
-633
No files matched your search
@@ -5,10 +5,51 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
var ErrAssessmentSignalOutcomeNotFound = errors.New("assessment signal outcome not found")
|
||||
var (
|
||||
ErrAssessmentSignalOutcomeNotFound = errors.New("assessment signal outcome not found")
|
||||
ErrAssessmentReviewNotFound = errors.New("assessment attempt review not found")
|
||||
)
|
||||
|
||||
// AssessmentReviewInputs are the stored facts a review is computed from, apart
|
||||
// from the comparison with other attempts. They hold no answer, address, or
|
||||
// session identifier.
|
||||
type AssessmentReviewInputs struct {
|
||||
Answers []domain.AssessmentResponseSample
|
||||
Marks []domain.AssessmentOriginMark
|
||||
ClientFocusLossMS int64
|
||||
ClientClipboardCount int32
|
||||
ClientFullscreenExit int32
|
||||
}
|
||||
|
||||
// AssessmentDuplicateQuery selects the pairs of attempts that share answers.
|
||||
// The caps come from the policy of the attempt being evaluated.
|
||||
type AssessmentDuplicateQuery struct {
|
||||
IntegerCapBits int32
|
||||
SequenceCapBits int32
|
||||
// MinBits drops pairs with less evidence.
|
||||
MinBits int32
|
||||
// EndedOnly keeps only attempts that are over at Now: terminal, or past
|
||||
// their deadline.
|
||||
EndedOnly bool
|
||||
Now time.Time
|
||||
Limit int32
|
||||
}
|
||||
|
||||
// AssessmentDuplicatePair is one other attempt that shares answers with the
|
||||
// evaluated one. It is used inside the usecase only: nothing that identifies
|
||||
// the other attempt or its candidate leaves it.
|
||||
type AssessmentDuplicatePair struct {
|
||||
AttemptID domain.AssessmentAttemptID
|
||||
PolicyVersionID domain.PolicyVersionID
|
||||
EvidenceBits int32
|
||||
IntegerItems int32
|
||||
SequenceItems int32
|
||||
}
|
||||
|
||||
type AssessmentSignalRepositories interface {
|
||||
AssessmentSignals() AssessmentSignalRepository
|
||||
@@ -23,4 +64,28 @@ type AssessmentSignalRepository interface {
|
||||
SaveOutcome(ctx context.Context, scope AssessmentAttemptIdempotencyScope, attemptID domain.AssessmentAttemptID, receipt domain.AssessmentSignalReceipt) error
|
||||
DeleteExpiredOutcome(ctx context.Context, scope AssessmentAttemptIdempotencyScope) error
|
||||
GetOutcome(ctx context.Context, scope AssessmentAttemptIdempotencyScope) (domain.AssessmentSignalReceipt, error)
|
||||
|
||||
// SaveAnswerObservation and SaveOriginMark store server-side facts of an
|
||||
// accepted request in the current unit of work. The caller holds the row
|
||||
// lock of the attempt; no other lock is taken.
|
||||
SaveAnswerObservation(ctx context.Context, observation domain.AssessmentAnswerObservation) error
|
||||
SaveOriginMark(ctx context.Context, mark domain.AssessmentOriginMark) error
|
||||
LastOriginMark(ctx context.Context, attemptID domain.AssessmentAttemptID) (domain.AssessmentOriginMark, bool, error)
|
||||
|
||||
ReviewInputs(ctx context.Context, attemptID domain.AssessmentAttemptID) (AssessmentReviewInputs, error)
|
||||
// DuplicatePairs lists the other attempts that share answers with the given
|
||||
// one, strongest first and bounded by the query.
|
||||
DuplicatePairs(ctx context.Context, attemptID domain.AssessmentAttemptID, query AssessmentDuplicateQuery) ([]AssessmentDuplicatePair, error)
|
||||
// ReviewSubject returns the product policy version a real attempt is pinned
|
||||
// to; found is false for an unknown or training attempt.
|
||||
ReviewSubject(ctx context.Context, attemptID domain.AssessmentAttemptID) (domain.PolicyVersionID, bool, error)
|
||||
// LockReview takes the transaction-scoped lock of one attempt's review. A
|
||||
// job locks every review it will write, in ascending attempt order, before
|
||||
// it reads any fact, so concurrent evaluations of one attempt run one after
|
||||
// another and the later one reads what the earlier one committed.
|
||||
LockReview(ctx context.Context, attemptID domain.AssessmentAttemptID) error
|
||||
// SaveReview stores the review; the times come from the database clock.
|
||||
SaveReview(ctx context.Context, review domain.AssessmentAttemptReview) error
|
||||
GetReview(ctx context.Context, attemptID domain.AssessmentAttemptID) (domain.AssessmentAttemptReview, error)
|
||||
RecordReviewRead(ctx context.Context, id uuid.UUID, attemptID domain.AssessmentAttemptID, actor domain.AssessmentReviewActor, found bool, at time.Time) error
|
||||
}
|
||||
Reference in new issue
Block a user