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:
15
classes/policy.go
Normal file
15
classes/policy.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package classes
|
||||
|
||||
import "git.golem15.com/golem15/sm-quizzes-plugin/models"
|
||||
|
||||
// IsTest reports whether the quiz runs as a test. A zero or unknown mode is
|
||||
// learning, so a quiz written before test mode existed keeps its behaviour.
|
||||
func IsTest(q *models.Quiz) bool { return q != nil && q.Mode == models.ModeTest }
|
||||
|
||||
// Withheld reports whether an attempt's solutions must stay hidden: it is
|
||||
// an attempt at a test that is not finished yet. Every student serializer
|
||||
// drops is_correct, points, correct answers, explanations and model answers
|
||||
// while it is true.
|
||||
func Withheld(a *models.Attempt) bool {
|
||||
return a != nil && IsTest(a.Quiz) && a.CompletedAt == nil
|
||||
}
|
||||
Reference in New Issue
Block a user