Files
sm-quizzes-plugin/models/question.go

54 lines
1.8 KiB
Go

// Code generated by summer make. DO NOT EDIT.
package models
import "time"
// Question types.
const (
TypeSingle = "single"
TypeMultiple = "multiple"
TypeSelfCheck = "self_check"
)
// QuestionTypes lists the valid values of Question.Type.
var QuestionTypes = []string{TypeSingle, TypeMultiple, TypeSelfCheck}
// Question is one question of a quiz. A self_check question is a flashcard:
// the user reveals AnswerText and marks whether they knew it.
type Question struct {
ID uint `gorm:"column:id;primaryKey"`
QuizID uint `gorm:"column:quiz_id"`
Text string `gorm:"column:text"`
Type string `gorm:"column:type"`
Category *string `gorm:"column:category"`
AnswerText *string `gorm:"column:answer_text"`
Explanation *string `gorm:"column:explanation"`
SortOrder int `gorm:"column:sort_order"`
Points int `gorm:"column:points"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
Quiz *Quiz `gorm:"foreignKey:QuizID"`
Answers []Answer `gorm:"foreignKey:QuestionID"`
}
// TableName is the plugin-prefixed table.
func (Question) TableName() string { return "golem15_quizzes_questions" }
// Fillable lists the columns mass assignment may set.
func (Question) Fillable() []string {
return []string{"quiz_id", "text", "type", "category", "answer_text", "explanation", "sort_order", "points"}
}
// Rules are checked by the admin API on every save.
func (Question) Rules() map[string]string {
return map[string]string{
"quiz_id": "required|integer|min:1",
"text": "required",
"type": "required|in:single,multiple,self_check",
"category": "nullable|max:255",
"sort_order": "nullable|integer",
"points": "required|integer|min:0",
}
}