Sending Quiz Results to Server

If you are using the newer version of QuizMaker, check out the article for the 7-th version.

In this article we’ll describe how to configure a quiz to send results to a server and how to write a server-side script to collect the sent values.

Troy Roberts

iSpring has allowed me to create expensive looking training material and tests for a minimal cost.

Check out iSpring Presenter

Prerequisites

  • You must have permissions to create a script on your server and to access your database. Or you may address your system administrator for help.
  • You must have a working knowledge of some server-side programming language, for example, PHP or any other language.

Quiz Settings

First of all, you should configure your quiz to send results to a server.

  1. 1Open your quiz or create a new one.
  2. 2Click the Settings button on the QuizMaker toolbar.
  3. 3Open the Result tab.
  4. 4Select the Send quiz result to server checkbox.
    Send Quiz Result to Server
  5. 5Specify the web address of the script that will process quiz results.
    The script itself will be described below.
  6. 6Publish your quiz.

Now your quiz will send results to your server script.

PHP Script

The next step is to write a script that will process quiz results and deploy it on your server at the address you specified in the quiz settings.

Quizzes generated with iSpring QuizMaker send results using the POST method. The table below contains all the POST variables that a quiz sends.

Variable Description
v QuizMaker version
dr Detailed results in .xml format complying with the schema below
sp Earned points
ps Passing score
psp Passing score in percent (the percentage of the total points the user must score to pass a quiz)
tp Gained score
sn Quiztaker's username
se Quiztaker's email address
qt Quiz title

Note: QuizMaker will send either ps or psp. This depends on the Passing Score option (Quiz Settings -> Main). If it’s specified in points, the program will send ps; if in percentage – psp.

In order to receive these variables, you need to write a script and deploy it on your server.

Here is a sample PHP script that receives the POST data and writes them to a file. This is just an example; you will certainly want to use a database to store the results. But this script does its job: it shows how to get the POST data sent from a quiz.

Let’s analyze this script.

These PHP lines collect the POST values sent from a quiz:

 $version = $_POST['v'];
 $points = $_POST['sp'];
 $passing_percent = $_POST['psp'];
 $gained_score = $_POST['tp'];
 $username = $_POST['sn'];
 $email = $_POST['se'];
 $quiz_title = $_POST['qt'];

$_POST is an associative array of variables passed to the current script via the HTTP POST method. So all you need is to address necessary variables (listed in the table above).

The second part of the script simply writes the obtained data to a text file (results.txt). This is just an example; a real script will most certainly work with a database to store results.

Detailed Report

What if you want to get detailed results? In this case you will need to use $_POST['dr']. This variable will return an xml file with detailed results.

Here is the XML schema that describes the structure of this XML document.

$detailed_results_xml = $_POST['dr'];

Then you will just parse the xml file.

I answered some questions from the US Country Study quiz and got the following xml report.

For example, the multiple response question about Yellowstone National Park:

This question in QuizMaker

This question in Quiz Review

Here is the xml output from the detailed results:

  
 <quiz>
  ...
     <questions>
     ...
         <multipleResponseQuestion awardedPoints="10"
                 usedAttempts="1"
                 status="correct"
                 maxPoints="10"
                 maxAttempts="1">
             <direction>Yellowstone, the oldest American national park,
                 is located in three of the following states
                 (Tick the names of three states):
             </direction>
             <answers>
                 <answer selected="true" correct="true">Wyoming</answer>
                 <answer selected="false" correct="false">Indiana</answer>
                 <answer selected="true" correct="true">Idaho</answer>
                 <answer selected="true" correct="true">Montana</answer>
             </answers>
         </multipleResponseQuestion>
     ...
     </questions>
 </quiz>
 

The question type is Multiple Response. The attributes of the element provide the summary of the given question: the number of used attempts, the maximum number of attempts allowed, the question status (correct or incorrect), the maximum points a user can get for the correct answer and the actual points awarded.

In our case the user answered this question correctly (status="correct") using only one attempt (usedAttempts="1") out of one (maxAttempts="1") and got 10 points for it (awardedPoints="10") out of 10 (maxPoints="10").

The detailed information about the user’s answer is described by the element. As you can see, the user selected all the correct options (Wyoming, Idaho, and Montana) and left the wrong option (Indiana) unselected.

Let’s take just the answer “Wyoming” as our example.

The user selected Wyoming (selected="true"), which was a correct answer (correct="true").

Note that the xml representation differs for different question types. So you should look up the xml schema for details.