89 lines
2.1 KiB
SQL
89 lines
2.1 KiB
SQL
-- name: CreateLmsPractice :one
|
|
INSERT INTO lms_practices (
|
|
course_id, module_id, lesson_id,
|
|
title, story_description, story_image, persona_id, question_set_id, quick_tips
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
RETURNING *;
|
|
|
|
-- name: GetLmsPracticeByID :one
|
|
SELECT *
|
|
FROM lms_practices
|
|
WHERE id = $1;
|
|
|
|
-- name: ListLmsPracticesByCourseID :many
|
|
SELECT
|
|
COUNT(*) OVER () AS total_count,
|
|
p.id,
|
|
p.course_id,
|
|
p.module_id,
|
|
p.lesson_id,
|
|
p.title,
|
|
p.story_description,
|
|
p.story_image,
|
|
p.persona_id,
|
|
p.question_set_id,
|
|
p.quick_tips,
|
|
p.created_at,
|
|
p.updated_at
|
|
FROM lms_practices p
|
|
WHERE p.course_id = $1
|
|
ORDER BY p.created_at DESC
|
|
LIMIT $2 OFFSET $3;
|
|
|
|
-- name: ListLmsPracticesByModuleID :many
|
|
SELECT
|
|
COUNT(*) OVER () AS total_count,
|
|
p.id,
|
|
p.course_id,
|
|
p.module_id,
|
|
p.lesson_id,
|
|
p.title,
|
|
p.story_description,
|
|
p.story_image,
|
|
p.persona_id,
|
|
p.question_set_id,
|
|
p.quick_tips,
|
|
p.created_at,
|
|
p.updated_at
|
|
FROM lms_practices p
|
|
WHERE p.module_id = $1
|
|
ORDER BY p.created_at DESC
|
|
LIMIT $2 OFFSET $3;
|
|
|
|
-- name: ListLmsPracticesByLessonID :many
|
|
SELECT
|
|
COUNT(*) OVER () AS total_count,
|
|
p.id,
|
|
p.course_id,
|
|
p.module_id,
|
|
p.lesson_id,
|
|
p.title,
|
|
p.story_description,
|
|
p.story_image,
|
|
p.persona_id,
|
|
p.question_set_id,
|
|
p.quick_tips,
|
|
p.created_at,
|
|
p.updated_at
|
|
FROM lms_practices p
|
|
WHERE p.lesson_id = $1
|
|
ORDER BY p.created_at DESC
|
|
LIMIT $2 OFFSET $3;
|
|
|
|
-- name: UpdateLmsPractice :one
|
|
UPDATE lms_practices
|
|
SET
|
|
title = COALESCE(sqlc.narg('title')::varchar, title),
|
|
story_description = COALESCE(sqlc.narg('story_description')::text, story_description),
|
|
story_image = COALESCE(sqlc.narg('story_image')::text, story_image),
|
|
persona_id = COALESCE(sqlc.narg('persona_id')::bigint, persona_id),
|
|
question_set_id = COALESCE(sqlc.narg('question_set_id')::bigint, question_set_id),
|
|
quick_tips = COALESCE(sqlc.narg('quick_tips')::text, quick_tips),
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = sqlc.arg('id')
|
|
RETURNING *;
|
|
|
|
-- name: DeleteLmsPractice :exec
|
|
DELETE FROM lms_practices
|
|
WHERE id = $1;
|