From 7243b0492390bb870084717800a0015dede3a5bc Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 5 Apr 2025 14:43:04 +0300 Subject: fix: update question model fields and feedback check --- internal/handlers/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 7e3bfa0..686b0ce 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -1,8 +1,9 @@ package handlers import ( + "fmt" "demoon/config" - "demoon/internal/database/repos" + "demoon/internal/database/repos" "demoon/internal/models" "html/template" "log/slog" @@ -50,7 +51,7 @@ func (h *Handlers) HandleAnswer(w http.ResponseWriter, r *http.Request) { "question_id", questionID) var feedback string - if selectedIndex == "1" { + if selectedIndex == fmt.Sprint(question.CorrectIndex) { feedback = `
Correct! 🎉
` } else { feedback = `
Wrong answer, try again! ❌
` @@ -70,10 +71,15 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { ID: 1, Text: "___ du keine Zweifel daran?", Option1: "Haben", - Option2: "Hast", + Option2: "Hast", Option3: "Hat", Option4: "Habt", CorrectIndex: 1, + Requirement: "Choose the correct verb form", + Explanation: "Use 'Hast' for 2nd person singular", + Status: 0, + ExamID: 1, + MixedID: 101, } err = tmpl.ExecuteTemplate(w, "main", testQuestion) if err != nil { -- cgit v1.2.3