feat: carry open questions and the grader through import and the quiz tools
- import document, manage routes and MCP question tools take rubric and max_length; open questions refuse answers, max_length is 1..20000 and both apply to open questions only - quizzes take a grader; the manage routes refuse a code the registry does not know, the import accepts any well-formed code - quiz stats report unreviewed open answers and their average points - import_quiz warns that replace deletes the grades and reviews
This commit is contained in:
@@ -145,16 +145,23 @@ type updateQuizBody struct {
|
||||
PassingScore *int `json:"passing_score"`
|
||||
RoundSize *int `json:"round_size"`
|
||||
ShuffleQuestions *bool `json:"shuffle_questions"`
|
||||
Grader *string `json:"grader"`
|
||||
}
|
||||
|
||||
func (b updateQuizBody) input() classes.QuizInput {
|
||||
return classes.QuizInput{
|
||||
Title: b.Title, Description: b.Description, Context: b.Context, Mode: b.Mode, Navigation: b.Navigation,
|
||||
MaxAttempts: b.MaxAttempts, TimeLimitSeconds: b.TimeLimitSeconds, PassingScore: b.PassingScore,
|
||||
RoundSize: b.RoundSize, ShuffleQuestions: b.ShuffleQuestions,
|
||||
RoundSize: b.RoundSize, ShuffleQuestions: b.ShuffleQuestions, Grader: b.Grader,
|
||||
}
|
||||
}
|
||||
|
||||
// graderProblems checks a sent grader against the codes the application's
|
||||
// grader registry knows (manual and every registered grader).
|
||||
func (h *Handlers) graderProblems(in classes.QuizInput) []string {
|
||||
return classes.CheckGrader(in.Grader, classes.ForApp(h.App, nil).Graders.Codes())
|
||||
}
|
||||
|
||||
// answerQuiz counts and answers a quiz a write returned, or maps err.
|
||||
func answerQuiz(w http.ResponseWriter, r *http.Request, db *gorm.DB, status int, quiz *models.Quiz, err error) {
|
||||
if err != nil {
|
||||
@@ -174,7 +181,7 @@ func answerQuiz(w http.ResponseWriter, r *http.Request, db *gorm.DB, status int,
|
||||
// database is touched.
|
||||
func (h *Handlers) ManageCreateQuiz(w http.ResponseWriter, r *http.Request) {
|
||||
var in classes.QuizInput
|
||||
if !readManaged(w, r, &in) || refuse(w, classes.CheckQuizInput(in, true)) {
|
||||
if !readManaged(w, r, &in) || refuse(w, classes.CheckQuizInput(in, true)) || refuse(w, h.graderProblems(in)) {
|
||||
return
|
||||
}
|
||||
db, ok := h.manageDB(w)
|
||||
@@ -189,7 +196,8 @@ func (h *Handlers) ManageCreateQuiz(w http.ResponseWriter, r *http.Request) {
|
||||
// fields change.
|
||||
func (h *Handlers) ManageUpdateQuiz(w http.ResponseWriter, r *http.Request) {
|
||||
var body updateQuizBody
|
||||
if !readManaged(w, r, &body) || refuse(w, classes.CheckQuizInput(body.input(), false)) {
|
||||
if !readManaged(w, r, &body) || refuse(w, classes.CheckQuizInput(body.input(), false)) ||
|
||||
refuse(w, h.graderProblems(body.input())) {
|
||||
return
|
||||
}
|
||||
db, ok := h.manageDB(w)
|
||||
|
||||
Reference in New Issue
Block a user