models

package
v0.0.0-...-11704d7 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const StateFinished = "FINISHED"
View Source
const StateInProgress = "INPROGRESS"
View Source
const StateInitialized = "INITIALIZED"

Variables

This section is empty.

Functions

This section is empty.

Types

type Buzz

type Buzz struct {
	gorm.Model `json:"-"`
	TS         time.Time `json:"ts,omitempty"`
	UserID     uint      `json:"user_id,omitempty"`
	QuestionID uint      `json:"question_id,omitempty"`
	Question   Question  `json:"question,omitempty"`
}

type PlaySession

type PlaySession struct {
	gorm.Model           `json:"-"`
	Code                 uint `gorm:"uniqueIndex" json:"code"`
	QuizID               uint
	Quiz                 *Quiz     `json:"quiz"`
	State                string    `json:"state"`
	CurrentQuestionIndex int       `json:"current_question_index"`
	CurrentQuestion      *Question `gorm:"-" json:"current_question"`
	CurrentAnswer        string    `json:"current_answer,omitempty"`
	QuizMaster           string    `json:"quiz_master"`
	Users                []*User   `gorm:"many2many:session_users" json:"users"`
	Teams                []*Team   `gorm:"many2many:session_teams" json:"teams"`
}

func NewPlaySession

func NewPlaySession(qm string, q *Quiz) (s *PlaySession)

func (*PlaySession) AddTeam

func (s *PlaySession) AddTeam(t *Team)

func (*PlaySession) AddTeamPoints

func (s *PlaySession) AddTeamPoints(points int, teamName string) (err error)

func (*PlaySession) AddUser

func (s *PlaySession) AddUser(u *User)

func (*PlaySession) AssignUserToTeam

func (s *PlaySession) AssignUserToTeam(teamName string, email string) (err error)

func (*PlaySession) ClearCurrentAnswer

func (s *PlaySession) ClearCurrentAnswer()

func (*PlaySession) GetTeam

func (s *PlaySession) GetTeam(name string) (t *Team, err error)

func (*PlaySession) SetCurrentAnswer

func (s *PlaySession) SetCurrentAnswer(answer string)

func (*PlaySession) SetFinished

func (s *PlaySession) SetFinished()

func (*PlaySession) SetInProgress

func (s *PlaySession) SetInProgress()

func (*PlaySession) UpdateQuestion

func (s *PlaySession) UpdateQuestion(q *Question)

type Question

type Question struct {
	gorm.Model
	UserID       uint   `json:"-"`
	QuizID       uint   `json:"-"`
	Points       uint   `json:"points,omitempty"`
	Text         string `json:"text,omitempty"`
	ImageLink    string `json:"image_link,omitempty"`
	AudioLink    string `json:"audio_link,omitempty"`
	Answer       string `json:"answer,omitempty"`
	TimerSeconds uint   `json:"timer_seconds,omitempty"`
	Tags         []*Tag `gorm:"many2many:question_tags" json:"tags,omitempty"`
}

func NewQuestion

func NewQuestion(quizID uint, text, imageLink, audioLink, answer string, points, timerSeconds uint) *Question

type Quiz

type Quiz struct {
	gorm.Model
	Name          string      `gorm:"uniqueIndex" json:"name"`
	Private       bool        `json:"private"`
	Collaborators []*User     `gorm:"many2many:quiz_collaborators" json:"collaborators"`
	Tags          []*Tag      `gorm:"many2many:quiz_tags" json:"tags"`
	Questions     []*Question `gorm:"many2many:quiz_questions" json:"questions"`
}

func NewQuiz

func NewQuiz(name string, owner *User, tt []*Tag) *Quiz

NewQuiz is used to initialize an empty Quiz

func (*Quiz) AddQuestion

func (qz *Quiz) AddQuestion(q *Question)

func (*Quiz) AddTags

func (qz *Quiz) AddTags(tags []*Tag)

AddTags attaches tags to a given quiz

func (*Quiz) CanView

func (qz *Quiz) CanView(email string) bool

func (*Quiz) IsCollaborator

func (qz *Quiz) IsCollaborator(email string) bool

func (*Quiz) TogglePrivacy

func (qz *Quiz) TogglePrivacy()

TogglePrivacy toggle Quiz Privacy

type QuizPGStore

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

func NewQuizPGStore

func NewQuizPGStore(dsn string) (*QuizPGStore, error)

func (*QuizPGStore) CreatePlaySession

func (db *QuizPGStore) CreatePlaySession(s *PlaySession) error

func (*QuizPGStore) CreateQuestion

func (db *QuizPGStore) CreateQuestion(q *Question) error

func (*QuizPGStore) CreateQuiz

func (db *QuizPGStore) CreateQuiz(qz *Quiz) error

func (*QuizPGStore) CreateUser

func (db *QuizPGStore) CreateUser(u *User) error

func (*QuizPGStore) DeletePlaySession

func (db *QuizPGStore) DeletePlaySession(code uint) (err error)

func (*QuizPGStore) DeleteQuestion

func (db *QuizPGStore) DeleteQuestion(id uint, quizID uint) error

func (*QuizPGStore) DeleteQuiz

func (db *QuizPGStore) DeleteQuiz(id uint) (err error)

func (*QuizPGStore) GetAllPublicQuizzes

func (db *QuizPGStore) GetAllPublicQuizzes() (qzs []*Quiz, err error)

func (*QuizPGStore) GetPlaySession

func (db *QuizPGStore) GetPlaySession(code uint) (s *PlaySession, err error)

func (*QuizPGStore) GetPreloadedQuiz

func (db *QuizPGStore) GetPreloadedQuiz(id uint) (qz *Quiz, err error)

func (*QuizPGStore) GetQuestion

func (db *QuizPGStore) GetQuestion(id uint) (q *Question, err error)

func (*QuizPGStore) GetQuestionsByQuiz

func (db *QuizPGStore) GetQuestionsByQuiz(qzID uint) (qq []*Question, err error)

func (*QuizPGStore) GetQuiz

func (db *QuizPGStore) GetQuiz(id uint) (qz *Quiz, err error)

func (*QuizPGStore) GetQuizByName

func (db *QuizPGStore) GetQuizByName(name string) (qz *Quiz, err error)

func (*QuizPGStore) GetQuizzesByUser

func (db *QuizPGStore) GetQuizzesByUser(email string) (qzs []*Quiz, err error)

func (*QuizPGStore) GetTagByName

func (db *QuizPGStore) GetTagByName(name string) (t *Tag, err error)

func (*QuizPGStore) GetUserByEmail

func (db *QuizPGStore) GetUserByEmail(email string) (*User, error)

func (*QuizPGStore) Migrate

func (db *QuizPGStore) Migrate() error

func (*QuizPGStore) UpdatePlaySession

func (db *QuizPGStore) UpdatePlaySession(s *PlaySession) error

func (*QuizPGStore) UpdateQuestion

func (db *QuizPGStore) UpdateQuestion(id uint, q *Question) error

func (*QuizPGStore) UpdateQuiz

func (db *QuizPGStore) UpdateQuiz(qz *Quiz) error

func (*QuizPGStore) UpdateTeam

func (db *QuizPGStore) UpdateTeam(t *Team) error

func (*QuizPGStore) UpdateUser

func (db *QuizPGStore) UpdateUser(u *User) error

type QuizStore

type QuizStore interface {
	CreateUser(u *User) error
	UpdateUser(u *User) error
	GetUserByEmail(email string) (u *User, err error)
	CreateQuiz(qz *Quiz) error
	DeleteQuiz(id uint) error
	GetQuizByName(name string) (qz *Quiz, err error)
	GetQuiz(id uint) (qz *Quiz, err error)
	GetPreloadedQuiz(id uint) (qz *Quiz, err error)
	GetAllPublicQuizzes() (qzs []*Quiz, err error)
	GetQuizzesByUser(email string) (qzs []*Quiz, err error)
	UpdateQuiz(qz *Quiz) error
	CreateQuestion(q *Question) error
	UpdateQuestion(id uint, q *Question) error
	DeleteQuestion(id uint, quizID uint) error
	GetQuestion(id uint) (q *Question, err error)
	GetQuestionsByQuiz(qzID uint) (qq []*Question, err error)
	GetTagByName(name string) (t *Tag, err error)
	CreatePlaySession(s *PlaySession) error
	UpdatePlaySession(s *PlaySession) error
	GetPlaySession(code uint) (s *PlaySession, err error)
	DeletePlaySession(code uint) (err error)
	UpdateTeam(t *Team) error
}

type Tag

type Tag struct {
	gorm.Model `json:"-"`
	Name       string `json:"name,omitempty"`
}

type Team

type Team struct {
	gorm.Model
	Name   string  `json:"name"`
	Users  []*User `gorm:"many2many:user_teams" json:"users"`
	Points int     `json:"points"`
}

func NewTeam

func NewTeam(name string) *Team

func (*Team) AddPoints

func (t *Team) AddPoints(points int)

type User

type User struct {
	gorm.Model `json:"-"`
	Email      string  `gorm:"uniqueIndex" json:"email,omitempty"`
	Name       string  `json:"name,omitempty"`
	Quizzes    []*Quiz `gorm:"many2many:quiz_collaborators" json:"quizzes,omitempty"`
	Teams      []*Team `gorm:"many2many:user_teams" json:"teams,omitempty"`
	AvatarURL  string  `json:"avatar_url,omitempty"`
}

Jump to

Keyboard shortcuts

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