feat: add test mode to quizzes and withhold its solutions
- mode, navigation and max_attempts columns with Go-side defaults - classes.Withheld gates every solution field of the answer feedback and the attempt result while a test attempt is open - a test's quiz detail lists no questions before the attempt starts - admin fields and lang keys for the three settings
This commit is contained in:
28
updates/20261109120000_add_test_mode_to_quizzes.go
Normal file
28
updates/20261109120000_add_test_mode_to_quizzes.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by summer make. DO NOT EDIT.
|
||||
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// AddTestModeToQuizzes returns the 20261109120000_add_test_mode_to_quizzes gormigrate entry.
|
||||
// A test quiz withholds solutions until the attempt is finished; navigation
|
||||
// and max_attempts apply only to tests. Every existing quiz stays a learning
|
||||
// quiz with free navigation and no attempt limit.
|
||||
func AddTestModeToQuizzes() *gormigrate.Migration {
|
||||
return &gormigrate.Migration{
|
||||
ID: "20261109120000_add_test_mode_to_quizzes",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`ALTER TABLE golem15_quizzes_quizzes
|
||||
ADD COLUMN mode VARCHAR(20) NOT NULL DEFAULT 'learning' CHECK (mode IN ('learning', 'test')),
|
||||
ADD COLUMN navigation VARCHAR(20) NOT NULL DEFAULT 'free' CHECK (navigation IN ('free', 'one_way')),
|
||||
ADD COLUMN max_attempts INTEGER NULL CHECK (max_attempts IS NULL OR max_attempts >= 1)`).Error
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`ALTER TABLE golem15_quizzes_quizzes
|
||||
DROP COLUMN IF EXISTS max_attempts, DROP COLUMN IF EXISTS navigation, DROP COLUMN IF EXISTS mode`).Error
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user