Building a Live Quiz Control Panel
An app page can run a live quiz the way the dashboard's Live Control tab does: open a session, send questions, read the counts, reveal answers, show the leaderboard and close the session. Both use the same platform control service, so a change made from the app and one made from the dashboard behave the same and broadcast the same events.
This guide was reviewed against platform source at 208d36e1b5 (live quiz control and collection-sourced options) on 2026-11-05. The bundled REST API reference includes a source-reviewed supplement for these endpoints; it is not a deployed-server capability check. Confirm the deployed platform includes them before relying on them.
Before you start
- Live mode must be on. An admin enables it on the quiz in the dashboard. An app cannot turn it on:
live_mode_enabledis not one of the settings the management API accepts. Opening a session or sending questions on a quiz without live mode returns 422 underlive_mode. - The app runs on a portal page. Every management request needs the app page's context (the page key the runtime sends). A request without it, such as one made with an API key, gets 404.
- The quiz is addressed by slug.
{form}in every path below is the quiz form's slug. Channels use the quiz's numeric ID instead, whichGET /statereturns; see Realtime channels.
Bind the app to the quiz
Declare a ProjectForm dependency with the live quiz abilities the app needs. A preset name stands for a set of abilities:
{
"model": "ProjectForm",
"identifier": "quiz",
"permissions": ["live_quiz_host"]
}
When the app version is saved, the platform expands a preset into the abilities it stands for and stores those, so an admin can still drop a single ability from an install. A scoped preset such as live_quiz_host:viewAny expands with the same scope on each ability. The Developer Hub dependency editor also offers an Add preset button that grants a preset's abilities.
On install, bind quiz to the quiz in the page's dependency list. The dashboard's form picker stores the form's slug. An app whose dependencies don't bind the quiz (by slug, ID, tag or *) gets 404 from every management endpoint, the same response as for a quiz that does not exist.
| Preset | Abilities |
|---|---|
live_quiz_viewer | view_live_quiz_state, view_live_quiz_analytics, view_live_quiz_history |
live_quiz_host | The viewer abilities, plus view_quiz_banks, open_live_quiz_session, close_live_quiz_session, send_live_quiz_questions, unsend_live_quiz_questions, review_live_quiz_questions, control_live_quiz_leaderboard, set_active_quiz_bank |
live_quiz_editor | view_quiz_banks, view_quiz_answers, update_quiz_bank_status, manage_quiz_banks, manage_quiz_questions |
live_quiz_admin | Every live quiz ability, including reset_live_quiz and update_live_quiz_settings |
The host preset can list banks and questions, to find the questions to send, but gets them without correct answers or explanations; that needs view_quiz_answers. It can't reset the quiz, change its live settings or edit banks. Add those abilities separately if the panel needs them.
How abilities are checked
- Each endpoint needs its own ability. Without it the request gets 403.
- Every control ability (open, close, reset, send, unsend, review, leaderboard, set active bank, bank status, manage banks, manage questions, live settings) also lets the app read the live state, since a controller has to see what it changed. No other ability is implied: a host without
view_live_quiz_analyticscannot read counts. - Correct answers, answer explanations and feedback come back only with
view_quiz_answers. This applies to the question listings and to the question returned after a create, update or reorder. - Sending a whole bank by
bank_idalso makes it the live bank, so it needsset_active_quiz_bankas well assend_live_quiz_questions. - An admin can drop single abilities from an installed page in its permission rules. A dropped ability gets 403 on the API and on the channels.
The same abilities are admin permissions. Dashboard admin roles that held manage_project_forms were granted all of them when this feature shipped, so existing quiz operators keep the Live Control tab.
Endpoints
Paths are relative to /api/v1/projects/{team}/{project}/quiz/{form}/manage. {bank} and {question} are numeric IDs.
| Method | Path | Ability | Input |
|---|---|---|---|
| GET | /state | view_live_quiz_state or any control ability | None |
| GET | /analytics | view_live_quiz_analytics | Optional question_id |
| GET | /session/analytics | view_live_quiz_analytics | Optional question_id; 404 when no session is open |
| GET | /session/history | view_live_quiz_history | Optional limit, 1–100, default 10 |
| POST | /live/open | open_live_quiz_session | Optional bank_id, question_ids |
| POST | /session/reopen | open_live_quiz_session | session_id |
| POST | /live/close | close_live_quiz_session | None |
| POST | /live/reset | reset_live_quiz | None |
| POST | /questions/send | send_live_quiz_questions | question_ids or bank_id; optional duration, max_selections |
| POST | /questions/unsend | unsend_live_quiz_questions | question_ids |
| POST | /review/start | review_live_quiz_questions | question_id; optional include_analytics, include_explanation (default true) |
| POST | /review/end | review_live_quiz_questions | None |
| POST | /leaderboard/show | control_live_quiz_leaderboard | None |
| POST | /leaderboard/hide | control_live_quiz_leaderboard | None |
| POST | /banks/active | set_active_quiz_bank | bank_id |
| PATCH | /settings | update_live_quiz_settings | At least one live setting (below) |
| GET | /banks | view_quiz_banks | None |
| GET | /questions | view_quiz_banks | None |
| GET | /banks/{bank}/questions | view_quiz_banks | None |
| PATCH | /banks/{bank}/status | update_quiz_bank_status | status: active, draft or archived |
| POST | /banks | manage_quiz_banks | name, optional order; creates a draft bank (201) |
| PATCH | /banks/{bank} | manage_quiz_banks | name and/or order |
| DELETE | /banks/{bank} | manage_quiz_banks | Deletes the bank and its questions (204) |
| POST | /banks/{bank}/questions | manage_quiz_questions | Question fields; added at the end of the bank (201) |
| POST | /banks/{bank}/questions/reorder | manage_quiz_questions | question_ids: every question in the bank, once |
| PATCH | /banks/{bank}/questions/{question} | manage_quiz_questions | Question fields to change |
| DELETE | /banks/{bank}/questions/{question} | manage_quiz_questions | 204 |
Sending and closing questions
POST /questions/send takes question_ids, or bank_id alone to send every question in that bank in display order. A bank with no questions is refused (422 under bank_id). When both are sent, every question must be in that bank (422 under question_ids), since the bank becomes the live bank. duration sets the window length in seconds (5–3600) for this send; without it the quiz's default question duration applies. max_selections (1–1000) limits how many options an attendee may pick on multiple choice questions in this round; see Limit the picks. ignore_keys, which decides which state keys attendees don't receive, can only be set from the dashboard; an app that sends it gets 422.
When the quiz does not allow multiple live questions, a send closes the questions already live and moves their windows to closed_question_windows. When it does, the new windows are added beside the live ones.
POST /questions/unsend closes the listed questions early. Their windows get closed_at and move to the closed history. Because the analytics broadcast is throttled, an unsend also broadcasts each closed question's final counts on the analytics channels.
A window has an end_at. After that time the platform refuses answers to the question, but nothing closes the window or broadcasts when the time passes: the stored window stays active until the app unsends the question, sends another one (when only one question may be live), or closes the session. Close questions explicitly when the countdown ends if the panel needs the final counts broadcast or the round recorded as closed.
Sessions
POST /live/open starts a session in waiting status. It ends any session already open first. When the quiz is linked to a game, it also creates a game session. Optional bank_id and question_ids set the session's question sequence; IDs must belong to this quiz.
POST /live/close ends the session and live mode but keeps the window history: windows still live move to closed_question_windows, so a round's counts can still be read afterwards. POST /live/reset ends the session and wipes all live state, including the window history. Both leave keys the quiz does not own alone.
POST /session/reopen reopens one of this quiz's earlier sessions by session_id, ending any other open session.
Starting review and showing the leaderboard need an open session. Ending review and hiding the leaderboard are no-ops when no session is open. POST /review/start reveals the question's answers to attendees, with the analytics and explanation unless those flags are false.
Live settings
PATCH /settings changes only these settings, and needs at least one:
| Setting | Values |
|---|---|
default_question_duration | Integer, 5–3600 seconds |
live_multi_question_allowed | Boolean |
late_join_policy | current_question, wait_for_next, no_late_join |
timeout_behavior | skip, wrong |
Use the non-null values in the table; do not use null to reset a setting. The request validator permits some nullable combinations, but downstream getters do not consistently support them. The REST schema documents this recommended non-null input subset.
It returns the same body as GET /state. Note that GET /state reports the multi-question setting as settings.multi_question_allowed.
Banks and questions
POST /banks/active makes a bank the open session's bank and, in single-bank mode, the quiz's active bank. It does not change the bank's status. PATCH /banks/{bank}/status with active in single-bank mode is refused while another bank is active.
Banks that attendees are answering cannot be edited. Renaming, reordering or deleting a bank, and adding, changing, reordering or deleting its questions, return 422 under bank when the bank:
- has the status
active(a bank with no stored status counts as active), - is the live bank,
- is the quiz's active bank in single-bank mode, or
- holds a question that is live now.
If the bank is live, close the live session first (POST /live/close clears its live-bank state); simply unsending its questions may leave live_bank_id set. Deactivating a live bank is itself refused with 422 under status. Then set the bank to draft and edit it. In single-bank mode, deactivating the active bank clears its active-bank selection. Quizzes edited in the layout builder can't have their banks edited through this API (422 under form). Deleting a question that is delete-locked returns 422.
Question fields are label, question_type, options (each with label and value), correct_answers, case_sensitive, points_correct (0–1000), points_incorrect (−1000–0), time_limit (1–3600), is_active, feedback_correct, feedback_incorrect, answer_explanations, plus the fields of the question type. label and question_type are required on create.
The question listings return each question's ID, element_id (its slug), bank, label, type, order, points and time limit, options_source and max_selections (null when unset), and the options attendees see.
IDs from another quiz
Question, bank and session IDs in a request body must belong to this quiz; otherwise the request gets 422 (Every question must belong to this quiz., That bank does not belong to this quiz., That session does not belong to this quiz.). A {bank} or {question} path segment that is not in this quiz gets 404.
Responses
The control endpoints return the quiz's live state:
{
"success": true,
"live_state": {
"live_mode": "active",
"live_bank_id": null,
"live_question_ids": [311],
"mode": "single",
"question_windows": [
{
"question_id": 311,
"bank_id": null,
"start_at": "2026-10-28T15:00:00.000000Z",
"end_at": "2026-10-28T15:00:30.000000Z",
"duration_seconds": 30,
"status": "active",
"closed_at": null,
"initiated_by": null,
"max_selections": 2
}
],
"closed_question_windows": [],
"questions": [
{
"id": 311,
"label": "Which songs should play next?",
"slug": "which_songs_should_play_next_3f9a1c2e",
"is_required": false,
"quiz_question_type": "multiple_choice",
"max_selections": 3,
"options": [
{ "label": "Blue Monday", "value": "1201", "secondary": "New Order" },
{ "label": "Heroes", "value": "1202", "secondary": "David Bowie" }
],
"points": 10
}
],
"late_join_policy": "current_question",
"ignore_keys": ["updated_by", "initiated_by", "admin_analytics", "closed_question_windows"],
"updated_at": "2026-10-28T15:00:00.000000Z",
"session_id": 9,
"session_uuid": "1f0c2b8e-3a6d-4d1e-9a51-0c7d2c1b6a10",
"session_status": "question_active",
"review_question_id": null,
"review_data": null,
"leaderboard_visible": false,
"leaderboard_data": null
}
}
The values are synthetic and the question entry is shortened. questions holds each live question as attendees receive it: ID, field type, label, slug, quiz_question_type, max_selections when the question has one, options without correctness markers, points and an optional hint. Here the question allows three picks and the window limits this round to two. initiated_by and updated_by are null when an app made the change; they hold the admin's ID when the dashboard did. A window carries max_selections only when the send set one.
session_status is one of no_session, waiting, question_active, review, leaderboard or ended. POST /live/open and POST /session/reopen also return session, with its ID, UUID, status, game session, current question and bank, question sequence, review question, start and end times, participant count and total points.
GET /state returns form_id (the quiz's numeric ID, which names its channels), live_state and settings (live_mode_enabled, multi_question_allowed, default_question_duration, late_join_policy, ignore_keys).
GET /analytics returns counts for each live question. With question_id it returns that question's latest window instead, live or closed, so a round's final counts can be read after it is locked:
{
"analytics": [
{
"question_id": 311,
"question_label": "Which songs should play next?",
"total_responses": 3,
"correct_responses": 0,
"answer_distribution": { "1201": 2, "1202": 2, "1207": 1 },
"window": { "question_id": 311, "status": "closed" }
}
],
"total_responses": 3
}
The window is abbreviated here. Counts cover answers recorded from the window's start until it closed, or until its end_at while it is still live. GET /session/analytics instead counts the answers linked to the open session, keyed by question, and adds average_points.
Realtime channels
Attendee pages and control panels get different channels. A control panel needs the full state, which includes the closed window history and keys hidden from attendees, and the analytics, which a broadcast can't filter per subscriber.
| Channel | Event | Who may listen | Payload |
|---|---|---|---|
portal.forms.{formId}.live | trigger_state.changed | App pages bound to the quiz with view_live_quiz_state or any control ability | form_id, trigger_state (full), event_type, updated_at |
portal.forms.{formId}.live.analytics | analytics.updated | App pages bound to the quiz with view_live_quiz_analytics | form_id, question_id, total_responses, correct_responses, answer_distribution, updated_at |
portal.forms.{formId} | ProjectPageStateChanged | Attendee-facing pages; see Trigger State API | project_page_id (the form ID), changes, updated_at |
dashboard.project.{projectSlug}.quiz.{formSlug}.admin | trigger_state.changed, analytics.updated | Dashboard admins with view_live_quiz_state or any control ability | As the two app channels |
Channel names here are the logical names; the transport adds its private-channel prefix. Channel authorization also checks the app page's group gate and the abilities an admin dropped from the install.
event_type is one of live.state.updated, live.waiting, live.review.started, live.review.ended, live.leaderboard.shown, live.leaderboard.hidden, live.session.ended or live.reset. trigger_state is the whole stored state, including closed_question_windows, ignore_keys and any keys other apps wrote. The analytics event fires at most about once a second per question while answers arrive, with a trailing broadcast so the last answers before a close are not dropped, and once more for each question an unsend closes.
Subscribe from an app
Use the store's connectLiveQuizChannel(formId). formId is the quiz's numeric ID, which GET /state returns as form_id; the channels are named by ID while the endpoints take the slug.
import { onMounted, onUnmounted } from "vue"
let disposed = false
let stopState = () => {}
let stopCounts = () => {}
onMounted(async () => {
// Run after the portal store has initialized its Echo connection.
try {
const { form_id: quizId } = await store.apiGet(`${manage}/state`)
if (disposed) return
const live = store.connectLiveQuizChannel(quizId)
if (!live) throw new Error("Quiz connection is not ready")
stopState = live.onState((event) => {
// event.trigger_state is the full live state; event.event_type names the change.
})
stopCounts = live.onAnalytics((event) => {
// event.question_id, event.total_responses, event.answer_distribution
})
} catch {
stopState()
stopCounts()
if (!disposed) showConnectionError() // Your UI: retry after initialization.
}
})
onUnmounted(() => {
disposed = true
stopState()
stopCounts()
})
The snippet assumes your component supplies store, manage and showConnectionError. Initialize the portal store first; connectLiveQuizChannel uses window.Echo directly and does not wait for it. The disposed guard prevents a late state response from registering listeners after unmount. manage is the management path built in the example host flow. The helper returns { onState, onAnalytics, leave }:
onState(callback)listens fortrigger_state.changedonportal.forms.{formId}.live.onAnalytics(callback)listens foranalytics.updatedonportal.forms.{formId}.live.analytics.- Each returns a function that removes that callback and keeps the subscription.
- Each channel is joined on its first listener, so an app without
view_live_quiz_analyticsthat never callsonAnalyticsnever asks for the analytics channel. leave(), orstore.leaveLiveQuizChannel(formId), leaves both channels.
The store keeps one helper per quiz ID and returns the same one to every caller on the page, so leave affects every listener on that quiz. Use the returned cleanup functions for a single component, and leave only when the page is done with the quiz. The helper joins with the page key, like the store's other channels. When the app may not listen to a channel, its authorization request is refused and the callbacks never fire; the helper does not report the refusal, so check the channel authorization request in the browser's network log.
Under gxdev dev with API_ENV=mock, toolkit 2.1.47 provides an adapter over its single relay socket and stateful mocks of selected management endpoints. The local helper can return null before the primary relay initializes. Use the local fixture and six-request workflow to exercise it. Mock channels do not enforce production abilities or isolation; bank/question editing is not a complete simulation of the platform.
Events are notifications, not a replay log. After a reconnect, call GET /state and GET /analytics again rather than assuming nothing was missed.
Multiple choice options from a collection
A multiple choice question can take its options from a collection instead of storing its own. Set options_source in the question's quiz settings, from the Quiz Builder or with the question fields on POST /banks/{bank}/questions and PATCH /banks/{bank}/questions/{question}:
{
"label": "Which songs should play next?",
"question_type": "multiple_choice",
"options_source": {
"collection_id": 58,
"label_field": "title",
"secondary_field": "artist"
},
"max_selections": 3
}
- The collection must be in the quiz's project, and
label_field(andsecondary_field, when given) must be fields the collection defines. Otherwise the save gets 422 underoptions_source.collection_id,options_source.label_fieldoroptions_source.secondary_field. - Each entry becomes one option. Its
valueis the entry ID as a string. Itslabelis the entry's label field, orEntry #<id>when that field is empty; list values are joined with commas. With asecondary_field, each option also hassecondary. - Every entry that has not been deleted is an option, whatever its status. Options are sorted by label, ignoring case and comparing numbers naturally.
- Collection-sourced options have only
label,valueandsecondary; noorderoricon. - Correct answers, when the question has any, are entry IDs. Store them as strings, as the option values are.
- The option list is cached and refreshed when the collection's entries change.
Attendees receive the options wherever the question's options appear: in the live state's questions, in the quiz questions API and in the management question listings. Because the live state carries every option, a large collection can push the sent questions past the 8,192-byte limit on the live question payload; the send is then refused with 422 under question_ids.
Only the multiple_choice question type takes options_source and max_selections.
Limit the picks
max_selections on the question limits how many options an attendee may pick. max_selections on POST /questions/send overrides it for that round only: it is stored on the question window, not on the question. While live mode is on, the platform uses the live window's limit when it has one, and the question's otherwise.
Answer checks
For multiple choice questions, the answer endpoint refuses:
| Answer | Response |
|---|---|
| A value that isn't one of a collection-sourced question's options | 422, That answer is not one of the options. |
| More picks than the limit allows | 422, Pick one option. or Pick at most <n> options. |
The body is { "success": false, "error": "<message>" }, and the message is safe to show the attendee. Repeated picks of the same option count once. Answers to collection-sourced questions are stored as the unique entry IDs. Values outside a question's own (non-collection) options are not checked against the option list.
Per-option tallies
For multiple choice questions, answer_distribution counts each option once for every response that picked it. total_responses counts responses, not picks. A share computed as count / total_responses is the share of respondents who picked that option, so the shares can add up to more than 100%. In the example above, three responses picked five options: 67%, 67% and 33%. The dashboard's Live Control analytics show the same shares and label collection options with the entry's label.
Other list answers, such as an ordering, still count as one combination per response, keyed by their comma-joined values.
Example host flow
This sketch runs one round with the live_quiz_host preset. It assumes the app binds quiz to the quiz's slug, and leaves out error handling and the countdown display.
import { useGxpStore } from "@/stores/gxpPortalConfigStore"
const store = useGxpStore()
const [team, project] = store.pluginVars.projectId.split("/")
const quizSlug = store.findDependency("quiz")
const manage = `/api/v1/projects/${team}/${project}/quiz/${quizSlug}/manage`
async function openSession() {
const { session } = await store.apiPost(`${manage}/live/open`, {})
return session
}
async function sendQuestion(questionId) {
const { live_state } = await store.apiPost(`${manage}/questions/send`, {
question_ids: [questionId],
duration: 30,
max_selections: 2,
})
return live_state.question_windows.find((window) => window.question_id === questionId)
}
async function readCounts(questionId) {
const { analytics } = await store.apiGet(`${manage}/analytics`, { question_id: questionId })
return analytics[0] ?? null
}
async function closeQuestion(questionId) {
await store.apiPost(`${manage}/questions/unsend`, { question_ids: [questionId] })
}
async function closeSession() {
await store.apiPost(`${manage}/live/close`, {})
}
Call closeQuestion when the window's end_at passes or the host locks the round, then readCounts for the final counts (or wait for the analytics.updated event the unsend triggers). Between rounds, POST /review/start and the leaderboard endpoints work the same way.
findDependency returns the stored binding. It is the slug when the quiz was bound with the dashboard's form picker; a tag or * binding does not name one quiz, so the panel needs the slug from elsewhere. apiGet, apiPost and apiPatch take the full path. Their errors carry only a message, not the HTTP status or the response body. When the deployed REST catalog lists these operations, callApi reports the status as error.status.
Errors
| Status | Cause |
|---|---|
| 401 | No valid page key, or the page requires a signed-in attendee |
| 403 | The app's dependency lacks the ability, an admin dropped it from the install, or a whole-bank send lacks set_active_quiz_bank |
| 404 | The slug is not a quiz in this project, the app does not bind it, the request has no app page context, the bank or question is not in the quiz, or GET /session/analytics with no open session |
| 422 | Validation errors; live mode off (live_mode); IDs from another quiz; a locked bank (bank); a layout-builder quiz (form); a second active bank in single-bank mode (status); starting review or showing the leaderboard without an open session; sent questions over 8,192 bytes (question_ids); ignore_keys sent by an app |
422 responses use the framework's validation shape, with messages under errors.<field>.
Not available yet
- There is no next or previous endpoint. Send the next question's ID.
- Question windows do not close themselves on the server when
end_atpasses; close them as described in Sending and closing questions. - A dependency can't limit an app to some of the quiz's banks. An app bound to the quiz reaches all of its banks.
Related
- Trigger State API for app state outside the live quiz keys. The live quiz keys can only be changed through the endpoints above.
- Real-time Events for the store's socket helpers.
- Quiz System Architecture for the platform-side model.
- Permissions and Dependencies for bindings and per-install rules.