feat: quiz and rbac
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user