Using our API, you can capture quiz data on your website or web-server with ease.
Example Use Cases of Capture API
This feature requires minor programming at your end to accept the data sent by ProProfs. There are two ways you can capture data through API.
How it works
Whenever someone takes your quiz, your callback script will be called, which will accept the data. After accepting the data, you can write any custom code such as inserting into your database or CRM or triggering some business logic process.
Please follow the steps below to set up the callback URL:
Go to the Settings page and click on Advanced. Enable "Notification via API". Type the call back URL indicating where the script is on your site. This is the URL of the script which will accept the data in the REQUEST method. Select the "Query String/REQUEST" or "JSON" option from the drop-down menu.
This integration can be done either through the REQUEST method or the JSON method.
Examples for both have been given below. Both methods use the same variable and variable attributes. The variables have been given in the table.
# | Variable Name | Variable Description | Data Type | Example (PHP) |
---|---|---|---|---|
1 | result_id | A unique ID to identify an attempt | INT | $_REQUEST['result_id'] |
2 | status |
New: Refers to a new attempt. |
VARCHAR | $_REQUEST['status_id'] |
3 | quiz_id | A unique ID which will identify your quiz. | INT | $_REQUEST['quiz_id'] |
4 | quiz_title | A unique quiz title to identify your quiz. | VARCHAR | $_REQUEST['quiz_title'] |
5 | quiz_name | Name of your quiz. | VARCHAR | $_REQUEST['quiz_name'] |
6 | attempt_date | The date and time stamp of the attempt (UNIX TIMESTAMP) | TIMESTAMP | $_REQUEST['attempt_date'] |
7 | total_marks | Total number of marks you set for the quiz. Eg: 100. | VARCHAR | $_REQUEST['total_marks'] |
8 | user_obtained_marks | Total number of marks obtained by the quiz taker. | VARCHAR | $_REQUEST['user_obtained_marks'] |
9 | user_percent_marks | Percentage marks of quiz taker. | VARCHAR | $_REQUEST['user_percent_marks'] |
10 | user_totalcorrect_answers | Total number of correct answers by quiz taker. | INT | $_REQUEST['user_totalcorrect_answers'] |
11 | user_totalwrong_answers | Total number of wrong answers/anwer by the quiz taker. | INT | $_REQUEST['user_totalwrong_answer'] |
12 | user_Id | Quiz taker's ID | VARCHAR | $_REQUEST['user_Id'] |
13 | user_Email | Quiz taker's email address. | VARCHAR | $_REQUEST['user_Email'] |
14 | user_Address | Quiz taker's address | VARCHAR | $_REQUEST['user_Address'] |
15 | user_City | Quiz taker's city | VARCHAR | $_REQUEST['user_City'] |
16 | user_State | Quiz taker's state | VARCHAR | $_REQUEST['user_State'] |
17 | user_Zipcode | Quiz taker's zipcode | VARCHAR | $_REQUEST['user_Zipcode'] |
18 | user_Phone | Quiz taker's phone number | VARCHAR | $_REQUEST['user_Phone'] |
19 | user_name | Quiz taker's name | VARCHAR | $_REQUEST['user_name'] |
20 | min_pass_marks | Minimum passing marks | INT |
$_REQUEST['min_pass_marks'] |
To get started, you would need to make a file (your callback script) which will accept the data sent by the quiz through REQUEST method.
Example:
This example uses PHP & MySQL. Test this feature using PHP for server scripting.
Step 1: SQL: Create a table with the following SQL query:
Step 2: PHP: Given below is the sample code that you can use to code what data is retrieved.
Step 3: Download and implement the following PHP code to retrieve data.
Click here to download the PHP script (responsetest.php)
You can get JSON data by using the POST request. The sample code below shows how data can be retrieved. The POST request is enough to retrieve the data in the JSON method.
JSON gets two additional attributes and variables over the REQUEST method. With JSON, you can retrieve data for custom questions and tag-based scores.
Content-Type : application/json
//This code will retrieve the data
$post_json = file_get_contents("php://input");
$post_json = json_decode($post_json,true);
$result_id = $post_json['result_id'];
//This is how data will be retrieved
{
"result_id" : "206370034",
"user_name" : "ProProfs",
"total_marks" : "10",
"attempt_date" : 1559632348,
"user_obtained_marks" : 5,
"user_percent_marks" : "50",
"user_totalcorrect_answers" : 1,
"user_totalwrong_answers" : 1,
"user_Id" : "",
"user_Email" : "someone@example.com",
"user_Address" : "",
"user_City" : "",
"user_State" : "",
"user_Zipcode" : "",
"user_Phone" : "",
"quiz_id" : "2478348",
"quiz_name" : "API Test",
"quiz_title" : "mjq3odu5nqo7iv",
"min_pass_marks" : "70",
"tag_based_score" : [
{
"tag" : "Maths",
"score" : "5 / 5"
},
{
"tag" : "Physics",
"score" : "0 / 5"
}
],
"custom_ques_ans" : [
{
"question" : "How did you find us?",
"answer" : "Search Engine"
},
{
"question" : "How do you commute?",
"answer" : "Car"
}
],
"status" : "new"
}
Related Articles:
ProProfs REST API Guide
How To Auto-enroll Learners To Classroom Using API
How To Track Progress Of Learners In My Systems Using API