libsp

package
v0.0.0-...-c1bc8f9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.4"

Version of libsp

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	ID      string
	Label   string
	VarName string // short variable name for use in analysis scripts
	HasText bool
}

Choice represents one possible response to a survey question

type QType

type QType int

QType represents the type of a survey question

const (
	Unknown QType = iota
	ConstantSum
	Description
	Embedded
	Form
	Meta
	MultipleChoiceSingleResponse
	MultipleChoiceMultiResponse
	MatrixSingleResponse
	MatrixMultiResponse
	MaxDiff
	NPS
	PickGroupRank
	RankOrder
	TextEntry
	Timing
)

Types of supported survey questions

func (QType) String

func (qt QType) String() string

type Question

type Question struct {
	ID      string
	Wording string
	// contains filtered or unexported fields
}

Question represents a survey question

func (*Question) CSVCols

func (q *Question) CSVCols(useCompatNames bool) []string

CSVCols returns a slice of string holding the ordered CSV column names for this question

func (*Question) OrderedChoices

func (q *Question) OrderedChoices() bool

OrderedChoices returns true if this question has RecodeValues set, indicating that order matters

func (*Question) RColType

func (q *Question) RColType() string

RColType returns the R type of columns associated with this question

func (*Question) ResponseChoices

func (q *Question) ResponseChoices() []Choice

ResponseChoices returns a slice of Choice holding the ordered response choices available to survey respondents

func (*Question) ResponseCols

func (q *Question) ResponseCols(r *Response) []string

ResponseCols returns a slice of string holding the ordered responses in r for this question

func (*Question) SubQuestions

func (q *Question) SubQuestions() []Choice

SubQuestions returns a slice of Choice holding the subquestions asked as part of this question (e.g., rows of a matrix question)

func (*Question) Type

func (q *Question) Type() QType

Type returns a QType representing the type of this survey question

type Response

type Response struct {
	ID         string
	Progress   int
	Duration   int
	Finished   bool
	RecordedOn time.Time
	// contains filtered or unexported fields
}

Response models a Qualtrics participant response

func NewResponse

func NewResponse() *Response

NewResponse creates and initializes a Response

func (*Response) AddAnswer

func (r *Response) AddAnswer(id string, answer string)

AddAnswer adds a question answer to the response

type Survey

type Survey struct {
	Title         string
	Description   string
	Status        string
	CreatedOn     time.Time
	LaunchedOn    time.Time
	ModifiedOn    time.Time
	QuestionOrder []string
	Questions     map[string]*Question
	Responses     []*Response

	UseCompatNames bool
	// contains filtered or unexported fields
}

Survey represents a survey, including its questions, potential responses, and meta-data

func ReadQsf

func ReadQsf(r *bufio.Reader) (survey *Survey, err error)

ReadQsf reads a Qualtrics survey definition file (.qsf) from disk

func (*Survey) ReadXML

func (s *Survey) ReadXML(r *bufio.Reader) error

ReadXML reads a Qualtrics XML file of participant responses

func (*Survey) UnmarshalJSON

func (s *Survey) UnmarshalJSON(b []byte) error

UnmarshalJSON fills the fields of s with the data found in b

func (*Survey) WriteCSV

func (s *Survey) WriteCSV(bw *bufio.Writer) error

WriteCSV saves the parsed survey questions and responses in comma-separated value format

func (*Survey) WriteR

func (s *Survey) WriteR(w *bufio.Writer, csvPath string) error

WriteR saves an R script suitable for importing the survey questions to R

Jump to

Keyboard shortcuts

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