assessment

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RiskUnassessed = "unassessed"
	RiskUnknown    = "unknown"
	RiskRed        = "red"
	RiskYellow     = "yellow"
	RiskGreen      = "green"
)

Assessment risk

View Source
const (
	StatusEmpty    = "empty"
	StatusStarted  = "started"
	StatusComplete = "complete"
)

Assessment status

View Source
const (
	AdjusterRed    = 0.5
	AdjusterYellow = 0.98
)

Confidence adjustment

View Source
const (
	MultiplierRed    = 0.6
	MultiplierYellow = 0.95
)

Confidence multiplier.

View Source
const (
	WeightRed     = 1
	WeightYellow  = 80
	WeightGreen   = 100
	WeightUnknown = 70
)

Risk weights

Variables

This section is empty.

Functions

func Confidence

func Confidence(assessments []Assessment) (confidence int)

Confidence returns a total confidence score for a group of assessments.

func PrepareForApplication

func PrepareForApplication(tagResolver *TagResolver, application *model.Application, assessment *model.Assessment)

PrepareForApplication prepares the sections of an assessment by including, excluding, or auto-answering questions based on a set of tags.

func PrepareForArchetype

func PrepareForArchetype(tagResolver *TagResolver, archetype *model.Archetype, assessment *model.Assessment)

PrepareForArchetype prepares the sections of an assessment by including, excluding, or auto-answering questions based on a set of tags.

func Risk

func Risk(assessments []Assessment) (risk string)

Risk returns the single highest risk score for a group of assessments.

Types

type Answer

type Answer struct {
	Order         *uint            `json:"order" yaml:"order" binding:"required"`
	Text          string           `json:"text" yaml:"text"`
	Risk          string           `json:"risk" yaml:"risk" binding:"oneof=red yellow green unknown"`
	Rationale     string           `json:"rationale" yaml:"rationale"`
	Mitigation    string           `json:"mitigation" yaml:"mitigation"`
	ApplyTags     []CategorizedTag `json:"applyTags,omitempty" yaml:"applyTags,omitempty"`
	AutoAnswerFor []CategorizedTag `json:"autoAnswerFor,omitempty" yaml:"autoAnswerFor,omitempty"`
	Selected      bool             `json:"selected,omitempty" yaml:"selected,omitempty"`
	AutoAnswered  bool             `json:"autoAnswered,omitempty" yaml:"autoAnswered,omitempty"`
}

Answer represents an answer to a question in a questionnaire.

type Application

type Application struct {
	*model.Application
	Assessments []Assessment
}

Application represents an Application with its assessments.

func (*Application) With

func (r *Application) With(m *model.Application)

With updates the Application with the db model and deserializes its assessments.

type ApplicationResolver

type ApplicationResolver struct {
	// contains filtered or unexported fields
}

ApplicationResolver wraps an Application model with archetype and assessment resolution behavior.

func NewApplicationResolver

func NewApplicationResolver(m *model.Application, tags *TagResolver, membership *MembershipResolver, questionnaire *QuestionnaireResolver) (a *ApplicationResolver)

NewApplicationResolver creates a new ApplicationResolver from an application and other shared resolvers.

func (*ApplicationResolver) ArchetypeTags

func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error)

ArchetypeTags returns the list of tags that the application should inherit from the archetypes it is a member of.

func (*ApplicationResolver) Archetypes

func (r *ApplicationResolver) Archetypes() (archetypes []Archetype, err error)

Archetypes returns the list of archetypes the application is a member of.

func (*ApplicationResolver) Assessed

func (r *ApplicationResolver) Assessed() (assessed bool, err error)

Assessed returns whether the application has been fully assessed.

func (*ApplicationResolver) AssessmentTags

func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag)

AssessmentTags returns the list of tags that the application should inherit from the answers given to its assessments or those of its archetypes. Archetype assessments are only inherited if the application does not have any answers to required questionnaires.

func (*ApplicationResolver) Confidence

func (r *ApplicationResolver) Confidence() (confidence int, err error)

Confidence returns the application's overall assessment confidence score.

func (*ApplicationResolver) RequiredAssessments

func (r *ApplicationResolver) RequiredAssessments() (required []Assessment)

RequiredAssessments returns the slice of assessments that are for required questionnaires.

func (*ApplicationResolver) Risk

func (r *ApplicationResolver) Risk() (risk string, err error)

Risk returns the overall risk level for the application based on its or its archetypes' assessments.

type Archetype

type Archetype struct {
	*model.Archetype
	Assessments []Assessment
}

Archetype represents an Archetype with its assessments.

func (*Archetype) With

func (r *Archetype) With(m *model.Archetype)

With updates the Archetype with the db model and deserializes its assessments.

type ArchetypeResolver

type ArchetypeResolver struct {
	// contains filtered or unexported fields
}

ArchetypeResolver wraps an Archetype model with assessment-related functionality.

func NewArchetypeResolver

func NewArchetypeResolver(m *model.Archetype, tags *TagResolver, membership *MembershipResolver, questionnaire *QuestionnaireResolver) (a *ArchetypeResolver)

NewArchetypeResolver creates a new ArchetypeResolver.

func (*ArchetypeResolver) Applications

func (r *ArchetypeResolver) Applications() (applications []Application, err error)

Applications returns the archetype's member applications.

func (*ArchetypeResolver) Assessed

func (r *ArchetypeResolver) Assessed() (assessed bool)

Assessed returns whether the archetype has been fully assessed.

func (*ArchetypeResolver) AssessmentTags

func (r *ArchetypeResolver) AssessmentTags() (tags []model.Tag)

AssessmentTags returns the list of tags that the archetype should inherit from the answers given to its assessments.

func (*ArchetypeResolver) Confidence

func (r *ArchetypeResolver) Confidence() (confidence int)

Confidence returns the archetype's overall assessment confidence score.

func (*ArchetypeResolver) RequiredAssessments

func (r *ArchetypeResolver) RequiredAssessments() (required []Assessment)

RequiredAssessments returns the slice of assessments that are for required questionnaires.

func (*ArchetypeResolver) Risk

func (r *ArchetypeResolver) Risk() (risk string)

Risk returns the overall risk level for the archetypes' assessments.

type Assessment

type Assessment struct {
	*model.Assessment
	Sections     []Section    `json:"sections"`
	Thresholds   Thresholds   `json:"thresholds"`
	RiskMessages RiskMessages `json:"riskMessages"`
}

Assessment represents a deserialized Assessment.

func (*Assessment) Complete

func (r *Assessment) Complete() bool

Complete returns whether all sections have been completed.

func (*Assessment) Confidence

func (r *Assessment) Confidence() (score int)

Confidence calculates a confidence score based on the answers to an assessment's questions. The algorithm is a reimplementation of the calculation done by Pathfinder.

func (*Assessment) Risk

func (r *Assessment) Risk() string

Risk calculates the risk level (red, yellow, green, unknown) for the application.

func (*Assessment) Started

func (r *Assessment) Started() bool

Started returns whether any sections have been started.

func (*Assessment) Status

func (r *Assessment) Status() string

Status returns the started status of the assessment.

func (*Assessment) With

func (r *Assessment) With(m *model.Assessment)

With updates the Assessment with the db model and deserializes its fields.

type CategorizedTag

type CategorizedTag struct {
	Category string `json:"category" yaml:"category"`
	Tag      string `json:"tag" yaml:"tag"`
}

CategorizedTag represents a human-readable pair of category and tag.

type MembershipResolver

type MembershipResolver struct {
	// contains filtered or unexported fields
}

MembershipResolver resolves archetype membership.

func NewMembershipResolver

func NewMembershipResolver(db *gorm.DB) (m *MembershipResolver)

NewMembershipResolver builds a MembershipResolver.

func (*MembershipResolver) Applications

func (r *MembershipResolver) Applications(m Archetype) (applications []Application, err error)

Applications returns the list of applications that are members of the given archetype.

func (*MembershipResolver) Archetypes

func (r *MembershipResolver) Archetypes(app Application) (archetypes []Archetype, err error)

Archetypes returns the list of archetypes that the application is a member of.

type Question

type Question struct {
	Order       *uint            `json:"order" yaml:"order" binding:"required"`
	Text        string           `json:"text" yaml:"text"`
	Explanation string           `json:"explanation" yaml:"explanation"`
	IncludeFor  []CategorizedTag `json:"includeFor,omitempty" yaml:"includeFor,omitempty"`
	ExcludeFor  []CategorizedTag `json:"excludeFor,omitempty" yaml:"excludeFor,omitempty"`
	Answers     []Answer         `json:"answers" yaml:"answers" binding:"min=1,dive"`
}

Question represents a question in a questionnaire.

func (*Question) Answered

func (r *Question) Answered() bool

Answered returns whether the question has had an answer selected.

func (*Question) AutoAnswered added in v0.5.0

func (r *Question) AutoAnswered() bool

AutoAnswered returns whether the question has had an answer pre-selected by the system.

func (*Question) Risk

func (r *Question) Risk() string

Risk returns the risk level for the question based on how it has been answered.

func (*Question) Tags

func (r *Question) Tags() (tags []CategorizedTag)

Tags returns any tags to be applied based on how the question is answered.

type QuestionnaireResolver

type QuestionnaireResolver struct {
	// contains filtered or unexported fields
}

QuestionnaireResolver resolves questionnaire logic.

func NewQuestionnaireResolver

func NewQuestionnaireResolver(db *gorm.DB) (a *QuestionnaireResolver, err error)

NewQuestionnaireResolver builds a QuestionnaireResolver.

func (*QuestionnaireResolver) Assessed

func (r *QuestionnaireResolver) Assessed(assessments []Assessment) (assessed bool)

Assessed returns whether a slice contains a completed assessment for each of the required questionnaires.

func (*QuestionnaireResolver) Required

func (r *QuestionnaireResolver) Required(id uint) (required bool)

Required returns whether a questionnaire is required.

type RiskMessages

type RiskMessages struct {
	Red     string `json:"red" yaml:"red"`
	Yellow  string `json:"yellow" yaml:"yellow"`
	Green   string `json:"green" yaml:"green"`
	Unknown string `json:"unknown" yaml:"unknown"`
}

RiskMessages contains messages to display for each risk level.

type Section

type Section struct {
	Order     *uint      `json:"order" yaml:"order" binding:"required"`
	Name      string     `json:"name" yaml:"name"`
	Questions []Question `json:"questions" yaml:"questions" binding:"min=1,dive"`
	Comment   string     `json:"comment,omitempty" yaml:"comment,omitempty"`
}

Section represents a group of questions in a questionnaire.

func (*Section) Complete

func (r *Section) Complete() bool

Complete returns whether all questions in the section have been answered.

func (*Section) Risks

func (r *Section) Risks() []string

Risks returns a slice of the risks of each of its questions.

func (*Section) Started

func (r *Section) Started() bool

Started returns whether any questions in the section have been answered.

func (*Section) Tags

func (r *Section) Tags() (tags []CategorizedTag)

Tags returns all the tags that should be applied based on how the questions in the section have been answered.

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is an unordered collection of uints with no duplicate elements.

func NewSet

func NewSet() (s Set)

NewSet builds a new Set.

func (Set) Add

func (r Set) Add(members ...uint)

Add a member to the set.

func (Set) Contains

func (r Set) Contains(element uint) bool

Contains returns whether an element is a member of the set.

func (Set) Intersects

func (r Set) Intersects(other Set) bool

Intersects tests whether this set and the other have at least one element in common.

func (Set) Members

func (r Set) Members() []uint

Members returns the members of the set as a slice.

func (Set) Size

func (r Set) Size() int

Size returns the number of members in the set.

func (Set) Subset

func (r Set) Subset(other Set, strict bool) bool

Subset tests whether every element of this set is in the other.

func (Set) Superset

func (r Set) Superset(other Set, strict bool) bool

Superset tests whether every element of other is in the set.

type TagResolver

type TagResolver struct {
	// contains filtered or unexported fields
}

TagResolver resolves CategorizedTags to Tag models.

func NewTagResolver

func NewTagResolver(db *gorm.DB) (t *TagResolver, err error)

NewTagResolver builds a TagResolver.

func (*TagResolver) Assessment

func (r *TagResolver) Assessment(assessment Assessment) (tags []model.Tag)

Assessment returns all the Tag models that should be applied from the assessment.

func (*TagResolver) Resolve

func (r *TagResolver) Resolve(category string, tag string) (t *model.Tag, found bool)

Resolve a category and tag name to a Tag model.

type Thresholds

type Thresholds struct {
	Red     uint `json:"red" yaml:"red"`
	Yellow  uint `json:"yellow" yaml:"yellow"`
	Unknown uint `json:"unknown" yaml:"unknown"`
}

Thresholds contains the threshold values for determining risk for the questionnaire.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL