From e14463c1033bce540bb254ec49b92673fc04a3f9 Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 5 Apr 2025 14:47:07 +0300 Subject: fix: properly fetch question from DB in HandleAnswer --- internal/handlers/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 686b0ce..2fe749c 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -50,6 +50,14 @@ func (h *Handlers) HandleAnswer(w http.ResponseWriter, r *http.Request) { "selected", selectedIndex, "question_id", questionID) + // Get question from database + question, err := h.repo.DBGetQuestion(questionID) + if err != nil { + h.log.Error("failed to get question", "error", err, "question_id", questionID) + abortWithError(w, "Question not found") + return + } + var feedback string if selectedIndex == fmt.Sprint(question.CorrectIndex) { feedback = `
Correct! 🎉
` -- cgit v1.2.3