From ba24de361eb2133d5e014d5796f654c82e6d69cb Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 5 Apr 2025 17:56:09 +0300 Subject: feat: return full Question model in /answer response --- internal/handlers/main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'internal/handlers') diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 4717f3c..a685b88 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -88,8 +88,19 @@ func (h *Handlers) HandleAnswer(w http.ResponseWriter, r *http.Request) { feedback = `
Wrong answer! The correct answer was: ` + getCorrectOption(question) + `
` } + // Render feedback section with full question state + tmpl, err := template.ParseGlob("components/*.html") + if err != nil { + abortWithError(w, err.Error()) + return + } + + // Execute template with question data including status w.Header().Set("Content-Type", "text/html") - w.Write([]byte(feedback)) + err = tmpl.ExecuteTemplate(w, "feedback", question) + if err != nil { + h.log.Error("failed to render feedback template", "error", err) + } } func getCorrectOption(q *models.Question) string { -- cgit v1.2.3