fix: include answer_text of self_check questions in the quiz payload
This commit is contained in:
@@ -62,15 +62,18 @@ type quizJSON struct {
|
||||
}
|
||||
|
||||
// questionJSON is a question as the player sees it before answering: no
|
||||
// is_correct, explanation or answer_text.
|
||||
// is_correct or explanation, and no answer_text except for self_check
|
||||
// flashcards, which have no solution to hide.
|
||||
type questionJSON struct {
|
||||
ID uint `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Type string `json:"type"`
|
||||
Category *string `json:"category"`
|
||||
Points int `json:"points"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
Answers []answerJSON `json:"answers"`
|
||||
ID uint `json:"id"`
|
||||
Text string `json:"text"`
|
||||
Type string `json:"type"`
|
||||
Category *string `json:"category"`
|
||||
Points int `json:"points"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
// AnswerText is the model answer of a self_check question only.
|
||||
AnswerText *string `json:"answer_text,omitempty"`
|
||||
Answers []answerJSON `json:"answers"`
|
||||
}
|
||||
|
||||
type answerJSON struct {
|
||||
@@ -110,6 +113,9 @@ func question(q models.Question) questionJSON {
|
||||
SortOrder: q.SortOrder,
|
||||
Answers: make([]answerJSON, 0, len(q.Answers)),
|
||||
}
|
||||
if q.Type == models.TypeSelfCheck {
|
||||
out.AnswerText = q.AnswerText
|
||||
}
|
||||
for _, a := range q.Answers {
|
||||
out.Answers = append(out.Answers, answerJSON{ID: a.ID, Text: a.Text})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user