feat(assessment): assign the demonstration category and keep result history

This commit is contained in:
shira committed 2026-10-09 00:35:13 +03:00
1 parent b3c6dc870b
commit 8277133712
61 files changed
+4338 -268

No files matched your search

@@ -170,13 +170,21 @@ func lockAttemptForFinalize(
}
return domain.AssessmentAttempt{}, fmt.Errorf("%s - lock owner-scoped attempt: %w", location, err)
}
if current.Kind() != kind || current.Snapshot().Specialization == nil && selectedSnapshot.Specialization != nil ||
current.Snapshot().Specialization != nil && (selectedSnapshot.Specialization == nil || *current.Snapshot().Specialization != *selectedSnapshot.Specialization) {
if current.Kind() != kind || !sameAttemptSpecialization(current.Snapshot().Specialization, selectedSnapshot.Specialization) {
return domain.AssessmentAttempt{}, fmt.Errorf("%s - immutable attempt scope changed: %w", location, domain.ErrInvalidAssessmentAttempt)
}
return current, nil
}
// sameAttemptSpecialization compares the optional specializations of two reads
// of one attempt; training attempts have none.
func sameAttemptSpecialization(left, right *domain.SpecializationCode) bool {
if left == nil || right == nil {
return left == right
}
return *left == *right
}
func storeCompletedFinalize(
ctx context.Context,
repository outbound.AssessmentAttemptRepository,
@@ -394,9 +402,7 @@ func readCompletedAttemptResult(
if err != nil {
return AssessmentAttemptResult{}, fmt.Errorf("%s - restore stored category result: %w", location, err)
}
result := assessmentAttemptResultFromSnapshot(entry.Result)
result.CategoryDecision = entry.CategoryDecision
return result, nil
return AssessmentAttemptResultFromHistoryEntry(entry), nil
}
func terminalAttemptResult(attempt domain.AssessmentAttempt) (AssessmentAttemptResult, error) {
@@ -448,3 +454,15 @@ func assessmentAttemptResultFromSnapshot(
Summary: snapshot.Summary, DecidedAt: snapshot.DecidedAt,
}
}
// AssessmentAttemptResultFromHistoryEntry is the candidate-visible form of one
// stored result, with the category decision captured when it was stored. A
// legacy v1 entry has no decision.
func AssessmentAttemptResultFromHistoryEntry(entry domain.AssessmentAttemptResultHistoryEntry) AssessmentAttemptResult {
result := assessmentAttemptResultFromSnapshot(entry.Result)
if entry.CategoryDecision != nil {
decision := *entry.CategoryDecision
result.CategoryDecision = &decision
}
return result
}