Files
sm-quizzes-plugin/classes/policy.go
Jakub Zych 6c6ecae9d8 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
2026-11-09 14:03:34 +01:00

16 lines
662 B
Go

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
}