From 9fd38d5542a4822cbf928655174988e16ade8ac5 Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Mon, 12 Feb 2024 15:01:26 -0500 Subject: [PATCH] :ghost: Return false when no required questionnaires Signed-off-by: ibolton336 --- assessment/archetype.go | 2 +- assessment/questionnaire.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assessment/archetype.go b/assessment/archetype.go index cc905f1c7..d19257c00 100644 --- a/assessment/archetype.go +++ b/assessment/archetype.go @@ -85,7 +85,7 @@ func (r *ArchetypeResolver) Confidence() (confidence int) { // Assessed returns whether the archetype has been fully assessed. func (r *ArchetypeResolver) Assessed() (assessed bool) { if r.questionnaire == nil { - return + return false } assessed = r.questionnaire.Assessed(r.RequiredAssessments()) return diff --git a/assessment/questionnaire.go b/assessment/questionnaire.go index 905520c9e..eb3da056f 100644 --- a/assessment/questionnaire.go +++ b/assessment/questionnaire.go @@ -47,6 +47,9 @@ func (r *QuestionnaireResolver) Required(id uint) (required bool) { // Assessed returns whether a slice contains a completed assessment for each of the required // questionnaires. func (r *QuestionnaireResolver) Assessed(assessments []Assessment) (assessed bool) { + if r.requiredQuestionnaires.Size() == 0 { + return false + } answered := NewSet() for _, a := range assessments { if r.requiredQuestionnaires.Contains(a.QuestionnaireID) {