fix(assessment): return confirmed categories with their basis and label demonstration categories
This commit is contained in:
1 parent
623d41b969
commit
d4903a3796
77 files changed
+1441
-288
No files matched your search
@@ -29,8 +29,12 @@ type AssessmentAvailability struct {
|
||||
}
|
||||
|
||||
type SpecializationAvailability struct {
|
||||
Specialization domain.SpecializationCode
|
||||
Specialization domain.SpecializationCode
|
||||
// ConfirmedGrade and ConfirmedBasis are set together from the current
|
||||
// category of the specialization, or both are nil. The basis keeps a
|
||||
// demonstration grade from reading as a real confirmation.
|
||||
ConfirmedGrade *domain.GradeCode
|
||||
ConfirmedBasis *domain.AssessmentCategorySource
|
||||
ActiveAttemptID *domain.AssessmentAttemptID
|
||||
Grades []GradeAvailability
|
||||
}
|
||||
@@ -108,6 +112,7 @@ type assessmentAvailabilityReads struct {
|
||||
selections []outbound.AssessmentAvailabilitySelection
|
||||
active map[domain.SpecializationCode]outbound.AssessmentActiveAttemptSummary
|
||||
rootHistory map[domain.SpecializationCode][]outbound.AssessmentRootAvailabilitySummary
|
||||
categories map[domain.SpecializationCode]domain.CandidateAssessmentCategory
|
||||
quota outbound.AssessmentRootQuotaSnapshot
|
||||
seen map[domain.AssessmentFamilyKey]struct{}
|
||||
}
|
||||
@@ -164,6 +169,14 @@ func readAssessmentAvailability(
|
||||
if err != nil {
|
||||
return assessmentAvailabilityReads{}, fmt.Errorf("%s - read active attempts: %w", location, err)
|
||||
}
|
||||
categories, err := unit.AssessmentAttempts().ListCandidateCategories(ctx, userID)
|
||||
if err != nil {
|
||||
return assessmentAvailabilityReads{}, fmt.Errorf("%s - read confirmed categories: %w", location, err)
|
||||
}
|
||||
reads.categories = make(map[domain.SpecializationCode]domain.CandidateAssessmentCategory, len(categories))
|
||||
for _, category := range categories {
|
||||
reads.categories[category.Snapshot().Specialization] = category
|
||||
}
|
||||
window := policy.AttemptWindow.Duration()
|
||||
reads.quota, err = unit.AssessmentAttempts().GetRootQuotaSnapshot(
|
||||
ctx, userID, now.Add(-window), now, window, policy.MaxAttemptsPerWindow,
|
||||
@@ -245,6 +258,12 @@ func buildSpecializationAvailability(
|
||||
id := active.ID
|
||||
result.ActiveAttemptID = &id
|
||||
}
|
||||
if category, confirmed := reads.categories[answer.Specialization]; confirmed {
|
||||
snapshot := category.Snapshot()
|
||||
grade, basis := snapshot.Grade, snapshot.Source
|
||||
result.ConfirmedGrade = &grade
|
||||
result.ConfirmedBasis = &basis
|
||||
}
|
||||
for _, grade := range availabilityGrades {
|
||||
result.Grades = append(result.Grades, buildGradeAvailability(
|
||||
answer, grade, reads, policy, now, seconds, itemCount, hasActive,
|
||||
|
||||
Reference in new issue
Block a user