216 lines
4.8 KiB
Go
216 lines
4.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: practice_questions.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const CreatePracticeQuestion = `-- 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
|
|
`
|
|
|
|
type CreatePracticeQuestionParams struct {
|
|
PracticeID int64 `json:"practice_id"`
|
|
Question string `json:"question"`
|
|
QuestionVoicePrompt pgtype.Text `json:"question_voice_prompt"`
|
|
SampleAnswerVoicePrompt pgtype.Text `json:"sample_answer_voice_prompt"`
|
|
SampleAnswer pgtype.Text `json:"sample_answer"`
|
|
Tips pgtype.Text `json:"tips"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
func (q *Queries) CreatePracticeQuestion(ctx context.Context, arg CreatePracticeQuestionParams) (PracticeQuestion, error) {
|
|
row := q.db.QueryRow(ctx, CreatePracticeQuestion,
|
|
arg.PracticeID,
|
|
arg.Question,
|
|
arg.QuestionVoicePrompt,
|
|
arg.SampleAnswerVoicePrompt,
|
|
arg.SampleAnswer,
|
|
arg.Tips,
|
|
arg.Type,
|
|
)
|
|
var i PracticeQuestion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PracticeID,
|
|
&i.Question,
|
|
&i.QuestionVoicePrompt,
|
|
&i.SampleAnswerVoicePrompt,
|
|
&i.SampleAnswer,
|
|
&i.Tips,
|
|
&i.Type,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const DeletePracticeQuestion = `-- name: DeletePracticeQuestion :exec
|
|
DELETE FROM practice_questions
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeletePracticeQuestion(ctx context.Context, id int64) error {
|
|
_, err := q.db.Exec(ctx, DeletePracticeQuestion, id)
|
|
return err
|
|
}
|
|
|
|
const GetPracticeQuestionByID = `-- 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
|
|
`
|
|
|
|
func (q *Queries) GetPracticeQuestionByID(ctx context.Context, id int64) (PracticeQuestion, error) {
|
|
row := q.db.QueryRow(ctx, GetPracticeQuestionByID, id)
|
|
var i PracticeQuestion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PracticeID,
|
|
&i.Question,
|
|
&i.QuestionVoicePrompt,
|
|
&i.SampleAnswerVoicePrompt,
|
|
&i.SampleAnswer,
|
|
&i.Tips,
|
|
&i.Type,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const ListPracticeQuestions = `-- 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
|
|
`
|
|
|
|
func (q *Queries) ListPracticeQuestions(ctx context.Context, practiceID int64) ([]PracticeQuestion, error) {
|
|
rows, err := q.db.Query(ctx, ListPracticeQuestions, practiceID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []PracticeQuestion
|
|
for rows.Next() {
|
|
var i PracticeQuestion
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.PracticeID,
|
|
&i.Question,
|
|
&i.QuestionVoicePrompt,
|
|
&i.SampleAnswerVoicePrompt,
|
|
&i.SampleAnswer,
|
|
&i.Tips,
|
|
&i.Type,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const UpdatePracticeQuestion = `-- 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
|
|
`
|
|
|
|
type UpdatePracticeQuestionParams struct {
|
|
ID int64 `json:"id"`
|
|
Question string `json:"question"`
|
|
QuestionVoicePrompt pgtype.Text `json:"question_voice_prompt"`
|
|
SampleAnswerVoicePrompt pgtype.Text `json:"sample_answer_voice_prompt"`
|
|
SampleAnswer pgtype.Text `json:"sample_answer"`
|
|
Tips pgtype.Text `json:"tips"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePracticeQuestion(ctx context.Context, arg UpdatePracticeQuestionParams) (PracticeQuestion, error) {
|
|
row := q.db.QueryRow(ctx, UpdatePracticeQuestion,
|
|
arg.ID,
|
|
arg.Question,
|
|
arg.QuestionVoicePrompt,
|
|
arg.SampleAnswerVoicePrompt,
|
|
arg.SampleAnswer,
|
|
arg.Tips,
|
|
arg.Type,
|
|
)
|
|
var i PracticeQuestion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PracticeID,
|
|
&i.Question,
|
|
&i.QuestionVoicePrompt,
|
|
&i.SampleAnswerVoicePrompt,
|
|
&i.SampleAnswer,
|
|
&i.Tips,
|
|
&i.Type,
|
|
)
|
|
return i, err
|
|
}
|