Wednesday, September 21, 2005

Iowa Gambling Task

Eric-Jan and his undergraduate Mirre Stallen decided to collect responses from a biggg group of subjects on the Iowa Gambling task. Together with Eric-Jan I implemented an internet version of this task. It should work with both MSIE and Firefox (I didn't test other browsers). You can find it here. Although it is in Dutch I have added some approximate English translation when you mouseover the text. I would appreciate it if you would seriously do the task for me until the end, so that I can gather some data for comparisson with the subject pool. If you would like to hack the code for your own purposes, you can dowload this zip file which contains all the files used. The code is not the neatest possible, but sufficiently readable I think.

Added June 25th, 2006
Please read this post to learn how to save the data.

Added January 14th, 2007
The zip file now bundles both the task and the code to save data to file. Now there is a web version (.html file) and a desktop version (.hta file) which runs after unzipping the complete directory. Both are English versions. The saved data format is compatible with the included data extraction tool. Please see the Readme.txt file for instructions. The desktop version also has more graphical feedback (see screenshot below).

Added April 30th, 2007
Note that after you downloaded the zip file, you really must unzip the file! In Windows XP this is easiest if you double click the downloaded file, and click the 'Extract all files' at the top of the left panel. If you don't see images when you start the hta version, then you most likely have not unzipped the zip file.

Preventing a participant (or user) from accidentally leaving a page or closing a window prematurely

When using DHTML for behavioral experiments, one thing you certainly wish not to be possible, is that before the experiment is finished and the data were saved or submitted, your subjects can accidentally close the window (by clicking on the window close button, or pressing Ctrl-W, or even pressing Alt-F4), or unload the page in any other way (e.g., pressing the reload button or pressing F5). To prevent such accidents you can use an onbeforesubmit event handler. (Fortunately it is not possible to prevent such actions that are carried out deliberately.) The simplest is to copy and paste the code below and put it in your HTML page:
<script>
window.onbeforeunload = confirmExit;
function confirmExit()
{
   // you might consider conditionalizing 
   // this return statement
   return "You haven't finished yet!" +
          " Please press 'Cancel' to continue.";
}
</script>
This works in MSIE 5.1 and higher, and in Firefox 0.9 and higher.

Monday, September 19, 2005

Opening your HTML page in full screen mode

How to start your DHTML page in 'theatermode' (or 'channelmode' or 'full screen' mode, whatever...)

If you are using DHTML for psychological experiments, you would often like to get rid of the window border and have the entire display covered by a background. This was possible in MS Internet Explorer if you would open a popup window with one of the parameters set to channelmode (see the example here, which will open such a window if you click the button), or by resizing and repositioning the window such that the window borders would fall of the screen. For security reasons (phishing, and the like) this has changed in recent updates of MSIE. Now, you cannot get rid of the window if the document is loaded over an http connection. It is still possible to have the screen entirely occupied by you HTML-page if you load it from the hard disk (e.g., when you use MSIE as a substitute for behavioral research software and don't want to spend ridiculous amounts of public funding money on products such as E-prime). The secret is in the launch flags of MSIE that hardly anyone knows about: If you click Start &rightarrow; Run and type “iexplore.exe -k” followed by the full address of your file (i.e., 'iexplore.exe -k “c:\Documents and settings\John Doe\Desktop\myExperiment.html”') , then MSIE will launch in theater mode with the indicated file opened. You can close the window with Alt-F4.

This is probably not the most convenient way to start your experiment each time with a new participant is tested. Instead, you can place a shortcut on the desktop: First right click the HTML file that implements your experiment, choose 'Send to desktop (creates shortcut)'. Then, on the desktop right click the freshly created shortcut and choose 'Properties'. A tabbed window opens, choose the tab 'Shortcut'. In the target field, you'll find the name and path of you HTML file. Put the cursor in front of and type the full path and name of the internet explorer executable in quotes (something like '"C:\Program Files\Internet Explorer\iexplore.exe"', followed by '-k' and a whitespace (see the image below). Click 'OK'; you're done. You'll notice that the icon of your shortcut has changed spontaneously to the icon you'd expect for a shortcut to MSIE itself. If you double click the shortcut your experiment starts automatically in full screen mode.