# QUIZZES

quizzes endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /quizzes/:quiz_id/questions

Add a question to a quiz. A scorecard takes single, multi (option_points for every option), scale (points for 10 out of 10), text and long (not scored) and number (a number, money or a percentage with min, max, step and format; not scored), each optionally in a category. Every question has a key that calculated results use (made from the question when you leave it blank). A test takes single (correct_index) and multi (correct_indexes), worth points (default 1).

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-questions.md)

### POST /quizzes/:quiz_id/attempts/:attempt_id/allow-retake

Let someone take the quiz again: this attempt stops counting towards their limit. Their score stays on record.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-attempts-attempt-id-allow-retake.md)

### POST /quizzes/:quiz_id/archive

Archive a quiz: it stops showing on Lead Magnet pages and in courses, and everyone's scores stay. Set status live with update_quiz to bring it back.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-archive.md)

### POST /quizzes/:quiz_id/calculate

Work out the quiz's calculated results (its calculations) for sample answers, instantly: { calculated: { outputs: [{ key, label, value, display, format }] } } with display written the way a person reads it ($3,597.30, 80%). Answers go by question key or id; a choice can be the option's words. Nothing is saved or charged. Send calculations to try a definition that is not saved yet; its problems come back in plain words.

**Scopes:** `quizzes:read` — [full detail](./quizzes/post-quizzes-quiz-id-calculate.md)

### POST /quizzes

Create a quiz as a draft: a scorecard (points per answer, categories and results; the default) or a test (right or wrong answers and a pass mark). A scorecard can also have number questions (never scored) and calculated results (update_quiz calculations). Then add questions (add_quiz_question or generate_quiz_questions), for a scorecard its categories and results, and set it live with update_quiz.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes.md)

### POST /quizzes/:quiz_id/categories

Add a category to a scorecard (e.g. "Online presence"): each question can count towards one, and everyone gets a score out of 100 for each category as well as overall.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-categories.md)

### POST /quizzes/:quiz_id/results

Add a result to a scorecard: a score range (min_score to max_score, 0 to 100) with a name and what it means, shown and emailed to people who land in it. Ranges never overlap; together they must cover 0 to 100 with no gaps before the quiz goes live (warnings says what is still missing).

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-results.md)

### DELETE /quizzes/:quiz_id

Delete a quiz nobody has taken and nothing uses. Refused once anyone took it (archive it instead), or while a course module or a Lead Magnet page uses it.

**Scopes:** `quizzes:delete` — [full detail](./quizzes/delete-quizzes-quiz-id.md)

### DELETE /quizzes/:quiz_id/categories/:category_id

Remove a scorecard category. Its questions stay and count towards the overall score only.

**Scopes:** `quizzes:write` — [full detail](./quizzes/delete-quizzes-quiz-id-categories-category-id.md)

### DELETE /quizzes/:quiz_id/questions/:question_id

Remove a question from a quiz. Attempts already made keep their copy of it.

**Scopes:** `quizzes:write` — [full detail](./quizzes/delete-quizzes-quiz-id-questions-question-id.md)

### DELETE /quizzes/:quiz_id/results/:result_id

Remove a scorecard result. People already in it keep their score; they just have no result name.

**Scopes:** `quizzes:write` — [full detail](./quizzes/delete-quizzes-quiz-id-results-result-id.md)

### POST /quizzes/:quiz_id/duplicate

Copy a quiz as a new draft called "<name> (copy)": its settings, questions, categories and results. The people who took it, their scores and where it is used are not copied. Returns the new quiz (copied_from is the original).

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-duplicate.md)

### POST /quizzes/:quiz_id/attempts/:attempt_id/email-score

Email someone their score again (the quiz's subject and opening words, in your workspace's email design). Not sent to a contact who unsubscribed.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-attempts-attempt-id-email-score.md)

### POST /quizzes/:quiz_id/questions/generate

Write questions for a quiz with AI from a brief (what they should find out), with points (scorecards) or right answers (tests), and add them. Every question passes the same checks as one you write. Costs 16 credits a go, refunded when nothing usable comes back. replace=true swaps out the current questions.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-questions-generate.md)

### GET /quizzes/:quiz_id

Get one quiz: its settings, every question (with its key, right answers and points, and a number question's min, max, step and format), its calculated results (calculations: rate tables and formulas), its categories and results (scorecards: what each score range means; results_problems says what is missing before it can go live), where it is used and its stats.

**Scopes:** `quizzes:read` — [full detail](./quizzes/get-quizzes-quiz-id.md)

### GET /quizzes/:quiz_id/attempts/:attempt_id

Get one person's attempt: their score, result and categories, and every answer they gave with the points it earned (or right or wrong for a test).

**Scopes:** `quizzes:read` — [full detail](./quizzes/get-quizzes-quiz-id-attempts-attempt-id.md)

### GET /quizzes/:quiz_id/attempts

List the people who took a quiz, newest first: who they are (name, email, business; their contact or cold campaign lead), their score, result and category scores, passed (tests), where they took it (a course module or a Lead Magnet pass), whether their score was emailed. Filters: status (open, submitted), result_id, passed, where (course, lead_magnet), contact_id, limit, offset.

**Scopes:** `quizzes:read` — [full detail](./quizzes/get-quizzes-quiz-id-attempts.md)

### GET /quizzes

List the workspace's quizzes, newest change first, archived ones left out unless status=archived. Each has its kind (scorecard or test), status, settings, question_count, used_in (course modules and Lead Magnet pages) and stats (how many finished, average score, percent passed). Filters: kind, status, used_in (course, lead_magnet, anywhere, nowhere), search (name), limit, offset.

**Scopes:** `quizzes:read` — [full detail](./quizzes/get-quizzes.md)

### POST /quizzes/:quiz_id/questions/reorder

Put a quiz's questions in a new order: send every question id once, in the order they should show.

**Scopes:** `quizzes:write` — [full detail](./quizzes/post-quizzes-quiz-id-questions-reorder.md)

### PATCH /quizzes/:quiz_id

Change a quiz's name, status, pass mark, questions drawn, attempts, wait between attempts, what they see when they finish and the score email. Setting it live checks it has questions and, for a scorecard with results, that they cover 0 to 100. A course module quiz's settings change here too.

**Scopes:** `quizzes:write` — [full detail](./quizzes/patch-quizzes-quiz-id.md)

### PATCH /quizzes/:quiz_id/categories/:category_id

Rename a scorecard category, change its colour or move it.

**Scopes:** `quizzes:write` — [full detail](./quizzes/patch-quizzes-quiz-id-categories-category-id.md)

### PATCH /quizzes/:quiz_id/questions/:question_id

Change a quiz question: send only what changes; it is checked as the whole question it becomes. A new kind or new options need their points or right answers sent again. People who already took the quiz keep the copy they answered.

**Scopes:** `quizzes:write` — [full detail](./quizzes/patch-quizzes-quiz-id-questions-question-id.md)

### PATCH /quizzes/:quiz_id/results/:result_id

Change a scorecard result's range, name or words. The ranges are checked again (no overlaps; warnings lists gaps).

**Scopes:** `quizzes:write` — [full detail](./quizzes/patch-quizzes-quiz-id-results-result-id.md)
