Internet Research Methods in Psychology


Internet Research Methods in Psychology
Seminar - PSYC 593 CF
CRN: 48584
Fri 9:00 am - 11:50 am
Room: 219 A

Instructor

R. Chris Fraley, PhD
Department of Psychology, Room 409
E-mail, phone, and other information: http://www.psych.uiuc.edu/~rcfraley



Class web page

http://www.yourpersonality.net/P593/

Updates

Jan 17, 2011

Updates will be posted here throughout the semester.
Readings and Materials

There is not a formal book for this class. However, you will also need a professional web hosting account for this class. I use Netfirms hosting for everything I do and I encourage you to do the same so you can follow along with some of my "step by step" explanations. You can see Netfirm's hosting packages via this link. The most basic, paid packages range from $4 to $12 per month.

You will also need access to a decent text editor. The one I use for Windows is called EditPlus. I strongly recommend it. You can try a free trial version for 30 days. If you're a Mac user, you might like TextWrangler.

Overview of the Course

During the past decade and a half, an increasing number of psychologists have begun to use the Internet as a tool for conducting psychological research. It is easy to understand the appeal of using the Web for research purposes. Just about any study that can be conducted via traditional pencil-and-paper methods can be implemented on-line, but without the hassles of data entry by hand, the scheduling of participants, and paper costs. Moreover, researchers who use computers in their experiments for manipulating visual or narrative stimuli, randomizing trials, or creating customized assessments can easily implement their protocols on-line. Most importantly, although researchers can use the Web simply as an efficient way to collect data from undergraduates in their departmental subject pools, the Web allows us to open our laboratory doors to people from across the world.

My objective in this class is to teach you how to create web programs so that you can use the Internet as a medium for conducting psychological research. We will focus on CGI programming using PHP. CGI programs are designed to run on a web server, and, unlike standard HTML web pages, these programs can be used to create a dynamic, interactive web experience for the user. By using CGI programs, researchers can (a) randomize the presentation order of stimuli, (b) randomly assign subjects to conditions, (c) automatically save response data to a file for data analysis, (d) provide subjects with customized feedback based on their responses, (e) exploit both text and image-based stimuli, (f) measure reaction times, and (e) employ complex branching operations within a project.

Throughout the semester we will work our way through these and other topics, beginning with the basics (e.g., how to create a simple web page using HTML) and progressing through the more complex topics (e.g., how to write PHP scripts that create customized feedback to subjects). We will also discuss some conceptual and practical issues, such as those concerning ethics, sampling, data security, the quality of Internet data, and how to submit IRB's for web-based research. We will also cover MySQL databases, PHP-MySQL interplay, DOM manipulation, javaScript, and AJAX.

This class is intended for anyone who currently conducts research in the behavioral sciences. The seminar is designed to be a practical, skill-based one and, as such, will be of most use to students who actually want to use the Internet to collect data.

The Class Webpage

I will post lecture notes and other materials relevant to the class on the class web page. You should treat the class web page as your primary syllabus. I will be updating it on a regular basis and it will be your responsibility to keep up-to-date on any changes that are made. (I will, however, announce significant changes in the lecture sessions.)

Workload, Grading, and Expectations

I will introduce the basic concepts for the week in each class, walk you through some examples, and then provide you with exercises and challenges to help you improve your skills. You probably need to set aside 4 to 6 hours a week outside of class for practicing your programming skills.

You will be given mini-projects throughout the semester as a way of keeping you on track and to help you evaluate your strengths and weaknesses. From a grading perspective, one of the nice things about web design is that a program either works or it does not and, more importantly, it is quite clear when the program is working well. As such, these projects will be graded on a pass/fail basis.

Beyond these assignments, you will have one mega-project for the class. Specifically, I will ask you to create a sophisticated web study from the ground up. This study will be one of your choosing and, as such, it should be one that fits naturally into your research program. I realize that some people have more lofty ambitions than others, so I will work with you early in the semester to ensure that your project is manageable (if it originally seems too complex) or more complex (if it originally seemed too simple and unchallenging).

Policy on Missed Tests and Assignments

Homework assignments should be organized on your personal website. You should create a directory called "p593" and in that folder create a web page called "homework.htm". A link to each homework assignment should be listed there, along with the date in question and links to any code that was used. I will start reviewing homework assignments on Fridays at 7:00 a.m. If you have not completed your assignment by that time, it will be considered late and, depending on what kind of time I have available to me, potentially overlooked.

Student Homework Links

I will list the links to the student homework pages here for easy reference.

Iris
David
Jing
Yuchen
Kevin
Lauren
Noam
Emily D
Emily G



Schedule for the Class

I will be constructing my lectures over the course of the semester. As the lectures and plans become more crystallized, I'll post the necessary materials on the class web page. The outline below is a preliminary outline (i.e., one that is subject to change) of what will be covered during the lab sections of the class.

Topics to be covered:
Basic HTML and CSS
Input fields and forms
Basic server-side scripting in PHP
Providing feedback to participants
Conditionals, Loops, Arrays
Multiple pages vs. single pages
Hidden tags and overcoming 'statelessness'
Functions and subroutines
Randomization of stimuli and random assignment to conditions
Branching structures
DOM manipulation
Basic JavaScript
Writing/Reading data to/from text files
MySQL data base administration
Interfacting PHP and MySQL
Security and data/input cleaning
Providing sample analyses
Graphical outputs (bargraphs, scatterplots) and jQuery flot
Working with dates and times. Page read times.
AJAX
MTurk



Jan 18
No Class
SPSP Conference


Jan 25
Introduction + Web server + Basic HTML
Lecture 01 PowerPoint

HTML Quick Reference Guide for Class Discussion

Links to useful resources:

W3 Schools 'Try it Yourself Editor'
Try it yourself
Netfirms
Netfirms
HTML Colors
http://www.w3schools.com/html/html_colors.asp
http://html-color-codes.info/

Homework, due next week
Set up your website. Include the following elements:
  1. An "index" page that briefly describes who you are and how to contact you
  2. A separate page that describes your research interests
  3. A separate page that contains your publications and/or conference presentations
  4. Your home page should contain links to these new research and pubs pages
  5. A new directory labeled "homework"
  6. Within your /homework/ directory, create a page called "homework.html" and put a nice message on it for me to read
  7. At least one of these pages should demonstrate your skills with the following




Feb 1
More on HTML, CSS, and Input Forms
elaboration on paths for images and links image file sizes and dimensions tables links file extensions CSS Quick Reference Guide for Class Discussion

CSS Tutorial
http://www.w3schools.com/css/default.asp
Great CSS Reference Page
CSS Properties
CSS Selectors


Homework, due next week
There are two assignments for next week.

Part 1.
Create a webpage that uses what you've learned about forms to collect the following data from a user:
  1. Information about the uesr's age
  2. Information about the user's sex
  3. Information about a user's ethnicity
  4. Which of the following adjectives the user thinks is descriptive of him or herself: outgoing, happy, energetic, athletic, fit, smart, religious, fabulous
  5. A rating of how hungry the person is on a 1 to 7 scale, anchored by "not at all" and "can eat a horse"
  6. A brief description of the person's childhood experiences
Be sure to demonstrate your ability to use the following input options: radio, checkbox, select menu, textbox, textarea, submit button. Please save the page as homework2.html and place it in your /homework/ directory.

Part 2.
Please describe for me at least one research project you would like to be able to implement based on skills that you hope to acquire in this course. It is not important that you explain the conceptual issues that might motivate the research. I'm more interested in the nuts and bolts of how you might collect data. Please send this description to me via e-mail OR, if you prefer, include it on your homework2.html page.



Feb 8
Introduction to PHP and server-side scripting
Core Building Blocks for designing dynamic web design

Building Block concepts to master: variables, escaping variables, substitution
iteration, reading CGI data
Using conditionals and logical tests to evaluate conditions
determine whether variables have values, evaluating page status
arrays and manipulating arrays
Looping to repeat operations
Writing and reading data from a text file


Topic Live Output Code with detailed notes
Basic PHP Output Code and notes
Variables (literal and interpreted) Output Code and notes
Variable manipulation Output Code and notes
CGI data and variables Output Code and notes
If-else conditionals + isset/empty Output Code and notes
Arrays Output Code and notes
Loops: for-next + while + foreach Output Code and notes


Homework, due next week
Create a webpage that does the following:
  1. The first time the user visits the page, the page will ask him or her for a name. Include a submit button to advance to the next step.
  2. Once submitted, the SAME PHP FILE will present a welcome messsage that uses substitution to acknowledge the user by name. It will also present three questions of your choosing for which the user can submit responses. Please feel free to use radio buttons, textboxes, or whatever input option you like. Again, include a submit button at the end of the page.
  3. When the user submits, the SAME PHP FILE should include a thank you message. In addition, you should use IF-THEN conditionals to present a thank you message that is customized for one of your questions. (Example: If you ask about mood, you can wish someone who is having a bad day a better day. If someone says they are hungry, make a suggestion for something tasty.)
  4. If we had time to cover data saving in class (EDIT: WE DIDN'T), please also have your PHP script save the data and display the current contents of your data file.



Feb 15
Overcoming Statelessness in PHP Forms

Functional Tools
- developing multi-page studies
- randomize the order of stimuli
- random assignment to conditions

Programming Tools, Concepts, and Building Blocks
- Using hidden tags and CGI input to preserve information in stateless situations
- Using hidden tags to pass forward both variables and arrays
- Creating and using functions to automate specific behaviors
- Understanding when FORM data and HIDDEN data do and do not overwrite one another
- explode() as a way of breaking strings down into separate elements

Topic Live Output Code with detailed notes
Passing variables forward as hidden variables Output Code and notes
Using pass variables to track page progress Output Code and notes
Randomize the order of stimuli, passing ARRAYs foward as hidden variables Output Code and notes
Random assignment to conditions Output Code and notes
Writing data to text files Output Code and notes
Reading and using data from text files | explode() Output Code and notes


Homework, due next week
The homework assignment is to simply rework the assignment you turned in this past week, but with the following modifications/additions:

1. The questions you ask after you've obtained the name of the user should be presented on multiple, separate pages rather than on a single page. (This is similar in spirit to the example we discussed in class in which I presented each mood item on a separate page.)

2. I want you to adopt the cyclical procedure we discussed for keeping form data "alive" across multiple, stateless submissions of a page. Thus, please "read in" all the CGI data at the start of your PHP script and, at the start of each FORM, be sure to pass forward all relevant data (whether collected yet or not) as HIDDEN tags.

3. I want you to explore the shuffle() function for the purposes of randomizing arrays and demonstrate you ability to use the procedure in your PHP script. I'm not too particular on how you use it. Some things that come to mind include using it to randomly assign people to one set of questions vs. another, randomizing the order of the questions you present, randomizing the feedback you present.

If you want to challenge yourself, I strongly encourage you to practice passing array data forward as HIDDEN tags. Even if this function isn't critical for the operation of your script, this is something you'll want to practice so that the process doesn't seem too foreign.

4. Finally, I want you to save the data you collect from your users to a text file. Moreover, your feedback page should also read the text file and present the contents of the file in a quick and dirty way so I can see it and make sure things are working okay when I run your PHP script. As an example of what I have in mind, see the output on this page http://www.yourpersonality.net/P593/PHPtutorial08.php.



Feb 22
Class canceled. Illness



Feb 29
Functions/subroutines in PHP

Functional Tools
- using functions to average variables
- using functions to create input fields and sticky forms
- using functions to simply the process of passing info forward as hidden fields

Programming Tools, Concepts, and Building Blocks
- functions (basics)
- functions with parameters/arguments
- returning output from functions - variable scopes with respect to functions

Topic Live Output Code with detailed notes
Basic fuction: Create, call, arguments, and return Output Code and notes
A function that averages scores, with graceful handling of missing data Output Code and notes
A function that makes radio button creation easier; sticky forms Output Code and notes
A function for passing forward all information as hidden tags (extension of PHPtutorial11.php) Output Code and notes


Homework, due next week
Each student will be responsible for creating a function that they think will be useful for their purposes or more general research purposes. Importantly, these functions must be flexible enough that other people in the class can use them. They should be documented clearly.



Mar 8
Introduction to MySQL and interfacing with MySQL via PHP

Functional Tools
- creating databases in SQL
- reading and writing to databases
- interacting with databases via PHP

MySQL Quick Reference Guide for Class Discussion



Topic Live Output Code with detailed notes
Write data to a MySQL database via PHP Output Code and notes
Read from a MySQL databse and process data via PHP Output Code and notes


Homework, due next week
Adapt one of the online questionnaires you've created such that it saves the data to a MySQL database rather than saving the data as a text file. You should also demonstrate that you know how to access the data in the SQL file once it has been stored there (e.g., using SELECT commands via PHP).

Additional challenge



Mar 15
Graphing (Part 1) and Form Validation

Functional Tools
- Create simple bargraphs via PHP/HTML (no plugins)
- Determine if users have submitted appropriate data
- Basic data cleaning



Topic Live Output Code with detailed notes
Basic graphing Output Code and notes
Form validation Output Code and notes



Mar 22 Spring Break



Mar 29
javascript, jQuery, basic DOM manipulation, flot (graphing part 2)

Functional Tools
- Create basic graphs (e.g., bargraphs, line graphs, scatter plots) via flot
- Using javascript to manipulate HTML objects and properties
- Basic javascript for form validation

Extra links, notes, and resources
Some notes on jQuery and flot
JS Fiddle -- a nice resource for testing javascript without file transfer
flot
jQuery
An amazing jQuery tutorial/resource


Topic Live Output Code with detailed notes
Using javascript to make forms appear and disappear in conditional ways Output right-click live page for source code
javascript to make radio buttons more intuitive and dynamic Output right-click live page for source code
javascript for basic text field validation Output right-click live page for source code
javascript for basic radio button validation Output right-click live page for source code
jQuery for a score bar that expands Output right-click live page for source code
jQuery for toggling sections on and off Output right-click live page for source code
jQuery - Combine previous two ideas Output right-click live page for source code
flot demonstration of a bargraph for a 2x2 design Output Code and notes
flot demonstration of a scatterplot and line graph Output Code and notes
flot demonstration of a scatterplot that dynamically loads PHP array data Output Code and notes

Homework

For this assignment I would like for you to create a simple PHP script that does one or more of the following:

1. Provides the user with rich, graphical feedback (i.e., 1 barplot and 1 scatterplot). You can create "fake" data for this pupose if you simply want to refine your skills on the graphical end. But, if you do, try to make your script easily extendable so that you can pass real data to it at some point in the future.

OR

2. Provides you (i.e., the researcher) with a special page that can be used to do some quick data summaries. Specifically, a page that shows the means for some variables, uses at least one barplots and at least one scatterplot.

AND

3. Find a creative way to use javascript and/or jQuery to augment your webpage. I'll leave it to you to find something useful to do, but please make sure that (a) it extends what we've discussed in class in a new direction and (b) it has the potential to be useful to you, given your research goals.

Example (without code showing): http://www.web-research-design.net/cgi-bin/P593/view2.pl




April 5
Designing a login system with user registration and SQL

Functional Tools
- Create (and delete) cookies
- Use PHP to send e-mails
- Organize multiple pieces of information (acrosss surveys/studies) via a single system



Topic Live Output Code with detailed notes
Entry page for live demonstration Demo
index.php Code and notes
change_password.php Code and notes
create_account.php Code and notes
forgot_password.php Code and notes
logout.php Code and notes
menu.php Code and notes
surveydemo1.php Code and notes
Homework

1. Send me an email that describes your final project and what you hope to accomplish. I need to make sure it is doable and appropriately challenging, but not overly complex.

2. Create a login system that works on your sever and allows you to administer one of the questionnaires you've created before (are are working on for other fun purposes) within that system, saving the data appropriately.

Note. You will need to create a table on your SQL data base on YOUR server to make this work. The table should contain the necessary variables, such as first_name, email, pass, registration_date, and user_id (auto-increment; unique). Also, make sure the table name matches what you're using in your code. In my class examples I used a table called "users." If you choose a different name for your table, be sure to use the appropriate name in your SQL/PHP queries.



April 12
Designing a login system with user registration and SQL: Part 2 - Track Participation and Provide Feedback

Functional Tools
- Work with multiple data tables
- Provide feedback to users independently of whether they just took the survey/study
- Create context-sensitive menus




Topic Live Output Code with detailed notes
Entries in bold contain different code than the entries from last week
Entry page for live demonstration Demo
index.php Code and notes
change_password.php Code and notes
create_account.php Code and notes
forgot_password.php Code and notes
logout.php Code and notes
menu.php Code and notes
surveydemo1.php Code and notes
surveydemo2.php Code and notes
surveydemo3.php Code and notes
resultsdemo2.php Code and notes
resultsdemo3.php Code and notes



April 19
Some security issues, IRBs, and Notes on MTurk

An example, approved local IRB (will email)
Readings on MTurk
Buhrmester Kwang and Gosling 2011
Shapriro Chandler and Mueller 2013

MTurk


This version of the login system incorportates several changes:
Topic Live Output Code with detailed notes
Entries in bold contain different code than the entries from last week
Entry page for live demonstration Demo
index.php Code and notes
change_password.php Code and notes
create_account.php Code and notes
forgot_password.php Code and notes
logout.php Code and notes
menu.php Code and notes
surveydemo2.php Code and notes
resultsdemo2.php Code and notes
userinformation.php Code and notes



April 26
Final project workshop

Final project due May 10th