From d5d503e1ec81bd4e21cfb53566b015df61a99db5 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 5 Apr 2025 18:04:26 +0300 Subject: Enha: /answer to return question --- internal/handlers/main.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'internal/handlers') diff --git a/internal/handlers/main.go b/internal/handlers/main.go index a685b88..b485864 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -79,25 +79,16 @@ func (h *Handlers) HandleAnswer(w http.ResponseWriter, r *http.Request) { return } selectedIdx++ // in db index starts from 1 - feedback := "" - if selectedIdx == int(question.CorrectIndex) { - question.Status = 1 - feedback = `
Correct! 🎉
` - } else { - question.Status = 2 - 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") - err = tmpl.ExecuteTemplate(w, "feedback", question) + err = tmpl.ExecuteTemplate(w, "main", question) if err != nil { h.log.Error("failed to render feedback template", "error", err) } -- cgit v1.2.3