Also replace question options on update so placement grading stays consistent with admin edits, and tune the Postgres pool defaults. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
825 B
SQL
35 lines
825 B
SQL
-- name: CreateQuestionShortAnswer :one
|
|
INSERT INTO question_short_answers (
|
|
question_id,
|
|
acceptable_answer,
|
|
match_type
|
|
)
|
|
VALUES ($1, $2, COALESCE($3, 'EXACT'))
|
|
RETURNING *;
|
|
|
|
-- name: GetShortAnswersByQuestionID :many
|
|
SELECT *
|
|
FROM question_short_answers
|
|
WHERE question_id = $1;
|
|
|
|
-- name: GetShortAnswersByQuestionIDs :many
|
|
SELECT *
|
|
FROM question_short_answers
|
|
WHERE question_id = ANY($1::BIGINT[])
|
|
ORDER BY question_id, id;
|
|
|
|
-- name: UpdateQuestionShortAnswer :exec
|
|
UPDATE question_short_answers
|
|
SET
|
|
acceptable_answer = COALESCE($1, acceptable_answer),
|
|
match_type = COALESCE($2, match_type)
|
|
WHERE id = $3;
|
|
|
|
-- name: DeleteQuestionShortAnswer :exec
|
|
DELETE FROM question_short_answers
|
|
WHERE id = $1;
|
|
|
|
-- name: DeleteShortAnswersByQuestionID :exec
|
|
DELETE FROM question_short_answers
|
|
WHERE question_id = $1;
|