The scripts below were written by William Schmidt to support use of factorWiz and surveyWiz. The first script below can be used to replace the script referenced by the Action statement in factorWiz and surveyWiz. It will send its output to a datafile named after the value of the "00exp" variable, which is the Short Name that is also placed in the file as the first variable. The second script provides random assignment of participants to different conditions.PERL script for coding and saving data
A couple of issues: 1. Unlike the PolyForm script which places the data in a file named data.csv, available via FTP, this script will place the data on your local server in a file named after the first variable, 00exp, with an extension of .data. 2. This script adds a final column to the data output called "complete". Each data record should end with "complete" in the last position. It does NOT, however, indicate that all responses are complete. Missing values appear as "" in the data file. How to use: 1. Ensure that you have perl installed. If you install perl5_004 or later then all is set; if you install an earlier version, then you need also get the CGI.pm perl module and install it as well... http://stein.cshl.org/WWW/software/CGI/cgi_docs.html If you have installed a recent distribution of the Apache Web server that includes Perl, you are all set. Here is a link to Apache. 2. Edit the script by replacing: i) the path to your operative perl executable in line 1 ii) the URL to redirect users after accepting data in line 2 (optional) iii) the path to the directory where your data files are to be stored in line 3; note the trailing slash after the directory name. Windows users may change this to read: $path_to_datafile = "C:/"; in which case, the data should appear at the root of the C drive. Windows 95/98/NT and OS/2 users will have to use backslashes (\) as separators in paths; MacOS 9 users need colons (:) as separators. Users of Mac OS X, can use / as separators. For more information on the Apache Server on Mac OS X, click here. 3. Place the script in the cgi-bin directory of your web server; check that it is executable by your web server (i.e., for UNIX users: chmod ugo+rx accept.pl). Test the script out by calling the URL directly -- If it is set up properly, your browser should be redirected to the URL supplied in line 2 when you enter the URL of the script. William C. Schmidt Dept. of Psychology Park Hall SUNY at Buffalo Buffalo, NY http://or.psychology.dal.ca/~wcs ---------------------------PERL script below (warning: before you copy it, please save this script as Unix text only). Text File of save_data.txt ------------------------------------------------------------------------ #!/usr/bin/perl $redirect_to = "http://psych.fullerton.edu/mbirnbaum/decisions/thanks.htm"; $path_to_datafile = "/export/home/wcs/public_html/"; use CGI; $query = new CGI; #timestamp the submission ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon++; #determine the data filename, open and dump data $filename = $query->param('00exp'); open(INFO, ">>$path_to_datafile/$filename.data"); foreach $key (sort($query->param)) { $value = $query->param($key); #filter out "'s and ,'s $value =~ s/\"/\'/g; $value =~ s/,/ /g; if ($value !~ /^pf/) { print INFO "\"$value\", "; } else { # filter out items that need to be expanded at submission time pf* if ($value =~ /^pfDate/) { print INFO "\"$mon/$mday/$year\", "; } if ($value =~ /^pfTime/) { print INFO "\"$hour:$min:$sec\", "; } if ($value =~ /^pfRemote/) { print INFO "\"",$query->remote_addr(),"\", "; } if ($value =~ /^pfReferer/) { print INFO "\"",$query->referer(),"\", "; } } #print "$key:$value"; } print INFO "\"complete\"\n"; close (INFO); print $query->redirect($redirect_to); exit(); ------------------------------------------------end of scriptPERL script for random assignment to conditions
Here's a perl script you can use to randomly assign participants to different conditions, including different random orders created in factorWiz. The experimenter makes a number of experimental pages and saves each one in a separate HTML file. The format of the name is pagename followed by an integer, followed by .html (e.g., form1.html, form2.html, form3.html ...). Enter the number of unique forms as the value of the $numforms variable on line 4 (e.g., 20). The root of the page names goes in line 3, and the URL of the directory where these pages are stored appears in line 2. As before, line 1 is the path to the PERL executable on the server. When the script is called it randomly redirects the user to one of the form pages. Try it at: http://or.psychology.dal.ca/cgi-bin/cgiwrap/~wcs/assign.pl You will see files not found messages, but note that repeated clicks of the link call for different addresses. -------------------- PERL script follows: #!/usr/bin/perl $redirect_to = "http://or.psychology.dal.ca/~wcs"; $root = "pagename"; $numforms = 20; use CGI; $query = new CGI; srand; $page = (rand $numforms)+1; $page =~ s/\.(\d+)$//g; print $query->redirect("$redirect_to/$root$page.html"); exit(); ---------------------------end of script