API DOCUMENTATION

table of contents

WEBHOOK - How to retrieve results using Webhooks?

Webhook is used to securely deliver the test results to your systems/website in real time.

Steps to be taken for creating webhook:

  • Download the file and add it to a publically accessible URL on your server.
  • Create a webhook in the Admin Panel.
  • Add your file URL in the URL option of webhook.
  • Select Save button, you will get a key.
  • Place that key in the webhook file with key_generated_in_webhook.
  • Add your code for saving data below the comment   //Save results in your database.
  • Now your webhook is active, and data will get save over your server.

Copy the code from below.

                    
<?php

// Notify you have received the Webhook.
http_response_code(200);

// You are given a unique key when creating a Webhook.
define('WEBHOOK_KEY''key_generated_in_webhook');

// Verification function.
function verify_webhook($header_hmac_signature) {
    return (
$header_hmac_signature == WEBHOOK_KEY);
}

// key against the webhook
$header_webhook_key $_SERVER['webhook_key'];

// JSON (The Test Results).
$json_string file_get_contents('php://input');

// Call verification function.
$verified verify_webhook($header_webhook_key);

// Add JSON  to array for referencing elements.
$array_data json_decode($json_stringtrue);

if (
$verified) {
    
// Save results in your database.
}

?>

Data return after using Webhook :

For example, JSON format for a Single Test result taken via a Link.

                    
{
    "ENROLLMENT_NO": "AABC",
    "EMAIL": "",
    "TEST_ID": "41",
    "RIGHT_QUE": "0",
    "WRONG": "3",
    "LEFT_QUE": "1",
    "TOTAL_MARKS": "0",
    "RANK": "0",
    "PERCENTILE": "0",
    "EXAM_DATE": "16-08-12",
    "CORRECT_MARKS": "",
    "LEFT_MARKS": "1",
    "NEGATIVE_MARKS": "0",
    "PRO_TIME": "0",
    "UNPRO_TIME": "9",
    "IDLE_TIME": "3",
    "TOTAL_TIME": "12"
}

Explaination of parameters in json.

Parameters Value
ENROLLMENT_NO unique identification can be any alphanumeric string under 100 characters long, this identification could be used to track, whether a user came from on your website to access your test
EMAIL email address of test taker
RIGHT_QUE count of correct questions attempted
WRONG count of incorrect questions attempted
LEFT_QUE count of non attempted questions
CORRECT_MARKS total correct marks obtained
NEGATIVE_MARKS total negative marks deducted
LEFT_MARKS total marks that could be obtained if attempted
TOTAL_MARKS total marks obtained
RANK position of test taker achieved in total test takers
PERCENTILE percentile among all test takers
EXAM_DATE date of test taken
PRO_TIME productive time taken by test taker
UNPRO_TIME unproductive time taken by test taker
IDLE_TIME idle time taken by test taker
TOTAL_TIME total time taken by test taker to complete the test

Checking webhook by sending Sample Data.

While applying webhook on your server, you need to test the script.

For testing, you can directly select Send Sample Data button on webhook page. It will hit your url with sample response string.

What will happen on real time test?

If webhook is active, for the particular test, than results will be sent to your Webhook URL.

If you need to save non-submitted results or need to do manual submission.

In case, if you need to submit the test results manually, you can do it by select Webhook Submission button in more options of particular test. Webhook submission will only work, if it is active for a particular test.

How to identify which data is sent or not?

  • When a Test is finished, Webhook attempt gets triggered.
  • For data send is a success or not, a webhook url status is kept.
  • If in case any data is not sent, you can identify it and send it manually.