Quiz

Quiz List

get
​

β€Žhttps://<domain>/<api prefix>/<version>/quiz/available/list/
This API endpoint will return a list of the available quiz.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Query Parameters
limit
optional
string
​
offset
optional
string
​
name
optional
string
Quiz name
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"results": [
{
"id": <quiz_id>,
"slug": "<quiz_slug>",
"name": "<quiz_name>",
"percentage": <percentage>,
"description": "<quiz_description>",
"course_id": <course_id>,
"module_id": <module_id>,
"created": "<created_date>",
"enable": <enable_status>,
"number_of_questions": <number_of_questions>,
"score": <score>,
"duration": "<duration_in_seconds>"
}
...
],
"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/available/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/available/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/summary/
This API endpoint will return a list of quiz summary list with data.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Query Parameters
name
optional
string
Quiz name
offset
optional
string
​
limit
optional
string
​
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"results": [
{
"id": <id>,
"status": "<status>",
"duration": "<available_time(seconds)>",
"created": "<first_attemt>",
"number_of_questions": <number_of_questions>,
"answered": <answered_questions>,
"correct": <correct_answered>,
"wrong": <wrong_answered>,
"time_taken": "<time_taken(seconds)>",
"score": <score>,
"percentage": <percentage>,
"pass_status": "<pass_status>",
"attempts": <number_of_attempts>,
"last_attempt": "<last_attempt>"
}
...
],
"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/summary/',
'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/summary/',
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 return a session for the quiz.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Query Parameters
slug
required
string
Quiz slug
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"session": <session_id>,
"question": <first_question_id>
}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/start/quiz/',
'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>/start/quiz/',
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

This field is required and it may not be blank.

Requested quiz not found.

No questions found on this quiz.

Get Question

get
​

β€Žhttps://<domain>/<api prefix>/<version>/quiz/get/question/
This API endpoint will return quiz question and options.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Query Parameters
session
required
string
Session id
question
required
string
Question id
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"Question": [
{
"id": <question_d>,
"order": <question_order>,
"question": "<question>",
"score": <score>,
"duration": "<duration(seconds)>",
"options": [
{
"id": <option_id>,
"order": <option_order>,
"option": "<option>"
},
...
]
},
...
]
}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/quiz/get/question/',
'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/get/question/',
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

session

This field is required and it may not be blank.

This must be an int value.

Your session is not found.

Your session time out.

400

Validation Error

question

This field is required and it may not be blank.

This must be an int value.

Question not found.

Submit Answer

post
​

β€Žhttps://<domain>/<api prefix>/<version>/quiz/submit/answer/
This API endpoint will submit an answer option of the question and return the next question id.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Body Parameters
session
required
string
Session id
question
required
string
Question id
answer
required
string
Answer - option id
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"progress": "<quiz_progress>",
"failed_question": [
<failed_questions_id>
],
"success_question": [
<success_question>
],
"end_time": <end_time>
}
}

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>',
},
formData: {
'session': '<session_id>',
'question': '<question_id>',
'answer': '<answer_option_id>'
}
};
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 => array('session' => '<session_id>','question' => '<question_id>','answer' => '<answer_id>'),
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

session

Your session is not found.

Your session time out.

This must be an int value.

This field is required and it may not be blank.

400

Validation Error

question

Question not found.

This must be an int value. This field is required and it may not be blank.

This question is already answered.

400

Validation Error

answer

This must be an int value.

This field is required and it may not be blank.

Answer not found.

End Quiz

post
​

β€Žhttps://<domain>/<api prefix>/<version>/quiz/stop/
This API endpoint will stop a quiz session.
Request
Response
Request
Headers
apikey
required
string
Apikey
Authorization
required
string
Bearer access token
Body Parameters
session
required
string
Session id
Response
200: OK
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>/stop/quiz/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>'
},
formData: {
'session': '<session_id>'
}
};
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>/stop/quiz/',
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 => array('session' => '<session_id>'),
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

session

Your session is not found.

This must be an int value.

This field is required and it may not be blank.