Files
sm-quizzes-plugin/controllers/quizzes.go
Jakub Zych 2ad4e8b1ec feat: review open answers in the admin and pick a grader per quiz
- Do oceny admin screen (golem15.quizzes.reviews) over the open answers,
  with a read-only context partial, score and comment virtual fields saved
  through SetScore, confirm and regrade record actions, bulk confirm
- open question type, rubric and max_length in the question form; grader
  dropdown on the quiz form from the grader registry
- Review model with quiz, status and student filters
2026-11-09 18:31:19 +01:00

68 lines
2.3 KiB
Go

// Code generated by summer make. DO NOT EDIT.
package controllers
import (
"git.golem15.com/golem15/sm-quizzes-plugin/graders"
"git.golem15.com/golem15/sm-quizzes-plugin/models"
"git.golem15.com/golem15/summercms/modules/pact"
)
var (
_ pact.AdminController = quizzesAdmin{}
_ pact.AdminRecordSource = quizzesAdmin{}
_ pact.AdminPermissioned = quizzesAdmin{}
_ pact.DropdownOptionsProvider = quizzesAdmin{}
)
// GraderOptions lists the grader dropdown choices: the registry golem15.quizzes
// built at boot. The plugin sets it at Boot; nil offers manual only.
//
// TODO: requires SummerCMS change. DropdownOptions receives neither a
// context nor the app, so the registry comes through a package-level hook.
var GraderOptions func() []graders.Option
// quizzesAdmin lists and edits quizzes. Questions have their own controller
// filtered by quiz.
//
// TODO: requires SummerCMS change. cabana's relation manager only links and
// unlinks belongsToMany records through a pivot; it cannot create or edit
// hasMany children inline, so the quiz form cannot embed its questions.
type quizzesAdmin struct{}
func (quizzesAdmin) ID() string { return "golem15.quizzes.quizzes" }
func (quizzesAdmin) ModelName() string { return "Quiz" }
func (quizzesAdmin) ConfigDir() string { return "controllers/quizzes" }
// NewRecord returns the model the generic admin handlers query and fill.
func (quizzesAdmin) NewRecord() any { return &models.Quiz{} }
// RequiredPermissions is checked before any schema or record is served.
func (quizzesAdmin) RequiredPermissions() []string {
return []string{"golem15.quizzes.access_quizzes"}
}
// DropdownOptions serves the grader dropdown (options: getGraderOptions):
// manual, then every grader an activated plugin registered. Other fields
// have no method-backed options.
func (quizzesAdmin) DropdownOptions(field string) []pact.Option {
if field != "grader" {
return nil
}
opts := []graders.Option{{Code: graders.Manual, Label: graders.ManualLabel}}
if GraderOptions != nil {
if got := GraderOptions(); len(got) > 0 {
opts = got
}
}
out := make([]pact.Option, 0, len(opts))
for _, o := range opts {
out = append(out, pact.Option{Value: o.Code, Label: o.Label})
}
return out
}
// QuizzesController returns the golem15.quizzes.quizzes admin controller.
func QuizzesController() pact.AdminController { return quizzesAdmin{} }