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.
- 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.
First of all, you should configure your quiz to send results to a server.
- 1Open your quiz or create a new one.
- 2Click the Settings button on the QuizMaker toolbar.
- 3Open the Result tab.
- 4Select the Send quiz result to server checkbox.
- 5Specify the web address of the script that will process quiz results.
The script itself will be described below.
- 6Publish your quiz.
Now your quiz will send results to your server 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.
||Detailed results in .xml format complying with the schema below
||Passing score in percent (the percentage of the total points the user must score to pass a quiz)
||Quiztaker's email address
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.
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:
Here is the xml output from the detailed results:
<direction>Yellowstone, the oldest American national park,
is located in three of the following states
(Tick the names of three states):
<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>
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.