feat: quiz and rbac

This commit is contained in:
Krispire Admin
2026-10-15 19:43:17 +05:30
parent 7d7ba2a002
commit 4b38047c26
26 changed files with 3270 additions and 75 deletions
+14
View File
@@ -0,0 +1,14 @@
-- Multiple-choice questions with more than one correct answer.
--
-- A question marked multi asks the reader to "select all that apply"; it is
-- scored correct only when the chosen set equals the correct set exactly. A
-- single-answer question keeps exactly one correct option.
ALTER TABLE quiz_questions ADD COLUMN IF NOT EXISTS multi BOOLEAN NOT NULL DEFAULT FALSE;
-- An answer is now a set of options. Arrays can't carry a foreign key; that
-- is safe here because a quiz's options are frozen once anyone has answered,
-- and options only ever go away with their whole question.
ALTER TABLE quiz_answers ADD COLUMN IF NOT EXISTS option_ids UUID[];
UPDATE quiz_answers SET option_ids = ARRAY[option_id]
WHERE option_id IS NOT NULL AND option_ids IS NULL;
ALTER TABLE quiz_answers DROP COLUMN IF EXISTS option_id;