survey

package
v0.0.0-...-557396d Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoMigrateModels

func AutoMigrateModels(db *gorm.DB) error

AutoMigrateModels imports the models into the DB

func BuildSurveyFromYMLFiles

func BuildSurveyFromYMLFiles(builder YamlFileToSurveyJSBuilder) (string, error)

BuildSurveyFromYMLFiles build a JSSurvey from a YamlFileToSurveyJSBuilder

func GenerateSurveyJSON

func GenerateSurveyJSON(sjs JSSurvey) (string, error)

GenerateSurveyJSON generates JSON without escaping HTML

func PackGenerate

func PackGenerate(url string)

PackGenerate posts to the pack generation service

func PopulateSurveyJSFromYML

func PopulateSurveyJSFromYML(sjs *JSSurvey, yamlString string) error

PopulateSurveyJSFromYML yaml > JSSurvey

Types

type Component

type Component struct {
	Model
	Category string `json:"category"`
	Name     string `json:"name"`
	Weight   int    `json:"weight"`
	SurveyID uint   `json:"-"`
}

Component is the a component of the survey e.g. Westrum

type JSElement

type JSElement struct {
	Type       string     `json:"type" yaml:"type"`
	Name       string     `json:"name" yaml:"name"`
	Title      string     `json:"title" yaml:"title"`
	IsRequired bool       `json:"isRequired" yaml:"isRequired"`
	ColCount   int        `json:"colCount" yaml:"colCount"`
	Choices    []string   `json:"choices,omitempty" yaml:"choices"`
	VisibleIf  string     `json:"visibleIf,omitempty" yaml:"visibleIf"`
	Columns    []JSKVPair `json:"columns,omitempty" yaml:"columns"`
	Rows       []JSKVPair `json:"rows,omitempty" yaml:"rows"`
}

JSElement struct

type JSKVPair

type JSKVPair struct {
	Value interface{} `json:"value" yaml:"value"`
	Text  string      `json:"text" yaml:"text"`
}

JSKVPair struct

type JSPage

type JSPage struct {
	Name     string      `json:"name" yaml:"name"`
	Title    string      `json:"title" yaml:"title"`
	Elements []JSElement `json:"elements" yaml:"elements"`
}

JSPage struct

type JSSurvey

type JSSurvey struct {
	CompletedHTML       template.HTML `json:"completedHtml" yaml:"completedHtml"`
	Pages               []JSPage      `json:"pages" yaml:"pages"`
	ShowQuestionNumbers string        `json:"showQuestionNumbers" yaml:"showQuestionNumbers"`
}

JSSurvey struct

type Model

type Model struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created"`
	UpdatedAt time.Time  `json:"updated"`
	DeletedAt *time.Time `json:"-"`
}

Model is a GORM compatible model

type Result

type Result struct {
	Model
	Time                                                   time.Time `json:"timestamp"`
	CurrentRole                                            string    `json:"current_role"`
	CurrentRoleOther                                       string    `json:"current_role_other"`
	EmploymentStatus                                       string    `json:"employment_status"`
	Team                                                   string    `json:"team"`
	ProgrammingLanguages1                                  string    `json:"programming_languages.1"`
	ProgrammingLanguages2                                  string    `json:"programming_languages.2"`
	ProgrammingLanguages3                                  string    `json:"programming_languages.3"`
	ProgrammingLanguages4                                  string    `json:"programming_languages.4"`
	ProgrammingLanguages5                                  string    `json:"programming_languages.5"`
	ProgrammingLanguages6                                  string    `json:"programming_languages.6"`
	ProgrammingLanguages7                                  string    `json:"programming_languages.7"`
	ProgrammingLanguages8                                  string    `json:"programming_languages.8"`
	ProgrammingLanguages9                                  string    `json:"programming_languages.9"`
	ProgrammingLanguages10                                 string    `json:"programming_languages.10"`
	ProgrammingLanguagesOther                              string    `json:"programming_languages_other"`
	AboutTheTeamInformationActivelySought                  int       `json:"about_the_team.information_actively_sought,string"`
	AboutTheTeamMessengersNotPunished                      int       `json:"about_the_team.messengers_not_punished,string"`
	AboutTheTeamResponsibilitiesShared                     int       `json:"about_the_team.responsibilities_shared,string"`
	AboutTheTeamCollaborationEncouraged                    int       `json:"about_the_team.collaboration_encouraged,string"`
	AboutTheTeamFailureCausesEnquiry                       int       `json:"about_the_team.failure_causes_enquiry,string"`
	AboutTheTeamNewIdeasWelcomed                           int       `json:"about_the_team.new_ideas_welcomed,string"`
	AboutTheTeamFailureTreatedAsOpportunity                int       `json:"about_the_team.failure_treated_as_opportunity,string"`
	AboutTheTeamExtendedUnguardedDiscussion                int       `json:"about_the_team_extended.unguarded_discussion,string"`
	AboutTheTeamExtendedCallOutUnproductiveBehaviour       int       `json:"about_the_team_extended.call_out_unproductive_behaviour,string"`
	AboutTheTeamExtendedContributeToCollectiveGood         int       `json:"about_the_team_extended.contribute_to_collective_good,string"`
	AboutTheTeamExtendedApologise                          int       `json:"about_the_team_extended.apologise,string"`
	AboutTheTeamExtendedWillinglyMakeSacrifices            int       `json:"about_the_team_extended.willingly_make_sacrifices,string"`
	AboutTheTeamExtendedAdmitMistakes                      int       `json:"about_the_team_extended.admit_mistakes,string"`
	AboutTheTeamExtendedCompellingMeetings                 int       `json:"about_the_team_extended.compelling_meetings,string"`
	AboutTheTeamExtendedLeaveMeetingsCommitted             int       `json:"about_the_team_extended.leave_meetings_committed,string"`
	AboutTheTeamExtendedMoraleAffectedByFailure            int       `json:"about_the_team_extended.morale_affected_by_failure,string"`
	AboutTheTeamExtendedDifficultIssuesRaised              int       `json:"about_the_team_extended.difficult_issues_raised,string"`
	AboutTheTeamExtendedConcernedAboutLettingDownPeers     int       `json:"about_the_team_extended.concerned_about_letting_down_peers,string"`
	AboutTheTeamExtendedComfortableDiscussingPersonalLives int       `json:"about_the_team_extended.comfortable_discussing_personal_lives,string"`
	AboutTheTeamExtendedClearResolutionDiscussions         int       `json:"about_the_team_extended.clear_resolution_discussions,string"`
	AboutTheTeamExtendedChallengeOneAnother                int       `json:"about_the_team_extended.challenge_one_another,string"`
	AboutTheTeamExtendedSlowToSeekCredit                   int       `json:"about_the_team_extended.slow_to_seek_credit,string"`
	LeadTime                                               string    `json:"lead_time"`
	DeploymentFrequency                                    string    `json:"deployment_frequency"`
	Mttr                                                   string    `json:"mttr"`
	ChangeFailure                                          string    `json:"change_failure"`
	SurveyID                                               uint      `json:"-"`
}

Result Struct

type ResultSearchParameters

type ResultSearchParameters struct {
	DateStart string
	DateEnd   string
	Team      string
}

ResultSearchParameters is used for searching Results

type Survey

type Survey struct {
	Model
	Results    []Result `json:"results"`
	Team       Team     `json:"team"`
	Name       string   `gorm:"unique;not null;unique_index" json:"name"`
	TeamID     uint     `json:"-"`
	ShareCode  string   `json:"share_code"`
	Components []Component
}

Survey Struct

func (*Survey) AfterSave

func (s *Survey) AfterSave()

AfterSave has some post-save hooks

func (*Survey) BeforeSave

func (s *Survey) BeforeSave()

BeforeSave will sanitize input data to be safe

func (Survey) Get

func (s Survey) Get(db *gorm.DB, id uint) (Survey, error)

Get will return a survey by ID

func (Survey) GetAll

func (s Survey) GetAll(db *gorm.DB) ([]Survey, error)

GetAll Returns a list of all surveys

func (Survey) GetAllResults

func (s Survey) GetAllResults(db *gorm.DB, p ResultSearchParameters) (Survey, error)

GetAllResults returns a survey with all results

func (Survey) GetByName

func (s Survey) GetByName(db *gorm.DB, name string) (Survey, error)

GetByName will return a survey by name

func (Survey) GetByNameAndShareCode

func (s Survey) GetByNameAndShareCode(db *gorm.DB, name, shareCode string) (Survey, error)

GetByNameAndShareCode will return a survey by name and share code

func (Survey) Save

func (s Survey) Save(db *gorm.DB) (Survey, error)

Save will commit to the database

type Team

type Team struct {
	Model
	Name string `json:"name"`
}

Team Struct

func (*Team) BeforeSave

func (t *Team) BeforeSave()

BeforeSave executes before a team is persisted

func (Team) GetAll

func (t Team) GetAll(db *gorm.DB) ([]Team, error)

GetAll Returns a list of teams

func (Team) GetByName

func (t Team) GetByName(db *gorm.DB, name string) (Team, error)

GetByName returns a team by name or an error

type YamlFileToSurveyJSBuilder

type YamlFileToSurveyJSBuilder struct {
	Survey string
	Pages  []string
}

YamlFileToSurveyJSBuilder holds the componets to build a SurveyJS survey from YAML

Jump to

Keyboard shortcuts

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