kahoot

package
v0.0.0-...-837ffed Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: BSD-2-Clause Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnClosed = errors.New("connection closed")
View Source
var ErrNotSubscribed = errors.New("not subscribed to channel")

Functions

func AccessToken

func AccessToken(email, password string) (string, error)

AccessToken returns an access token from the kahoot rest api.

Types

type Conn

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

func NewConn

func NewConn(gameId string) (*Conn, error)

NewConn connects to the kahoot server and performs a handshake using a given game pin.

func (*Conn) Close

func (c *Conn) Close()

Close terminates the connection, waiting synchronously for the incoming channels to close.

func (*Conn) GracefulClose

func (c *Conn) GracefulClose()

GracefulClose closes the connection gracefully, telling the other end that we are disconnecting.

func (*Conn) Login

func (c *Conn) Login(nickname string) error

Login tells the server our nickname.

func (*Conn) Receive

func (c *Conn) Receive(channel string) (Message, error)

Receive returns the next message on a given channel. You must Subscribe() to the channel before Receiving on it.

func (*Conn) Send

func (c *Conn) Send(channel string, m Message) error

Send transmits a message to the server over a channel.

func (*Conn) Subscribe

func (c *Conn) Subscribe(name string) error

Subscribe tells the server that we wish to receive messages on a given channel.

type Message

type Message map[string]interface{}

type Quiz

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

func NewQuiz

func NewQuiz(c *Conn) *Quiz

func (*Quiz) Receive

func (q *Quiz) Receive() (*QuizAction, error)

Receive receives the next QuizAction. This may be a QuestionIntro, indicating a new question is starting, or QuestionAnswers, indicating that the user may now submit an answer.

func (*Quiz) Send

func (q *Quiz) Send(index int) error

Send responds to a server's QuestionAnswers action with an answer index.

type QuizAction

type QuizAction struct {
	Type       QuizActionType
	NumAnswers int
	Index      int
	AnswerMap  map[int]int
}

type QuizActionType

type QuizActionType int
const (
	QuestionIntro QuizActionType = iota
	QuestionAnswers
)

type QuizChoice

type QuizChoice struct {
	Answer  string `json:"answer"`
	Correct bool   `json:"correct"`
}

QuizChoice represents a possible answer for a QuizQuestion.

type QuizInfo

type QuizInfo struct {
	Uuid                string         `json:"uuid"`
	QuizType            string         `json:"quizType"`
	Cover               string         `json:"cover"`
	Modified            int64          `json:"modified"`
	Creator             string         `json:"creator"`
	Audience            string         `json:"audience"`
	Title               string         `json:"title"`
	Description         string         `json:"description"`
	Type                string         `json:"type"`
	Created             int64          `json:"created"`
	Language            string         `json:"language"`
	CreatorPrimaryUsage string         `json:"creator_primary_usage"`
	Questions           []QuizQuestion `json:"questions"`
	Image               string         `json:"image"`
	Video               QuizVideo      `json:"video"`
	Metadata            QuizMetadata   `json:"metadata"`
	Resources           string         `json:"resources"`
	CreatorUsername     string         `json:"creator_username"`
	Visibility          int64          `json:"visibility"`
}

QuizInfo stores information about a quiz, including the correct answers.

func QuizInformation

func QuizInformation(token, quizid string) (*QuizInfo, error)

QuizInformation returns all quiz information for a specific kahoot id.

type QuizMetadata

type QuizMetadata struct {
	Resolution string         `json:"resolution"`
	Moderation QuizModeration `json:"moderation"`
}

QuizMetadata stores metadata about a quiz.

type QuizModeration

type QuizModeration struct {
	FlaggedTimestamp    float64 `json:"flaggedTimestamp"`
	TimestampResolution float64 `json:"timestampResolution"`
	Resolution          string  `json:"resolution"`
}

QuizModeration stores moderator information for a quiz.

type QuizQuestion

type QuizQuestion struct {
	NumberOfAnswers int          `json:"numberOfAnswers"`
	Image           string       `json:"image"`
	Video           QuizVideo    `json:"video"`
	Question        string       `json:"question"`
	QuestionFormat  int          `json:"questionFormat"`
	Time            int          `json:"time"`
	Points          bool         `json:"points"`
	Choices         []QuizChoice `json:"choices"`
	Resources       string       `json:"resources"`
	Type            string       `json:"type"`
}

QuizQuestion is a question in a quiz.

type QuizVideo

type QuizVideo struct {
	FullUrl   string  `json:"fullUrl"`
	Id        string  `json:"id"`
	StartTime float64 `json:"startTime"`
	EndTime   float64 `json:"endTime"`
	Service   string  `json:"service"`
}

QuizVideo is an optional video for a QuizQuestion.

Jump to

Keyboard shortcuts

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