diff options
Diffstat (limited to 'internal/handlers')
-rw-r--r-- | internal/handlers/main.go | 13 |
1 files changed, 2 insertions, 11 deletions
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 = `<div data-testid="feedback" class="feedback">Correct! 🎉</div>` - } else { - question.Status = 2 - feedback = `<div data-testid="feedback" class="feedback">Wrong answer! The correct answer was: ` + getCorrectOption(question) + `</div>` - } - // 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) } |