-- name: CreateQuestionOption :one
INSERT INTO question_options (
    question_id,
    option_text,
    option_order,
    is_correct
)
VALUES ($1, $2, COALESCE($3, 0), COALESCE($4, false))
RETURNING *;

-- name: GetOptionsByQuestionID :many
SELECT *
FROM question_options
WHERE question_id = $1
ORDER BY option_order;

-- name: UpdateQuestionOption :exec
UPDATE question_options
SET
    option_text = COALESCE($1, option_text),
    option_order = COALESCE($2, option_order),
    is_correct = COALESCE($3, is_correct)
WHERE id = $4;

-- name: DeleteQuestionOption :exec
DELETE FROM question_options
WHERE id = $1;

-- name: DeleteOptionsByQuestionID :exec
DELETE FROM question_options
WHERE question_id = $1;

-- name: BulkCreateQuestionOptions :copyfrom
INSERT INTO question_options (
    question_id,
    option_text,
    option_order,
    is_correct
) VALUES ($1, $2, $3, $4);
