fix: include answer_text of self_check questions in the quiz payload
This commit is contained in:
@@ -134,18 +134,28 @@ func TestQuizAPIFlow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The quiz payload never reveals a solution.
|
||||
// The quiz payload never reveals a solution; only self_check flashcards carry answer_text.
|
||||
code, raw := c.do("GET", apiPrefix+"/quizzes/swiat", token, "")
|
||||
if code != 200 {
|
||||
t.Fatalf("GET /quizzes/swiat = %d", code)
|
||||
}
|
||||
body, _ := json.Marshal(raw)
|
||||
for _, leak := range []string{"is_correct", "explanation", "answer_text", "Warszawa od 1596"} {
|
||||
for _, leak := range []string{"is_correct", "explanation", "Warszawa od 1596"} {
|
||||
if strings.Contains(string(body), leak) {
|
||||
t.Errorf("GET /quizzes/swiat leaks %q: %s", leak, body)
|
||||
}
|
||||
}
|
||||
quiz := data(raw)
|
||||
for _, qi := range quiz["questions"].([]any) {
|
||||
qm := qi.(map[string]any)
|
||||
text, has := qm["answer_text"]
|
||||
if (qm["type"] == "self_check") != has {
|
||||
t.Errorf("question %v (%v): answer_text present = %v", qm["id"], qm["type"], has)
|
||||
}
|
||||
if has && text != "Zdolność społeczeństwa do..." {
|
||||
t.Errorf("self_check answer_text = %v", text)
|
||||
}
|
||||
}
|
||||
if qs := quiz["questions"].([]any); len(qs) != 3 || qs[0].(map[string]any)["id"] != float64(f.single.ID) {
|
||||
t.Errorf("questions = %v, want three in sort order", qs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user