Instances

Manage quiz instances. Create new instances, answer questions, and complete the quiz.

Endpoints


get/api/v3/quiz/instances

Return a paginated list of quiz/instances

Input Schema

object
page?:
object
The page number, default to 1
number?: integer
The number of items per page, default to 1000
size?: integer
The sort order, comma separated list of fields. See sorting section for more details
sort?: string
Set to true to return the total number of items in the collection
count?: boolean
filter?:
object
id?: unknown
person_id?: unknown
quiz_id?: unknown
session_id?: unknown
started_at?: unknown
ended_at?: unknown
status?: unknown
scores?: unknown
created_at?: unknown
session_id?: unknown
The related resources to include in the response. Allowed resources are:
- `quiz`
- `quiz.questions`
- `answers.question`
included?:
array
Elements: string
The fields to include in the response.
The key is the resource type and the value is an array of fields.
fields?:
dictionary
Values: array

Typescript

type InputSchema = {
  page?: {
    // The page number, default to 1
    number?: number;
    // The number of items per page, default to 1000
    size?: number;
  };
  // The sort order, comma separated list of fields. See sorting section for more details
  sort?: string;
  // Set to true to return the total number of items in the collection
  count?: boolean;
  filter?: {
    id?: any;
    person_id?: any;
    quiz_id?: any;
    session_id?: any;
    started_at?: any;
    ended_at?: any;
    status?: any;
    scores?: any;
    created_at?: any;
    session_id?: any;
  };
  // The related resources to include in the response. Allowed resources are:
  // - `quiz`
  // - `quiz.questions`
  // - `answers.question`
  included?: Array<string>;
  // The fields to include in the response.
  // The key is the resource type and the value is an array of fields.
  fields?: { [key: string]: Array<any> };
};

Output Schema

object
data:
array
Elements:
object
type: string
id?: string
attributes?:
object
id?: string
person_id?: integer
started_at?: datetime
ended_at?: datetime
status?: string
scores?: open struct
created_at?: datetime
relationships?: open struct
included?:
array
Elements: open struct

Typescript

type OutputSchema = {
  data: Array<{
    type: string;
    id?: string;
    attributes?: {
      id?: string;
      person_id?: number;
      started_at?: Date;
      ended_at?: Date;
      status?: string;
      scores?: Record<string, any>;
      created_at?: Date;
    };
    relationships?: Record<string, any>;
  }>;
  included?: Array<Record<string, any>>;
};


post/api/v3/quiz/instances

Create an instance of quiz linked to a quiz session.

Input Schema

object
data:
object
type: string
attributes:
object
quiz_id: integer
session_id: string
expires_at?: datetime

Typescript

type InputSchema = {
  data: {
    type: string;
    attributes: { quiz_id: number; session_id: string; expires_at?: Date };
  };
};


post/api/v3/quiz/instances/:instance_id

Start the quiz and set the timer at now

Input Schema

object
instance_id: string

Typescript

type InputSchema = { instance_id: string };


patch/api/v3/quiz/instances/:instance_id/:question_id

Give answer to a specific question. If the question is already answered, will update the answer.

Raise error if the session is not in progress or doesn’t exists.

Input Schema

object
The session id
instance_id: string
The question id
question_id: integer
data:
object
type: string
attributes:
object
The answer. Format of the parameters match the question type
answer: string or array or open struct

Typescript

type InputSchema = {
  // The session id
  instance_id: string;
  // The question id
  question_id: number;
  data: {
    type: string;
    attributes: {
      // The answer. Format of the parameters match the question type
      answer: string | Array<any> | Record<string, any>;
    };
  };
};


post/api/v3/quiz/instances/:instance_id/complete

Mark the quiz as completed.

Input Schema

object
instance_id: string

Typescript

type InputSchema = { instance_id: string };

Output Schema

object
data:
object
type: string
id?: string
attributes?:
object
id?: string
person_id?: integer
started_at?: datetime
ended_at?: datetime
status?: string
scores?: open struct
created_at?: datetime
relationships?: open struct
included?:
array
Elements: open struct

Typescript

type OutputSchema = {
  data: {
    type: string;
    id?: string;
    attributes?: {
      id?: string;
      person_id?: number;
      started_at?: Date;
      ended_at?: Date;
      status?: string;
      scores?: Record<string, any>;
      created_at?: Date;
    };
    relationships?: Record<string, any>;
  };
  included?: Array<Record<string, any>>;
};


post/api/v3/quiz/instances/:instance_id/update_answer_score

Update the score of an open question

Input Schema

object
instance_id: string
data:
object
attributes:
object
question_id: integer
score: number

Typescript

type InputSchema = {
  instance_id: string;
  data: { attributes: { question_id: number; score: number } };
};