Top Banner
Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley | APS 2005
22

Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Jan 20, 2016

Download

Documents

Clyde Nelson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Part 4Processing and saving data with CGI/Perl

Psychological Science on the Internet:Designing Web-Based Experiments From the Ground Up

R. Chris Fraley | APS 2005

Page 2: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Sending data to the server

• If you submit information from a form, there must be some place for that information to go.

• The <FORM> tag of an HTML web page specifies where the information should be sent.

Page 3: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Sending data to the server

• More often than not, the information is sent to the server that delivered the web page to the user in the first place.

• The information is processed by a program/ script.

Page 4: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Scripting languages

• There are a number of scripting languages available for processing Internet data

– Perl– PHP– C++– ASP

• We will focus on using Perl for processing CGI data.

Page 5: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

CGI/Perl

• CGI programs are what enables a dynamic experience for the web user.

• A CGI program might be used to do any of the following:

– Provide the user with feedback based on his or her responses

– Write data to a file– Read data from a file– Create scores based on information provided– Randomize things

Page 6: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

What we need from a script that will process our self-esteem data

• The first script upon which we will focus will be designed to do four things:

– 1. Read the data that has been submitted by the user.

– 2. Use that information to compute the person’s self-esteem score.

– 3. Provide that score to the user, along with the average score in the sample to date.

– 4. Save the data to a file that can be imported into SPSS or Excel.

Page 7: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

The code

• This is a lot for one script to do, so we’ll focus on one part at a time.

• You can view (and copy-and-paste) the “commented” Perl script at the following address:

• http://web-research-design.net/APS2005/files/self-esteem-savedata.pl

• Note: This is the code per se; not the output of the code when it is executed. To use the code, paste it into a blank file, save it with the *.pl extension and place it in the cgi-bin directory of your Netfirms account.

Page 8: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

The code

• [An extended discussion of what the various codes “do” for self-esteem-savedata.pl. Also, a discussion of how to customize the script for your own purposes.]

• The goal of this discussion is not to teach you what every piece of the code does. We don’t have time for that kind of detailed discussion. Instead, I want you to see what each section is designed to do so that you can modify it without too much work for your own purposes. Please see the Fraley (2004) book for more information on exactly how these Perl commands operate.

Page 9: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Transferring your Perl script to the web server

• Save your file with the *.pl extension. Example: myscript.pl

• Go to the Netfirms web page and login to your account.

• Go to the File Manager.• Click the “cgi-bin” folder to open your cgi-bin

directory (i.e., the directory where your Perl scripts will reside)

• Click the “upload” button.• Find myscript.pl on your computer using the

“browse” option.• Upload the file.

Page 10: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Importing your data into SPSS or Excel

• The combination of the HTML program (self-esteem.htm) and the CGi/Perl program which processes and saves the data (i.e., self-esteem-savedata.pl) allows you to collect data, provide feedback to users, and save the data to the web server.

• The next step is to extract the data file from the web server and import it into your favorite stats package.

Page 11: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

• The self-etseem-savedata.pl script saves the data in a text-file called data.txt, located in a folder called “data”

• The first step is to get that file on to your computer.

• To do so, go to the File Manager of your Netfirms account.

Page 12: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

• Open your “www” folder and then open your “data” folder.

• Check the file called “self-esteem.txt” and then click the “download” icon to the right of that row.

• Download the file to a convenient place (e.g., the desktop) on your computer.

Page 13: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Import instructions for SPSS (version 12.0.01)

• 1. Open SPSS• 2. File -> Open -> Data• 3. Under “files of type,” select “text (*.txt)”• 4. Find your file and select it. Click open.• 5. The “Text Import Wizard” will open. Follow

each step and go with all of the defaults until you get to step 4 of 6. At that point, make sure that only the checkbox labeled “commas” in checked.

• 6. Continue on and press the “finish” button after step 6.

Page 14: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Step 2

Page 15: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Step 3. Chose the “Text” option under “Files of type”

Page 16: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Step 5. The “text import wizard” Step 5. Make sure that only the “comma” option is checked.

Page 17: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

The imported file in SPSS. You can now label the variables in any way that you wish and/or

analyze your data.

Page 18: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Import instructions for Excel

• 1. Open Excel• 2. File -> Open• 3. Under “files of type” choose “text.”• 4. Find your file, select it, and press “open”.• 5. This will begin a “text import wizard.” Choose

the option that indicates that the data are in a “delimited” format.

• 6. In the next step of the wizard, make sure “comma” is the only delimiter option selected.

• 7. Press finish.

Page 19: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Step 2. Chose the “Text” option under “Files of type”

Page 20: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

Step 5. The “text import wizard”. Choose the delimited option.

Step 6. Choose only the comma option.

Page 21: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.

The imported file in Excel. You can now label the variables in any way that you wish and/or

analyze your data.

Page 22: Part 4 Processing and saving data with CGI/Perl Psychological Science on the Internet: Designing Web-Based Experiments From the Ground Up R. Chris Fraley.