1. Instructions

1. Instructions for participants

In your folder C:\\xampp\\htdocs\\exp, you find the 21 files of the example experiment introduced in the kick-starter guide. Most of them code for the various screens shown to the participants’ of the experiment. Let us have a look at the code for the instructions page.

Open the file instructions.php in your editor. You will see a typical LIONESS script of about 90 lines of code, containing the information for displaying the instructions page to the participants. All scripts in this example program have the same basic set-up, and by going through this first script in some detail, we will see most of the basic elements of our programs. You will notice that each of the scripts of this example program contains extensive annotation to clarify the functioning of each of their parts in normal language.

The first 20 lines are written in PHP and are executed on the server; the rest of the code is mainly written in HTML, but we will get to that part later. In the PHP script we start by loading a library sql_library, which contains some handy functions to read from and write to the database (line 3). Next, we check whether the client is logged in to the server – by reading a cookie that has been written to the participant’s browser before – and read the needed parameters from the server, making them available for display. Finally, we update the variable onPage on the server, so that the experimenter can track the participant’s progress in the experiment via the control panel.

Most of the remaining code here is written in HTML. Scroll down to line 49 and find the line <body>. In this body section, you find the text that is displayed to the participants, including some basic formatting. At the very bottom, we have defined a button in an HTML form which calls a function to open a page called quiz.php in a pop-up window. The JavaScript function defined in the script’s <head> section ensures that this pop-up window is displayed without any navigation buttons. This is one way to lower the risk of participants going back and trying to revise their decisions.

Proceed to explore the code for the quiz page.