diff --git a/assessment/application.go b/assessment/application.go index 1b7e7fd9a..57446c1a0 100644 --- a/assessment/application.go +++ b/assessment/application.go @@ -15,9 +15,10 @@ type Application struct { // With updates the Application with the db model and deserializes its assessments. func (r *Application) With(m *model.Application) { r.Application = m - for _, a := range m.Assessments { + for i := range m.Assessments { + a := &m.Assessments[i] assessment := Assessment{} - assessment.With(&a) + assessment.With(a) r.Assessments = append(r.Assessments, assessment) } } diff --git a/assessment/archetype.go b/assessment/archetype.go index ffe3cf647..2450c1c56 100644 --- a/assessment/archetype.go +++ b/assessment/archetype.go @@ -13,9 +13,10 @@ type Archetype struct { // With updates the Archetype with the db model and deserializes its assessments. func (r *Archetype) With(m *model.Archetype) { r.Archetype = m - for _, a := range m.Assessments { + for i := range m.Assessments { + a := &m.Assessments[i] assessment := Assessment{} - assessment.With(&a) + assessment.With(a) r.Assessments = append(r.Assessments, assessment) } } diff --git a/assessment/questionnaire.go b/assessment/questionnaire.go index 5d119206b..0e21bacd2 100644 --- a/assessment/questionnaire.go +++ b/assessment/questionnaire.go @@ -46,15 +46,11 @@ func (r *QuestionnaireResolver) cacheQuestionnaires() (err error) { // questionnaires. func (r *QuestionnaireResolver) Assessed(assessments []Assessment) (assessed bool) { answered := NewSet() -loop: for _, a := range assessments { if r.requiredQuestionnaires.Contains(a.QuestionnaireID) { - for _, s := range a.Sections { - if !s.Complete() { - continue loop - } + if a.Complete() { + answered.Add(a.QuestionnaireID) } - answered.Add(a.QuestionnaireID) } } assessed = answered.Superset(r.requiredQuestionnaires, false)