From c2d82a17832590d86c7c243671b64df95913350e Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 5 Apr 2025 17:36:57 +0300 Subject: refactor: track question status using Status field instead of showNext flag --- components/index.html | 2 +- internal/handlers/main.go | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/components/index.html b/components/index.html index 50839f4..3efca24 100644 --- a/components/index.html +++ b/components/index.html @@ -15,7 +15,7 @@
{{if .Correct}}{{template "feedback" .}}{{else if .Requirement}}{{template "feedback" .}}{{end}} - {{if .ShowNext}} + {{if ne .Status 0}}
` } else { + question.Status = 2 feedback = `
Wrong answer! The correct answer was: ` + getCorrectOption(question) + `
` } @@ -119,7 +119,6 @@ func (h *Handlers) HandleNextQuestion(w http.ResponseWriter, r *http.Request) { return } - h.showNext = false // Reset flag for new question h.renderQuestion(w, question) } @@ -133,8 +132,6 @@ func (h *Handlers) renderQuestion(w http.ResponseWriter, question *models.Questi // Add ShowNext flag to template data type TemplateData struct { *models.Question - ShowNext bool - Correct bool } err = tmpl.ExecuteTemplate(w, "main", &TemplateData{ @@ -161,6 +158,5 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { return } - h.showNext = false h.renderQuestion(w, question) } -- cgit v1.2.3