summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder (aider) <wohilas@gmail.com>2025-04-05 12:28:35 +0300
committerGrail Finder (aider) <wohilas@gmail.com>2025-04-05 12:28:35 +0300
commita23b77f76f373cd02192117e0ba0aaa389aa9c1a (patch)
tree0dd16fcda68fc5e12f523871a7d64b569d9170ad
parentd508685f63107c070b20a9fcc2f63ecbd74a08a6 (diff)
feat: add SQLite schema for quiz questions storage
-rw-r--r--internal/database/migrations/002_quiz_schema.down.sql1
-rw-r--r--internal/database/migrations/002_quiz_schema.up.sql17
-rw-r--r--internal/models/models.go25
3 files changed, 30 insertions, 13 deletions
diff --git a/internal/database/migrations/002_quiz_schema.down.sql b/internal/database/migrations/002_quiz_schema.down.sql
new file mode 100644
index 0000000..8f644e8
--- /dev/null
+++ b/internal/database/migrations/002_quiz_schema.down.sql
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS questions;
diff --git a/internal/database/migrations/002_quiz_schema.up.sql b/internal/database/migrations/002_quiz_schema.up.sql
new file mode 100644
index 0000000..406432b
--- /dev/null
+++ b/internal/database/migrations/002_quiz_schema.up.sql
@@ -0,0 +1,17 @@
+CREATE TABLE IF NOT EXISTS questions (
+ id INTEGER PRIMARY KEY,
+ text TEXT NOT NULL,
+ option1 TEXT,
+ option2 TEXT,
+ option3 TEXT,
+ option4 TEXT,
+ correct_index INTEGER NOT NULL,
+ requirement TEXT,
+ explanation TEXT,
+ status INTEGER DEFAULT 0,
+ exam_id INTEGER,
+ mixed_id INTEGER
+);
+
+CREATE INDEX IF NOT EXISTS idx_questions_exam_id ON questions(exam_id);
+CREATE INDEX IF NOT EXISTS idx_questions_mixed_id ON questions(mixed_id);
diff --git a/internal/models/models.go b/internal/models/models.go
index c525466..8e30a6c 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -2,18 +2,17 @@ package models
type (
Question struct {
- ID uint32
- Text string
- Options []string
- CorrectIndex uint8
- TopicID uint32
- Feedback string
- FeedbackClass string
- }
- //
- Topic struct {
- ID uint32
- Name string
- Level uint32
+ ID uint32 `db:"id"`
+ Text string `db:"text"`
+ Option1 string `db:"option1"`
+ Option2 string `db:"option2"`
+ Option3 string `db:"option3"`
+ Option4 string `db:"option4"`
+ CorrectIndex uint8 `db:"correct_index"`
+ Requirement string `db:"requirement"`
+ Explanation string `db:"explanation"`
+ Status int `db:"status"`
+ ExamID uint32 `db:"exam_id"`
+ MixedID uint32 `db:"mixed_id"`
}
)