quiz

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExampleQuizGeography = models.Quiz{
	ID:          999,
	Title:       "Geography",
	Description: "This is a quiz about capitals around the world",
	Questions: []models.Question{
		{
			Text: "What is the capital of France?",
			Answers: []models.Answer{
				{Text: "Paris", IsCorrect: true},
				{Text: "Berlin", IsCorrect: false},
				{Text: "Warsaw", IsCorrect: false},
				{Text: "Barcelona", IsCorrect: false},
			},
		},
		{
			Text: "On which continent is Russia?",
			Answers: []models.Answer{
				{Text: "Europe", IsCorrect: true},
				{Text: "Asia", IsCorrect: true},
				{Text: "North America", IsCorrect: false},
				{Text: "South America", IsCorrect: false},
			},
		},
	},
}
View Source
var ExampleQuizMath = models.Quiz{
	ID:          998,
	Title:       "Math",
	Description: "This is a quiz about math",
	Questions: []models.Question{
		{
			Text: "What is 2 + 2?",
			Answers: []models.Answer{
				{Text: "4", IsCorrect: true},
				{Text: "5", IsCorrect: false},
			},
		},
		{
			Text: "What is 3 * 3?",
			Answers: []models.Answer{
				{Text: "9", IsCorrect: true},
				{Text: "6", IsCorrect: false},
			},
		},
	},
}
View Source
var QuizCreateTemplate = tmplParseWithBase("templates/quizzes/quiz-create.html")
View Source
var QuizPreviewTemplate = tmplParseWithBase("templates/quizzes/quiz-preview.html")
View Source
var QuizUpdateTemplate = tmplParseWithBase("templates/quizzes/quiz-update-2.0.html")
View Source
var QuizzesTemplate = tmplParseWithBase("templates/quizzes/quizzes.html")

Templates used to render the different pages of the quiz

Functions

func NewQuizzesRouter

func NewQuizzesRouter() http.Handler

Types

type ErrQuizAlreadyExists

type ErrQuizAlreadyExists struct{}

func (ErrQuizAlreadyExists) Error

func (ErrQuizAlreadyExists) Error() string

type ErrQuizNotFound

type ErrQuizNotFound struct{}

func (ErrQuizNotFound) Error

func (ErrQuizNotFound) Error() string

type GormQuizRepository

type GormQuizRepository struct {
	DB *gorm.DB
}

DB for quizzes

var QuizzesRepo *GormQuizRepository

func NewGormQuizRepository

func NewGormQuizRepository(db *gorm.DB) *GormQuizRepository

func (*GormQuizRepository) AddQuiz

func (r *GormQuizRepository) AddQuiz(q models.Quiz) (uint, error)

func (*GormQuizRepository) DeleteQuiz

func (r *GormQuizRepository) DeleteQuiz(id uint) error

func (*GormQuizRepository) GetAllQuizzes

func (r *GormQuizRepository) GetAllQuizzes() ([]models.Quiz, error)

func (*GormQuizRepository) GetAllQuizzesMetadata

func (r *GormQuizRepository) GetAllQuizzesMetadata() ([]models.QuizMetadata, error)

func (*GormQuizRepository) GetQuiz

func (r *GormQuizRepository) GetQuiz(id uint) (models.Quiz, error)

func (*GormQuizRepository) UpdateQuiz

func (r *GormQuizRepository) UpdateQuiz(q models.Quiz) (uint, error)

type QuizRepository

type QuizRepository interface {
	AddQuiz(models.Quiz) (uint, error)
	UpdateQuiz(models.Quiz) (uint, error)
	GetQuiz(id uint) (models.Quiz, error)
	DeleteQuiz(id uint) error
	GetAllQuizzes() ([]models.Quiz, error)
	GetAllQuizzesMetadata() ([]models.QuizMetadata, error)
}

Jump to

Keyboard shortcuts

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