fix: move quiz request
This commit is contained in:
parent
95a2f52339
commit
76b883af11
@ -570,31 +570,18 @@ WHERE
|
||||
Questions.percentage >= 1;
|
||||
|
||||
-- name: QuizCopyQid :one
|
||||
WITH original_quiz AS (
|
||||
SELECT id
|
||||
FROM quiz
|
||||
WHERE quiz.qid = $1 AND quiz.accountId = $2
|
||||
),
|
||||
new_quiz AS (
|
||||
INSERT INTO quiz (
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
)
|
||||
SELECT
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
$2, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
FROM
|
||||
quiz
|
||||
quiz as q
|
||||
WHERE
|
||||
qid = $1 AND accountId = $2
|
||||
RETURNING id,qid
|
||||
)
|
||||
SELECT
|
||||
original_quiz.id AS original_quiz_id,
|
||||
new_quiz.id AS new_quiz_id,
|
||||
new_quiz.qid AS original_qid
|
||||
FROM
|
||||
original_quiz, new_quiz;
|
||||
q.qid = $1
|
||||
RETURNING id,qid;
|
||||
|
||||
-- name: CopyQuestionQuizID :exec
|
||||
INSERT INTO question (
|
||||
@ -610,4 +597,4 @@ WHERE
|
||||
question.quiz_id = $1 AND deleted = false;
|
||||
|
||||
-- name: GetQidOwner :one
|
||||
SELECT accountid FROM quiz where qid=$1;
|
||||
SELECT accountid FROM quiz where qid=$1;
|
||||
|
@ -1751,31 +1751,18 @@ func (q *Queries) QuestionsStatistics(ctx context.Context, arg QuestionsStatisti
|
||||
}
|
||||
|
||||
const quizCopyQid = `-- name: QuizCopyQid :one
|
||||
WITH original_quiz AS (
|
||||
SELECT id
|
||||
FROM quiz
|
||||
WHERE quiz.qid = $1 AND quiz.accountId = $2
|
||||
),
|
||||
new_quiz AS (
|
||||
INSERT INTO quiz (
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
)
|
||||
SELECT
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
$2, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
FROM
|
||||
quiz
|
||||
quiz as q
|
||||
WHERE
|
||||
qid = $1 AND accountId = $2
|
||||
q.qid = $1
|
||||
RETURNING id,qid
|
||||
)
|
||||
SELECT
|
||||
original_quiz.id AS original_quiz_id,
|
||||
new_quiz.id AS new_quiz_id,
|
||||
new_quiz.qid AS original_qid
|
||||
FROM
|
||||
original_quiz, new_quiz
|
||||
`
|
||||
|
||||
type QuizCopyQidParams struct {
|
||||
@ -1784,15 +1771,14 @@ type QuizCopyQidParams struct {
|
||||
}
|
||||
|
||||
type QuizCopyQidRow struct {
|
||||
OriginalQuizID int64 `db:"original_quiz_id" json:"original_quiz_id"`
|
||||
NewQuizID int64 `db:"new_quiz_id" json:"new_quiz_id"`
|
||||
OriginalQid uuid.NullUUID `db:"original_qid" json:"original_qid"`
|
||||
ID int64 `db:"id" json:"id"`
|
||||
Qid uuid.NullUUID `db:"qid" json:"qid"`
|
||||
}
|
||||
|
||||
func (q *Queries) QuizCopyQid(ctx context.Context, arg QuizCopyQidParams) (QuizCopyQidRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, quizCopyQid, arg.Qid, arg.Accountid)
|
||||
var i QuizCopyQidRow
|
||||
err := row.Scan(&i.OriginalQuizID, &i.NewQuizID, &i.OriginalQid)
|
||||
err := row.Scan(&i.ID, &i.Qid)
|
||||
return i, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user