From 1e5faf9b609fa230d763bccdd8520441c5498a15 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sun, 6 Apr 2025 10:04:22 +0300 Subject: Feat: add mixed exercsises --- components/index.html | 4 ++- components/question.html | 75 ++++++++++++++++++++++++++++++++++++++++ demoon.db | Bin 1544192 -> 1564672 bytes internal/database/repos/main.go | 3 +- internal/handlers/main.go | 2 +- internal/models/models.go | 6 ++++ 6 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 components/question.html diff --git a/components/index.html b/components/index.html index b8b126d..816fd21 100644 --- a/components/index.html +++ b/components/index.html @@ -13,13 +13,15 @@

Mixed Übungen

{{range .}} +

+

{{end}}
diff --git a/components/question.html b/components/question.html new file mode 100644 index 0000000..ef4618b --- /dev/null +++ b/components/question.html @@ -0,0 +1,75 @@ +{{define "question"}} +
+ {{if .Requirement}} +

{{.Requirement}}

+ {{end}} +
+ {{.Text}} +
+
+ {{if eq .Status 1}} + Correct! + {{end}} + {{if eq .Status 2}} + Wrong. + {{end}} +
+
+ {{if ne .Status 0}} +
+ {{.Explanation}} +
+ + {{end}} +
+
+ + + + +
+
+{{end}} diff --git a/demoon.db b/demoon.db index f7b60c7..9a0c635 100644 Binary files a/demoon.db and b/demoon.db differ diff --git a/internal/database/repos/main.go b/internal/database/repos/main.go index f6835c7..e49d303 100644 --- a/internal/database/repos/main.go +++ b/internal/database/repos/main.go @@ -2,12 +2,11 @@ package repos import ( "github.com/jmoiron/sqlx" - "demoon/internal/models" ) type FullRepo interface { DefaultsRepo - DBGetQuestion(id string) (*models.Question, error) + QuestionsRepo } type Provider struct { diff --git a/internal/handlers/main.go b/internal/handlers/main.go index b6ce093..34f37d9 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -171,7 +171,7 @@ func (h *Handlers) renderQuestion(w http.ResponseWriter, question *models.Questi *models.Question } - err = tmpl.ExecuteTemplate(w, "main", question) + err = tmpl.ExecuteTemplate(w, "question", question) if err != nil { h.log.Error("failed to render template", "error", err) } diff --git a/internal/models/models.go b/internal/models/models.go index 8e30a6c..7cef85e 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -15,4 +15,10 @@ type ( ExamID uint32 `db:"exam_id"` MixedID uint32 `db:"mixed_id"` } + MixedUbung struct { + ID uint32 `db:"MixedID"` + Name string `db:"MixedName"` + Status int `db:"MixedStatus"` + LevelID uint32 `db:"LevelID"` + } ) -- cgit v1.2.3