Quiz

Quiz List

GET ‎https://<domain>/<api prefix>/<version>/quiz/list/

This API endpoint will return a list of the available quiz.

Query Parameters

Name
Type
Description

limit

string

offset

string

name

string

Quiz name

Headers

Name
Type
Description

apikey*

string

Apikey

Authorization*

string

Bearer access token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "slug": "<quiz_slug>",
                "name": "<quiz_name>",
                "question_count": <question_count>,
                "description": "<description>",
                "quiz_details": {
                    "name": "<name>",
                    "maximum_questions": <maximum_questions>,
                    "quiz_duration": "<quiz_duration>",
                    "total_score": <total_score>,
                    "badge": "<badge>",
                    "description": "<description>",
                    "rules": "<rules>"
                }
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/quiz/list/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Quiz Summary List

GET ‎https://<domain>/<api prefix>/<version>/quiz/list/results/

This API endpoint will return a list of quiz summary list with details.

Query Parameters

Name
Type
Description

name

string

Quiz name

offset

string

limit

string

Headers

Name
Type
Description

apikey*

string

Apikey

Authorization*

string

Bearer access token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "score": <score>,
                "total_score": <total_score>,
                "reward": <reward>,
                "last_attempt": "<last_attempt>",
                "attempts": <attempts>,
                "name": "<name>",
                "status": "<status>",
                "badge": {
                    "name": "<badg-name>",
                    "image": "<image>",
                    "slug": "<slug>"
                },
                "related_courses": [
                    {
                        "id": <id>,
                        "slug": "<slug>",
                        "title": "<title>",
                        "thumbnail": "<thumbnail>",
                        "short_description": "<short_description>",
                        "long_description": "<long_description>",
                        "detail_url": "<detail_url>",
                        "authors": [
                            {
                                "name": "<author_name>"
                            }
                        ],
                        "duration": "<duration>",
                        "progress": <progress>,
                        "skills": [
                            "<skills>"
                        ],
                        "price": <price>,
                        "converted_price": "<converted_price>",
                        "course_type": "<course_type>",
                        "total_reviews": "<total_reviews>"
                    },
                    ...
                ]
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/list/results/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/quiz/list/results/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Start Quiz

GET ‎https://<domain>/<api prefix>/<version>/quiz/start/

This API endpoint will start a quiz and return all the questions and options of the quiz.

Query Parameters

Name
Type
Description

slug*

string

Quiz slug

Headers

Name
Type
Description

apikey*

string

Apikey

Authorization*

string

Bearer access token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "questions": [
            {
                "id": <question_id>,
                "number": <question_number>,
                "question": "<question>",
                "score": <score>,
                "duration": "<duration>",
                "options": [
                    {
                        "number": <option_number>,
                        "question": <question_id>,
                        "option": "<option>",
                        "answer": <is_option>
                    },
                    ...
                ]
            },
            ...
        ]
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/start/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/quiz/start/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

FIeld

Description

400

Validation Error

slug

Requested quiz not found.

This field is required and it may not be blank.

Submit Answer

POST ‎https://<domain>/<api prefix>/<version>/quiz/submit/answer/

This API endpoint will submit answer options of all quiz questions and end the quiz.

Headers

Name
Type
Description

apikey*

string

Apikey

Authorization*

string

Bearer access token

Request Body

Name
Type
Description

slug*

string

Course Slug

options*

String

Options - an array of selected options of each question, the selected option must contain following key as per the following structure,

{ "id": <option_id>, "number": <option_number>, "question": <questionid>, "option": "<option>", "answer": <falseortrue> }, if any question is skipped or time out just add an additional key "func" with any option of corresponding question, and set the value for "func":"skip" (if question is skipped) or "func":"time_out" (if question time out)

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/submit/answer/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',

  },
  body: JSON.stringify({"slug":"<course_slug>","options":[
  {"id":<option_id>,"number":<option_number>,"question":<question_number>,"option":"<option>","answer":<answer>},...
  ]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/quiz/submit/answer/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "slug": "<course_slug>",
    "options":[
        {
            "id": <option_id>,
            "number": <option_number>,
            "question": <question_number>,
            "option": "<option>",
            "answer": <answer>,
        },
        ...
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

FIeld

Description

400

Validation Error

slug

This field is required and it may not be blank.

Requested quiz not found.

Last updated

Was this helpful?