summaryrefslogtreecommitdiff
path: root/internal/handlers/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/main.go')
-rw-r--r--internal/handlers/main.go8
1 files changed, 8 insertions, 0 deletions
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 = `<div class="feedback">Correct! 🎉</div>`