assessment

package
v0.3.0-alpha.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Assessment risk

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(sections []Section) (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 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.

Types

type Answer

type Answer struct {
	Order         uint             `json:"order" yaml:"order"`
	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 ApplicationResolver

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

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

func NewApplicationResolver

func NewApplicationResolver(app *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, including any tags that would be inherited due to answers given to the archetypes' assessments.

func (*ApplicationResolver) Archetypes

func (r *ApplicationResolver) Archetypes() (archetypes []model.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.

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 *model.Archetype) (applications []model.Application, err error)

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

func (*MembershipResolver) Archetypes

func (r *MembershipResolver) Archetypes(m *model.Application) (archetypes []model.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"`
	Text        string           `json:"text" yaml:"text"`
	Explanation string           `json:"explanation" yaml:"explanation"`
	IncludeFor  []CategorizedTag `json:"includeFor,omitempty" yaml:"includeFor,omitempty" binding:"excluded_with=ExcludeFor"`
	ExcludeFor  []CategorizedTag `json:"excludeFor,omitempty" yaml:"excludeFor,omitempty" binding:"excluded_with=IncludeFor"`
	Answers     []Answer         `json:"answers" yaml:"answers"`
}

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) 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 []model.Assessment) (assessed bool)

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

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"`
	Name      string     `json:"name" yaml:"name"`
	Questions []Question `json:"questions" yaml:"questions"`
}

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(member 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) bool

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

func (Set) Superset

func (r Set) Superset(other Set) 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 *model.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