models

package
v0.0.0-...-0ca590b Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkdownToQuiz

func MarkdownToQuiz(quiz *Quiz, markdown string) error

func QuizToMarkdown

func QuizToMarkdown(quiz *Quiz) (string, error)

Types

type Answer

type Answer struct {
	//	ID   string `json:"id" gorm:"primaryKey"`
	Meta
	Text string `json:"text"`
}

func (*Answer) GetHash

func (a *Answer) GetHash() string

func (*Answer) String

func (a *Answer) String() string

type AttributeList

type AttributeList map[string]string

func (AttributeList) Get

func (al AttributeList) Get(key string) string

func (AttributeList) MarshalCSV

func (al AttributeList) MarshalCSV() (string, error)

func (AttributeList) String

func (al AttributeList) String() string

func (*AttributeList) UnmarshalCSV

func (al *AttributeList) UnmarshalCSV(csv string) error

type Collection

type Collection struct {
	Meta

	Name string `json:"name"`

	Quizzes []*Quiz `json:"quizzes" gorm:"many2many:collection_quizzes"`
}

func (*Collection) GetHash

func (c *Collection) GetHash() string

func (*Collection) Marshal

func (c *Collection) Marshal() ([]byte, error)

func (*Collection) String

func (c *Collection) String() string

func (*Collection) Unmarshal

func (c *Collection) Unmarshal(data []byte) error

type Exam

type Exam struct {
	Meta

	Participant *Participant `json:"participant"`
	Quizzes     []*Quiz      `json:"quizzes"`
}

func (*Exam) GetHash

func (e *Exam) GetHash() string

func (*Exam) Marshal

func (e *Exam) Marshal() ([]byte, error)

func (*Exam) String

func (e *Exam) String() string

func (*Exam) ToMarkdown

func (e *Exam) ToMarkdown() (string, error)

func (*Exam) Unmarshal

func (e *Exam) Unmarshal(data []byte) error

type Group

type Group struct {
	Meta
	Name         string
	Participants []*Participant
}

func (*Group) GetHash

func (g *Group) GetHash() string

func (*Group) Marshal

func (g *Group) Marshal() ([]byte, error)

func (*Group) String

func (g *Group) String() string

func (*Group) Unmarshal

func (g *Group) Unmarshal(data []byte) error

type Meta

type Meta struct {
	ID        string    `json:"id" yaml:"id" gorm:"primaryKey"`
	Tags      []string  `json:"tags" yaml:"tags"`
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`
	UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`

	UniqueIDFunc func() string `json:"-" yaml:"-"`
}

func ParseMetaHeaderFromMarkdown

func ParseMetaHeaderFromMarkdown(markdown string) (*Meta, string, error)

func (*Meta) GetCreatedAt

func (m *Meta) GetCreatedAt() time.Time

func (*Meta) GetID

func (m *Meta) GetID() string

func (*Meta) GetUpdatedAt

func (m *Meta) GetUpdatedAt() time.Time

func (*Meta) SetCreatedAt

func (m *Meta) SetCreatedAt(t time.Time)

func (*Meta) SetID

func (m *Meta) SetID(id string)

func (*Meta) SetUpdatedAt

func (m *Meta) SetUpdatedAt(t time.Time)

type Participant

type Participant struct {
	Meta

	Firstname string `json:"firstname" csv:"firstname"`
	Lastname  string `json:"lastname" csv:"lastname"`

	Token string `json:"token" csv:"token"`

	Attributes AttributeList `json:"attributes" csv:"attributes"`
}

func (*Participant) AttributesToSlice

func (p *Participant) AttributesToSlice() []string

func (*Participant) GetHash

func (p *Participant) GetHash() string

func (*Participant) Marshal

func (p *Participant) Marshal() ([]byte, error)

func (*Participant) String

func (p *Participant) String() string

func (*Participant) Unmarshal

func (p *Participant) Unmarshal(data []byte) error

type ParticipantAnswer

type ParticipantAnswer struct {
	Quiz    *Quiz   `json:"question"`
	Answer  *Answer `json:"answer"`
	Correct bool    `json:"correct"`
}

type Player

type Player struct {
	Name string
	Wins int
}

type Question

type Question struct {
	Meta
	Text string `json:"text"`
}

func (*Question) GetHash

func (q *Question) GetHash() string

func (*Question) String

func (q *Question) String() string

type Quiz

type Quiz struct {
	Meta

	Hash       string    `json:"hash"`
	Question   *Question `json:"question"`
	Answers    []*Answer `json:"answers"`
	Correct    *Answer   `json:"correct"`
	CorrectPos uint      // Position of the correct answer during quiz creation
	Type       int       `json:"type"`
}

func (*Quiz) GetHash

func (q *Quiz) GetHash() string

func (*Quiz) Marshal

func (q *Quiz) Marshal() ([]byte, error)

func (*Quiz) Unmarshal

func (q *Quiz) Unmarshal(data []byte) error

type Response

type Response struct {
	Meta

	SessionTitle string               `json:"session_title"`
	Participant  *Participant         `json:"participant"`
	Answers      []*ParticipantAnswer `json:"answers"`
}

func (*Response) GetHash

func (r *Response) GetHash() string

func (*Response) Marshal

func (r *Response) Marshal() ([]byte, error)

func (*Response) String

func (r *Response) String() string

func (*Response) Unmarshal

func (r *Response) Unmarshal(data []byte) error

type Session

type Session struct {
	Meta

	Title       string `json:"title"`
	Description string `json:"description"`

	Participants map[string]*Participant `json:"participants"`
	Quizzes      map[string]*Quiz        `json:"quizzes"`
	Answers      map[string]*Answer      `json:"answers"`
	Exams        map[string]*Exam        `json:"exams"`
}

func (*Session) GetHash

func (s *Session) GetHash() string

func (*Session) Marshal

func (s *Session) Marshal() ([]byte, error)

func (*Session) String

func (s *Session) String() string

func (*Session) Unmarshal

func (s *Session) Unmarshal(data []byte) error

type Tag

type Tag struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳