questionBot

package module
v0.0.0-...-51487e8 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: MIT Imports: 5 Imported by: 1

README

questionbot

A library for working with question/answer steps.

TODO

  • Support multiple choice answers. Currently we have some structure laid out, but need to be able to validate/capture answers

Documentation

Index

Constants

View Source
const (
	ErrTooManyChoices     = "too many choices"
	ErrInvalidChoice      = "invalid choice"
	ErrNoQuestionSelected = "no question selected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PrefixType PrefixType
	DataPath   string
}

type PrefixType

type PrefixType string
const (
	Alpha   PrefixType = "alpha"
	Numeric PrefixType = "numeric"
)

type Question

type Question struct {
	Text      string
	Choices   []string
	Type      QuestionType
	Skippable bool
	Answered  []int
}

func NewQuestion

func NewQuestion(text string, choices []string, questionType QuestionType, skippable bool) *Question

func (*Question) Completed

func (q *Question) Completed() bool

func (*Question) Init

func (q *Question) Init()

func (*Question) MultipleChoice

func (q *Question) MultipleChoice() bool

func (*Question) SelectAnswer

func (q *Question) SelectAnswer(choices ...int) error

type QuestionType

type QuestionType string
const (
	SingleChoice           QuestionType = "single-choice"
	OpenQuestion           QuestionType = "open"
	MultipleChoiceQuestion QuestionType = "multiple-choice"
)

type Questionnaire

type Questionnaire struct {
	Title      string
	Closing    string
	Questions  Questions `toml:"question"`
	PrefixType PrefixType
	// contains filtered or unexported fields
}

func NewQuestionnaire

func NewQuestionnaire(questions Questions) *Questionnaire

func (*Questionnaire) AddQuestion

func (q *Questionnaire) AddQuestion(question Question)

func (*Questionnaire) Answer

func (q *Questionnaire) Answer(choice string) error

func (*Questionnaire) Back

func (q *Questionnaire) Back() (*Question, int)

func (*Questionnaire) Choice

func (q *Questionnaire) Choice(index int) string

func (*Questionnaire) Completed

func (q *Questionnaire) Completed() bool

func (*Questionnaire) Init

func (q *Questionnaire) Init()

func (*Questionnaire) IntToPrefix

func (q *Questionnaire) IntToPrefix(i int) string

func (*Questionnaire) Next

func (q *Questionnaire) Next() (*Question, int)

func (*Questionnaire) PrefixToInt

func (q *Questionnaire) PrefixToInt(prefix string) (int, error)

type Questionnaires

type Questionnaires []*Questionnaire

func LoadQuestionnaires

func LoadQuestionnaires(tomlData string) (Questionnaires, error)

func (Questionnaires) AvailableQuestionnaires

func (q Questionnaires) AvailableQuestionnaires() string

type Questions

type Questions []*Question

type Service

type Service struct {
	PrefixType     PrefixType
	Questionnaires Questionnaires
}

func NewService

func NewService(c Config) (*Service, error)

Jump to

Keyboard shortcuts

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