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
@@ -154,16 +154,18 @@ func newPrivacyCohortCandidate(
|
||||
const privacyCohortCategoryStrength = domain.CandidateViewStrengthStandard
|
||||
|
||||
// privacyCohortConfirmedCategories reads the current categories selected by
|
||||
// the cohort query: only a specialization and a grade of each, never the
|
||||
// attempt, score, policy, or review that produced it.
|
||||
// the cohort query: a specialization, a grade, and the basis of each, never the
|
||||
// attempt, score, policy, or review that produced it. A category without a
|
||||
// known basis is rejected rather than shown as a real confirmation.
|
||||
func privacyCohortConfirmedCategories(value any) ([]domain.CandidateViewConfirmedCategoryInput, error) {
|
||||
encoded, err := privacyCohortEncodedJSONBytes(value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid confirmed categories: %w", domain.ErrInvalidCandidateViewSource)
|
||||
}
|
||||
var stored []struct {
|
||||
Specialization domain.SpecializationCode `json:"specialization"`
|
||||
Grade domain.GradeCode `json:"grade"`
|
||||
Specialization domain.SpecializationCode `json:"specialization"`
|
||||
Grade domain.GradeCode `json:"grade"`
|
||||
Source domain.AssessmentCategorySource `json:"source"`
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(encoded))
|
||||
decoder.DisallowUnknownFields()
|
||||
@@ -172,8 +174,12 @@ func privacyCohortConfirmedCategories(value any) ([]domain.CandidateViewConfirme
|
||||
}
|
||||
categories := make([]domain.CandidateViewConfirmedCategoryInput, 0, len(stored))
|
||||
for _, category := range stored {
|
||||
if !category.Source.IsKnown() {
|
||||
return nil, fmt.Errorf("confirmed category has an unknown basis: %w", domain.ErrInvalidCandidateViewSource)
|
||||
}
|
||||
categories = append(categories, domain.CandidateViewConfirmedCategoryInput{
|
||||
Specialization: category.Specialization, Grade: category.Grade, Strength: privacyCohortCategoryStrength,
|
||||
Specialization: category.Specialization, Grade: category.Grade,
|
||||
Strength: privacyCohortCategoryStrength, Basis: category.Source,
|
||||
})
|
||||
}
|
||||
return categories, nil
|
||||
|
||||
Reference in new issue
Block a user