Documentation ¶
Index ¶
- Constants
- func Confidence(assessments []Assessment) (confidence int)
- func PrepareForApplication(tagResolver *TagResolver, application *model.Application, ...)
- func PrepareForArchetype(tagResolver *TagResolver, archetype *model.Archetype, ...)
- func Risk(assessments []Assessment) (risk string)
- type Answer
- type Application
- type ApplicationResolver
- func (r *ApplicationResolver) ArchetypeTags() (tags []model.Tag, err error)
- func (r *ApplicationResolver) Archetypes() (archetypes []Archetype, err error)
- func (r *ApplicationResolver) Assessed() (assessed bool, err error)
- func (r *ApplicationResolver) AssessmentTags() (tags []model.Tag)
- func (r *ApplicationResolver) Confidence() (confidence int, err error)
- func (r *ApplicationResolver) RequiredAssessments() (required []Assessment)
- func (r *ApplicationResolver) Risk() (risk string, err error)
- type Archetype
- type ArchetypeResolver
- func (r *ArchetypeResolver) Applications() (applications []Application, err error)
- func (r *ArchetypeResolver) Assessed() (assessed bool)
- func (r *ArchetypeResolver) AssessmentTags() (tags []model.Tag)
- func (r *ArchetypeResolver) Confidence() (confidence int)
- func (r *ArchetypeResolver) RequiredAssessments() (required []Assessment)
- func (r *ArchetypeResolver) Risk() (risk string)
- type Assessment
- type CategorizedTag
- type MembershipResolver
- type Question
- type QuestionnaireResolver
- type RiskMessages
- type Section
- type Set
- type TagResolver
- type Thresholds
Constants ¶
const ( RiskUnassessed = "unassessed" RiskUnknown = "unknown" RiskRed = "red" RiskYellow = "yellow" RiskGreen = "green" )
Assessment risk
const ( StatusEmpty = "empty" StatusStarted = "started" StatusComplete = "complete" )
Assessment status
const ( AdjusterRed = 0.5 AdjusterYellow = 0.98 )
Confidence adjustment
const ( MultiplierRed = 0.6 MultiplierYellow = 0.95 )
Confidence multiplier.
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.
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) AutoAnswered ¶ added in v0.5.0
AutoAnswered returns whether the question has had an answer pre-selected by the system.
func (*Question) Risk ¶
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 ¶
Complete returns whether all 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 (Set) Intersects ¶
Intersects tests whether this set and the other have at least one element in common.
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.
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.