2. Quiz to check understanding
Ensuring that participants understand the instructions is essential in many behavioural experiments. It is therefore often useful to add a quiz whose questions have to be answered correctly before a participant can proceed. Open the file quiz.php in your editor. You will see the same basic setup as the instructions file: first some lines of PHP code, followed by HTML.
Note that the correct answer for question 2 depends on the multiplication factor in the public goods game, as defined by the experimenter. The command on line 64 includes a PHP script to read the parameter multiplier from the server to calculate the correct answer. In case one of the two answers is wrong, the function confirm_form returns false, the form is not submitted, and the participant cannot proceed.
If both answers to the control questions are correct, we have verified that the participant has understood the instructions. The form is submitted to the server. Now scroll your way up to the PHP part of this code. In lines 25-30, we specify what happens in case of successful submission of the form: we tell the server that this participant has finished the quiz (quizOK in line 27), and let the participant proceed to a page called lobby.php; line 28 and 29.
We will get to the waiting pages later. Let us first have a look at the decision page.