questions

package
v0.0.0-...-3ee45e0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddQuestionInput

type AddQuestionInput struct {
	internal.GameParams
	QuestionIn
}

type AllQuestionOut

type AllQuestionOut struct {
	IDs    []string `json:"ids"    description:"All the question ids."`
	Cursor string   `json:"cursor" description:"The next question id (for pagination)."`
}

type Drawlosseum

type Drawlosseum struct{}

func (Drawlosseum) HasGroups

func (d Drawlosseum) HasGroups(_ string) bool

func (Drawlosseum) ValidateQuestion

func (d Drawlosseum) ValidateQuestion(_ QuestionIn) error

type FibbingIt

type FibbingIt struct{}

func (FibbingIt) HasGroups

func (f FibbingIt) HasGroups(round string) bool

func (FibbingIt) ValidateQuestion

func (f FibbingIt) ValidateQuestion(question QuestionIn) error

type GenericQuestion

type GenericQuestion struct {
	Content      string
	Round        string
	LanguageCode string
	Group        *GenericQuestionGroup
}

type GenericQuestionGroup

type GenericQuestionGroup struct {
	Name string
	Type string
}

type GetQuestionIDsInput

type GetQuestionIDsInput struct {
	internal.GameParams
	LimitParams
	Cursor string `description:"The ID to start at for retrieving ID" example:"60e777f2d24d7d711e971aee" query:"cursor"`
}

type GetQuestionInput

type GetQuestionInput struct {
	internal.GameParams
	LanguageParams
	QuestionIDParams
}

type GroupInput

type GroupInput struct {
	internal.GameParams
	internal.RoundParams
}

type GroupNameParams

type GroupNameParams struct {
	GroupName string `description:"The name of the group." example:"horse" query:"group_name"`
}

type LanguageParams

type LanguageParams struct {
	Language string `description:"The language code for the new question." example:"fr" path:"language"`
}

type LanguageQueryParams

type LanguageQueryParams struct {
	Language string `description:"The language code for the new question." example:"fr" default:"en" query:"language"`
}

type LimitParams

type LimitParams struct {
	Limit int64 `description:"The number of questions to retrieve." query:"limit" default:"5" validate:"gte=0,lte=100"`
}

type ListQuestionParams

type ListQuestionParams struct {
	internal.GameParams
	internal.RoundParams
	LanguageQueryParams
	GroupNameParams
	LimitParams
	Enabled string `` /* 133-byte string literal not displayed */
	Random  bool   `description:"If set will retrieve questions randomly."                      query:"random"`
}

type Question

type Question struct {
	ID       string            `bson:"id"`
	GameName string            `bson:"game_name"       json:"game_name"`
	Round    string            `bson:"round,omitempty"`
	Enabled  *bool             `bson:"enabled"`
	Content  map[string]string `bson:"content"`
	Group    *QuestionGroup    `bson:"group,omitempty"`
}

func (*Question) Add

func (question *Question) Add(db database.Database) (bool, error)

func (*Question) Get

func (question *Question) Get(db database.Database, filter map[string]interface{}) error

func (*Question) Update

func (question *Question) Update(db database.Database, filter map[string]interface{}) (bool, error)

type QuestionAPI

type QuestionAPI struct {
	Conf   core.Conf
	Logger *log.Logger
	DB     database.Database
}

func (*QuestionAPI) AddQuestion

func (env *QuestionAPI) AddQuestion(_ *gin.Context, questionInput *AddQuestionInput) (string, error)

func (*QuestionAPI) AddTranslation

func (env *QuestionAPI) AddTranslation(_ *gin.Context, questionInput *AddTranslationInput) error

func (*QuestionAPI) DisableQuestion

func (env *QuestionAPI) DisableQuestion(_ *gin.Context, questionInput *QuestionInput) (struct{}, error)

func (*QuestionAPI) EnableQuestion

func (env *QuestionAPI) EnableQuestion(_ *gin.Context, questionInput *QuestionInput) (struct{}, error)

func (*QuestionAPI) GetAllGroups

func (env *QuestionAPI) GetAllGroups(_ *gin.Context, groupInput *GroupInput) ([]string, error)

func (*QuestionAPI) GetAllLanguages

func (env *QuestionAPI) GetAllLanguages(_ *gin.Context, gameNameParam *internal.GameParams) ([]string, error)

func (*QuestionAPI) GetQuestion

func (env *QuestionAPI) GetQuestion(_ *gin.Context, questionInput *GetQuestionInput) (QuestionGenericOut, error)

func (*QuestionAPI) GetQuestions

func (env *QuestionAPI) GetQuestions(_ *gin.Context, params *ListQuestionParams) ([]QuestionOut, error)

func (*QuestionAPI) GetQuestionsIDs

func (env *QuestionAPI) GetQuestionsIDs(_ *gin.Context, questionInput *GetQuestionIDsInput) (AllQuestionOut, error)

func (*QuestionAPI) RemoveQuestion

func (env *QuestionAPI) RemoveQuestion(_ *gin.Context, questionInput *QuestionInput) error

func (*QuestionAPI) RemoveTranslation

func (env *QuestionAPI) RemoveTranslation(_ *gin.Context, questionInput *QuestionLanguageInput) error

type QuestionGenericOut

type QuestionGenericOut struct {
	Content string              `` /* 163-byte string literal not displayed */
	Round   string              `json:"round,omitempty" description:"If the game has rounds, specify the round in this field."               example:"opinion"`
	Enabled bool                `json:"enabled"         description:"True if the question is enabled and can be used in a game, else false."`
	Group   *QuestionGroupInOut `json:"group,omitempty"`
}

type QuestionGroup

type QuestionGroup struct {
	Name string `bson:"name"`
	Type string `bson:"type"`
}

type QuestionGroupInOut

type QuestionGroupInOut struct {
	Name string `json:"name" description:"The name of the group."         example:"animal_group" validate:"required"`
	Type string `json:"type" description:"The type of the content group." example:"question"                         enum:"question,answer"`
}

type QuestionIDParams

type QuestionIDParams struct {
	ID string `description:"The id for a specific question." example:"a-random-id" path:"question_id"`
}

type QuestionIDs

type QuestionIDs struct {
	IDs    []string
	Cursor string
}

type QuestionIn

type QuestionIn struct {
	Content      string              `` /* 157-byte string literal not displayed */
	LanguageCode string              `` /* 170-byte string literal not displayed */
	Round        string              `json:"round,omitempty"         description:"If the game has rounds, specify the round in this field." example:"opinion"`
	Group        *QuestionGroupInOut `json:"group,omitempty"`
}

type QuestionInput

type QuestionInput struct {
	internal.GameParams
	QuestionIDParams
}

type QuestionLanguageInput

type QuestionLanguageInput struct {
	internal.GameParams
	LanguageParams
	QuestionIDParams
}

type QuestionOut

type QuestionOut struct {
	Content string `json:"content" description:"The question to add to a specific game." example:"This is a funny question?" validate:"required"`
	Type    string `` /* 147-byte string literal not displayed */
}

type QuestionService

type QuestionService struct {
	DB         database.Database
	GameName   string
	QuestionID string
	Question   GenericQuestion
}

func (*QuestionService) Add

func (q *QuestionService) Add() (string, error)

func (*QuestionService) AddTranslation

func (q *QuestionService) AddTranslation(content string, langCode string) error

func (*QuestionService) Get

func (q *QuestionService) Get() (Question, error)

func (*QuestionService) GetAll

func (q *QuestionService) GetAll(limit int64, cursor string) (QuestionIDs, error)

func (*QuestionService) GetGroups

func (q *QuestionService) GetGroups(round string) ([]string, error)

func (*QuestionService) GetLanguages

func (q *QuestionService) GetLanguages() ([]string, error)

func (*QuestionService) GetList

func (q *QuestionService) GetList(searchParam SearchParams) (Questions, error)

func (*QuestionService) Remove

func (q *QuestionService) Remove() error

func (*QuestionService) RemoveTranslation

func (q *QuestionService) RemoveTranslation(languageCode string) error

func (*QuestionService) UpdateEnable

func (q *QuestionService) UpdateEnable(enabled bool) (bool, error)

type QuestionTranslationIn

type QuestionTranslationIn struct {
	Content string `json:"content" description:"The question in the new language" example:"Willst du eine Frage?" validate:"required"`
}

type Questioner

type Questioner interface {
	ValidateQuestion(question QuestionIn) error
	HasGroups(_ string) bool
}

func GetGame

func GetGame(name string) (Questioner, error)

type Questions

type Questions []Question

func (*Questions) Add

func (questions *Questions) Add(db database.Database) error

func (Questions) Delete

func (questions Questions) Delete(db database.Database, filter map[string]interface{}) (bool, error)

func (*Questions) Get

func (questions *Questions) Get(db database.Database, filter map[string]interface{}) error

func (*Questions) GetRandom

func (questions *Questions) GetRandom(db database.Database, filter map[string]interface{}, limit int64) error

func (*Questions) GetWithLimit

func (questions *Questions) GetWithLimit(db database.Database, filter map[string]interface{}, limit int64) error

func (Questions) ToInterface

func (questions Questions) ToInterface() []interface{}

type Quibly

type Quibly struct{}

func (Quibly) HasGroups

func (q Quibly) HasGroups(round string) bool

func (Quibly) ValidateQuestion

func (q Quibly) ValidateQuestion(question QuestionIn) error

type SearchParams

type SearchParams struct {
	Round     string
	GroupName string
	Language  string
	Enabled   *bool
	Random    bool
	Limit     int64
}

type UpdateQuestion

type UpdateQuestion map[string]interface{}

func (*UpdateQuestion) Add

func (question *UpdateQuestion) Add(db database.Database, filter map[string]interface{}) (bool, error)

func (*UpdateQuestion) Remove

func (question *UpdateQuestion) Remove(db database.Database, filter map[string]interface{}) (bool, error)

Jump to

Keyboard shortcuts

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