80 lines
1.4 KiB
SQL
80 lines
1.4 KiB
SQL
-- name: CreatePracticeQuestion :one
|
|
INSERT INTO practice_questions (
|
|
practice_id,
|
|
question,
|
|
question_voice_prompt,
|
|
sample_answer_voice_prompt,
|
|
sample_answer,
|
|
tips,
|
|
type
|
|
)
|
|
VALUES (
|
|
$1, -- practice_id
|
|
$2, -- question
|
|
$3, -- question_voice_prompt
|
|
$4, -- sample_answer_voice_prompt
|
|
$5, -- sample_answer
|
|
$6, -- tips
|
|
$7 -- type (MCQ, TRUE_FALSE, SHORT)
|
|
)
|
|
RETURNING
|
|
id,
|
|
practice_id,
|
|
question,
|
|
question_voice_prompt,
|
|
sample_answer_voice_prompt,
|
|
sample_answer,
|
|
tips,
|
|
type;
|
|
|
|
-- name: GetPracticeQuestionByID :one
|
|
SELECT
|
|
id,
|
|
practice_id,
|
|
question,
|
|
question_voice_prompt,
|
|
sample_answer_voice_prompt,
|
|
sample_answer,
|
|
tips,
|
|
type
|
|
FROM practice_questions
|
|
WHERE id = $1;
|
|
|
|
-- name: ListPracticeQuestions :many
|
|
SELECT
|
|
id,
|
|
practice_id,
|
|
question,
|
|
question_voice_prompt,
|
|
sample_answer_voice_prompt,
|
|
sample_answer,
|
|
tips,
|
|
type
|
|
FROM practice_questions
|
|
WHERE practice_id = $1
|
|
ORDER BY id ASC;
|
|
|
|
-- name: UpdatePracticeQuestion :one
|
|
UPDATE practice_questions
|
|
SET
|
|
question = $2,
|
|
question_voice_prompt = $3,
|
|
sample_answer_voice_prompt = $4,
|
|
sample_answer = $5,
|
|
tips = $6,
|
|
type = $7
|
|
WHERE id = $1
|
|
RETURNING
|
|
id,
|
|
practice_id,
|
|
question,
|
|
question_voice_prompt,
|
|
sample_answer_voice_prompt,
|
|
sample_answer,
|
|
tips,
|
|
type;
|
|
|
|
-- name: DeletePracticeQuestion :exec
|
|
DELETE FROM practice_questions
|
|
WHERE id = $1;
|