#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; #----------------------------------------------- # Read in variables #----------------------------------------------- $pass= $query->param('pass'); $thisCondition= $query->param('thisCondition'); $mem1= $query->param('mem1'); $mem2= $query->param('mem2'); @itemIndex= $query->param('itemIndex'); @picIndex= $query->param('picIndex'); $p0r0= $query->param('p0r0'); $p0r1= $query->param('p0r1'); $p0r2= $query->param('p0r2'); $p0r3= $query->param('p0r3'); $p0r4= $query->param('p0r4'); $p0r5= $query->param('p0r5'); $p0r6= $query->param('p0r6'); $p0r7= $query->param('p0r7'); $p0r8= $query->param('p0r8'); $p1r0= $query->param('p1r0'); $p1r1= $query->param('p1r1'); $p1r2= $query->param('p1r2'); $p1r3= $query->param('p1r3'); $p1r4= $query->param('p1r4'); $p1r5= $query->param('p1r5'); $p1r6= $query->param('p1r6'); $p1r7= $query->param('p1r7'); $p1r8= $query->param('p1r8'); $p2r0= $query->param('p2r0'); $p2r1= $query->param('p2r1'); $p2r2= $query->param('p2r2'); $p2r3= $query->param('p2r3'); $p2r4= $query->param('p2r4'); $p2r5= $query->param('p2r5'); $p2r6= $query->param('p2r6'); $p2r7= $query->param('p2r7'); $p2r8= $query->param('p2r8'); $va01= $query->param('va01'); $va02= $query->param('va02'); $va03= $query->param('va03'); $va04= $query->param('va04'); $va05= $query->param('va05'); $va06= $query->param('va06'); $va07= $query->param('va07'); $va08= $query->param('va08'); $va09= $query->param('va09'); $va10= $query->param('va10'); $sex= $query->param('sex'); $age= $query->param('age'); $country= $query->param('country'); $takenbefore= $query->param('takenbefore'); $title = "Relationships Survey"; #----------------------------------------------- # Survey Items #----------------------------------------------- # attachment (current or ex partner) - Relationship Structures $a01 = "1. It helps to turn to this person in times of need."; $a02 = "2. I usually discuss my problems and concerns with this person."; $a03 = "3. I talk things over with this person."; $a04 = "4. I find it easy to depend on this person."; $a05 = "5. I don't feel comfortable opening up to this person."; $a06 = "6. I prefer not to show this person how I feel deep down."; $a07 = "7. I often worry that this person doesn't really care for me."; $a08 = "8. I am afraid that this person may abandon me."; $a09 = "9. I worry that this person won't care about me as much as I care about him or her."; $a10 = "10. I don't fully trust this person."; # Set Pass = 0 if($pass < 1){ $pass=0; } # get date and time ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = 1900 + $year; $mon= $mon+1; $hour = $hour - 1; $date1= "$mon/$mday/$year"; $date2= "$hour:$min:$sec"; #Remove commas from free response $mem1 =~ s/\n/
/g; $mem1 =~ s/\r/ /g; $mem1 =~ s/\,/ /g; print $query->header; print $query->start_html(-title=>'Relationships Survey'); #----------------------------------------------- # Pass = 7 # Participant Feedback #----------------------------------------------- if ($pass == 7) { print "
"; #Calculate average reaction to picture stimuli $reaction = &averageScores($p0r0,$p1r0,$p2r0,$p0r2,$p1r2,$p2r2,$p0r3,$p1r3,$p2r3,$p0r5,$p1r5,$p2r5,$p0r6,$p1r6,$p2r6,&revKey(6,$p0r1),&revKey(6,$p1r1),&revKey(6,$p2r1),&revKey(6,$p0r4),&revKey(6,$p1r4),&revKey(6,$p2r4),&revKey(6,$p0r7),&revKey(6,$p1r7),&revKey(6,$p2r7),&revKey(6,$p0r8),&revKey(6,$p1r8),&revKey(6,$p2r8)); # Calculate PARTICIPANT Attachment and Anxiety # attachment with partner if ($thisCondition == 0) { $partnerAvoid = &averageScores(&revKey(6,$va01),&revKey(6,$va02),&revKey(6,$va03),&revKey(6,$va04),$va05,$va06); $partnerAnx = &averageScores($va07,$va08,$va09,$va10); } else { # attachment with ex $exAvoid = &averageScores(&revKey(6,$va01),&revKey(6,$va02),&revKey(6,$va03),&revKey(6,$va04),$va05,$va06); $exAnx = &averageScores($va07,$va08,$va09,$va10); } # Calculate SAMPLE AVERAGE Attachment and Anxiety $n0= 0; $n1= 0; $n= 0; $sum1= 0; $sum2= 0; $sum3= 0; $sum4= 0; $sum5= 0; # Read the full data file in as @data open(INFO, "$ENV{'DOCUMENT_ROOT_OLD'}/www/relationshipsresearch.com/P593/final.txt"); @data = ; close(INFO); # Loop through each line of the data file foreach $key (@data) { @a=split(/,/,$key); $sum1= $sum1 + $a[15]; $sum2= $sum2 + $a[16]; $sum3= $sum3 + $a[17]; $sum4= $sum4 + $a[18]; $sum5= $sum5 + $a[23]; $n= $n + 1; if ($a[2] eq 0) { $n0= $n0 + 1; } elsif ($a[2] eq 1) { $n1= $n1 + 1; } } # When done looping, divide by n to get sample averages #SAMPLE reaction to picture if ($n > 1) { $reactionSample = $sum5/$n; } if ($thisCondition == 0 && $n0 > 1) { # SAMPLE attachment with partner $pAvoidSample = $sum1/$n0; $pAnxSample = $sum2/$n0; } elsif ($thisCondition == 1 && $n1 > 1) { # SAMPLE attachment with ex $exAvoidSample = $sum3/$n1; $exAnxSample = $sum4/$n1; } # Round scores to two decimal places $reaction = sprintf("%.2f", $reaction); $reactionSample = sprintf("%.2f", $reactionSample); $pAvoidSample = sprintf("%.2f", $pAvoidSample); $pAnxSample = sprintf("%.2f", $pAnxSample); $exAvoidSample = sprintf("%.2f", $exAvoidSample); $exAnxSample = sprintf("%.2f", $exAnxSample); $partnerAvoid = sprintf("%.2f", $partnerAvoid); $partnerAnx = sprintf("%.2f", $partnerAnx); $exAvoid = sprintf("%.2f", $exAvoid); $exAnx = sprintf("%.2f", $exAnx); # save all the data to a text file open(INFO, ">>$ENV{'DOCUMENT_ROOT_OLD'}/www/relationshipsresearch.com/P593/final.txt"); print INFO "$date1,$date2,$thisCondition,$mem1,$mem2,"; print INFO "$va01,$va02,$va03,$va04,$va05,$va06,$va07,$va08,$va09,$va10,"; print INFO "$partnerAvoid,$partnerAnx,$exAvoid,$exAnx,"; print INFO "$pAvoidSample,$pAnxSample,$exAvoidSample,$exAnxSample,"; print INFO "$reaction,$reactionSample,"; print INFO "$p0r0,$p0r1,$p0r2,$p0r3,$p0r4,$p0r5,$p0r6,$p0r7,$p0r8,"; print INFO "$p1r0,$p1r1,$p1r2,$p1r3,$p1r4,$p1r5,$p1r6,$p1r7,$p1r8,"; print INFO "$p2r0,$p2r1,$p2r2,$p2r3,$p2r4,$p2r5,$p2r6,$p2r7,$p2r8,"; print INFO "$sex,$age,$country,$takenbefore,"; print INFO "endline\n"; close (INFO); # Print feedback for CURRENT PARTNER if ($thisCondition == 0 ) { print ""; print ""; print ""; print "
Relationships Survey: Feedback


"; print ""; print ""; print ""; # Print feedback for EX-PARTNER } else { print "
"; print ""; print " Attachment Avoidance
"; print " Attachment avoidance is the degree to which people feel comfortable opening up in close relationships. Higher scores indicate high avoidance and less comfort opening up. Lower scores indicate low avoidance and greater comfort opening up.

"; print "Your attachment avoidance with your current partner is $partnerAvoid. The average avoidance score in our sample is $pAvoidSample.

"; print " Attachment Anxiety
"; print "Attachment anxiety is the degree to which people worry about how responsive their partners (or ex-partner) will be when they need their ex-partners (for example, when they need the partner for comfort after a bad day). Higher scores indicate high anxiety and a greater degree of worrying. Lower scores indicate low anxiety and a lesser degree of worrying.

"; print "Your attachment anxiety with your current partner is $partnerAnx. The average anxiety score in our sample is $pAnxSample.

"; print "Your results (red dot) and the sample average (blue dot) are shown in the graph on the right.

"; print " "; # Scatterplot for CURRENT PARTNER print "
"; print "
"; print ""; print " Reaction to Pictures
"; print " We were also interested in your reaction to the pictures presented in the study. Specifically, we wanted to see how positive or negative your average reaction was. Higher scores indicate a more negative reaction and lower scores indicate a more positive reaction.

"; print "Your average reaction to the pictures is $reaction on a scale of 1 (positive reaction) to 5 (negative reaction). The average reaction in our sample is $reactionSample."; print "
"; print ""; print ""; print "
Relationships Survey: Feedback


"; print ""; print ""; print ""; } print "
"; print ""; print " Attachment Avoidance
"; print "Attachment avoidance is the degree to which a person feels comfortable opening up to close others. Higher scores indicate high avoidance and less comfort opening up. Lower scores indicate low avoidance and greater comfort opening up.

"; print "Your attachment avoidance with your ex-partner is $exAvoid. The average avoidance score in our sample is $exAvoidSample.

"; print " Attachment Anxiety
"; print " Attachment anxiety is the degree to which people worry about how responsive their partners (or ex-partner) will be when they need their ex-partners (for example, when they need the partner for comfort after a bad day). Higher scores indicate high anxiety and a greater degree of worrying. Lower scores indicate low anxiety and a lesser degree of worrying.

"; print "Your attachment anxiety with your ex-partner is $exAnx. The average anxiety score in our sample is $exAnxSample.

"; print "Your results (red dot) and the sample average (blue dot) are shown in the graph.

"; print "
"; print " "; # Scatterplot for EX-PARTNER print "
"; print "
"; print ""; print " Reaction to Pictures
"; print " We were also interested in your reaction to the pictures presented in the study. Specifically, we wanted to see how positive or negative your average reaction was. Higher scores indicate a more negative reaction and lower scores indicate a more positive reaction.

"; print "Your average reaction to the pictures is $reaction on a scale of 1 (positive reaction) to 5 (negative reaction). The average reaction in our sample is $reactionSample."; print "
"; } # end Pass = 6 #----------------------------------------------- # Pass = 6 # Demographic Items #----------------------------------------------- if ($pass == 6) { print "
"; print ""; print "
Relationships Survey: Demographic Questions


"; print ""; print "1. Are you male or female?
"; print " male
"; print " female
"; print "

"; print "2. How old are you?
"; print " years old
"; print "

"; print "3. What is your country of residence?
"; print ""; print "

"; print "4. Have you taken this survey before?
"; print " yes
"; print " no
"; print "

"; print ""; print ""; &passHidden(); print "
"; } # end Pass = 6 #----------------------------------------------- # Pass = 5 # Relationship Structures Questionnaire #----------------------------------------------- if ($pass == 5) { print "
"; print ""; print "
Relationships Survey: Relationship Questions


"; print ""; if ($thisCondition == 0) { print "The statements below concern how you feel in your current romantic relationship. Respond to each statement by clicking a circle to indicate how much you agree or disagree with the statement.

"; } else { print "The statements below concern how you feel about your former romantic relationship. Respond to each statement by clicking a circle to indicate how much you agree or disagree with the statement.

"; } print "$a01
"; &printLikert5(va01); print "$a02
"; &printLikert5(va02); print "$a03
"; &printLikert5(va03); print "$a04
"; &printLikert5(va04); print "$a05
"; &printLikert5(va05); print "$a06
"; &printLikert5(va06); print "$a07
"; &printLikert5(va07); print "$a08
"; &printLikert5(va08); print "$a09
"; &printLikert5(va09); print "$a10
"; &printLikert5(va10); print ""; print ""; &passHidden(); print "
"; } # end Pass = 5 #----------------------------------------------- # Pass = 2 - 4 # Present Three Pics and Ratings (change the number of passes depending on the number of pictures included) #----------------------------------------------- if($pass >= 2 && $pass <=4 ){ print "
"; @pics = ('/images/picture0.jpg','/images/picture1.jpg','/images/picture2.jpg'); $p = $pass - 2; print ""; print ""; print ""; print "
Relationships Survey: Pictures


"; print ""; print " Please take a moment to look at the picture, then respond to the questions below.



"; # picture ratings $p0 = "I thought the picture was gross."; $p1 = "I found the picture to be pleasant."; $p2 = "I did not enjoy looking at the picture."; $p3 = "The picture digusted me."; $p4 = "I liked the picture."; $p5 = "The picture distressed me."; $p6 = "I would avoid looking at this picture in the future."; $p7 = "The picture interested me."; $p8 = "My overall opinion of the picture is positive."; @itemIndex = &randomize(0,1,2,3,4,5,6,7,8); @variableNames = (r0,r1,r2,r3,r4,r5,r6,r7,r8); @items = ($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8); print ""; for ($i=0;$i<=8;$i++) { $num = $i + 1; print "$num. $items[$itemIndex[$i]]

"; &printLikert5(p.$picIndex[$p].$variableNames[$itemIndex[$i]]); } $pass = $pass + 1; &passHidden(); print ""; print $query->hidden(picIndex, @picIndex); print ""; print ""; print "
"; print "
"; } # end Pass = 2,3,4 #----------------------------------------------- # Pass = 1 # Assign to Condition, text area #----------------------------------------------- if($pass == 1){ # Create picture order for next pass # this should have the number of pictures to be viewed (i.e. for 3 pictures: 0, 1, 2) @picIndex = &randomize(0,1,2); # Define the prime stimuli $cond0= "Please take a moment to think about a memory you have that involves your current romantic partner. When you are ready, please briefly describe the memory in the box below.

"; $cond1= "Please take a moment to think about a memory you have that involves your ex-partner. When you are ready, please briefly describe the memory in the box below.

"; # randomly select a condition $thisCondition = &randomSelect(0,1); print "
"; print ""; print "
Relationships Survey: A Memory


"; # present different stimuli depending on the condition selected if($thisCondition == 0){ print "$cond0"; } else{ print "$cond1"; } # print Text Area print "
"; print "If you prefer not to write about this memory, please check here."; print "
"; print "


"; print ""; print ""; &passHidden(); print "
"; } # end Pass = 1 #----------------------------------------------- # Pass = 0 # Consent #----------------------------------------------- if($pass == 0){ print ""; print ""; print ""; print " "; print ""; print "
"; #-- print "
Relationships Survey: Study Information


"; print " The purpose of this research is to learn more about experiences in romantic relationships with both current and former partners. You can participate if you are in or have ever been in a romantic relationship. This research is being conducted by Dr. R. Chris Fraley, professor of psychology at the University of Illinois at Urbana-Champaign. This study takes about 10 minutes to complete.

You must be 18 years or older to participate. If you are not 18 years or older, you should not participate.

You will be asked to complete a questionnaire pertaining to your experiences in your current or past romantic relationships. The researchers will keep the information you provided confidential. However, the service hosting this survey may have access to the data you submit and your IP number. We cannot guarantee that this service will keep information you submit confidential.

We hope to gain insight into how relationships affect people. The benefit for you directly is that the program will analyze your responses and give you a personalized summary of the information you provided.

It is important that you answer as many questions as possible, but please note that you are free to skip any questionnaire item you wish, as well as free to withdraw from the study at any time without fear of prejudice or penalty. Your participation in the study is completely voluntary. Not participating or stopping the study will not affect your current or future relationship with the University of Illinois at Urbana-Champaign in any way.


"; print ""; print "

"; print "By clicking the above button, you certify that you are 18 years or older.

"; print "
Participation is voluntary and you may skip any questions you do not wish to answer. This research is being conducted by Dr. R. Chris Fraley of the University of Illinois at Urbana-Champaign. For more information concerning this research, please email rcfraley\@uiuc.edu or call (217) 333-3486. The Institutional Review Board office may also be contacted concerning this study at (217) 333-2670. You may call collect if you live outside the local calling area. There are no known risks involved in completing this study. You may print a copy of this page for your records."; print "
"; print "
"; print "
"; print ""; &passHidden(); print ""; } # end Pass = 0 # ----------------- Subroutines ----------------------------- # for a good tutorial/overview of Perl subroutines, see # http://www.comp.leeds.ac.uk/Perl/subroutines.html #------------------------------------------------------------ #----------------------- # randomSelect Subroutine #----------------------- sub randomSelect { # this subroutine randomizes the elements of an array and returns the 0th value of the new array srand; my(@new) = (); while (@_){ push(@new, splice(@_, rand @_,1)); } return $new[0]; } # end sub #----------------------- # randomize Subroutine #----------------------- sub randomize { # this subroutine randomizes the elements of an array and returns the new array srand; my(@new) = (); while (@_){ push(@new, splice(@_, rand @_,1)); } return @new; } # end sub #----------------------- # passHidden Subroutine #----------------------- sub passHidden { #PASS FORWARD ALL THE FINAL VARIABLES print $query->hidden(itemIndex, @itemIndex); print $query->hidden(picIndex, @picIndex); print ""; print ""; print ""; print ""; print ""; print ""; #more questions added if adding a new picture print $query->hidden(p0r0, $p0r0); print $query->hidden(p0r1, $p0r1); print $query->hidden(p0r2, $p0r2); print $query->hidden(p0r3, $p0r3); print $query->hidden(p0r4, $p0r4); print $query->hidden(p0r5, $p0r5); print $query->hidden(p0r6, $p0r6); print $query->hidden(p0r7, $p0r7); print $query->hidden(p0r8, $p0r8); print $query->hidden(p1r0, $p1r0); print $query->hidden(p1r1, $p1r1); print $query->hidden(p1r2, $p1r2); print $query->hidden(p1r3, $p1r3); print $query->hidden(p1r4, $p1r4); print $query->hidden(p1r5, $p1r5); print $query->hidden(p1r6, $p1r6); print $query->hidden(p1r7, $p1r7); print $query->hidden(p1r8, $p1r8); print $query->hidden(p2r0, $p2r0); print $query->hidden(p2r1, $p2r1); print $query->hidden(p2r2, $p2r2); print $query->hidden(p2r3, $p2r3); print $query->hidden(p2r4, $p2r4); print $query->hidden(p2r5, $p2r5); print $query->hidden(p2r6, $p2r6); print $query->hidden(p2r7, $p2r7); print $query->hidden(p2r8, $p2r8); print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print $query->hidden(mem1, $mem1); } # end sub #----------------------- # printLikert5 Subroutine #----------------------- sub printLikert5 { # Subroutine by Jenn Smith print " Strongly Disagree
\n Disagree
\n Neutral
\n Agree
\n Strongly Agree


\n\n"; } # end sub #-------------------------- # averageScores Subroutine #-------------------------- sub averageScores { # sub for averaging scores and adjusting denom for missing cases # fraley march 26 2005 # returns mean, takes as param an array or seq of values # returns zero if no valid cases $nSUB = @_; $validnSUB = 0; $sumSUB = 0; for($iSUB=0;$iSUB<=($nSUB-1);++$iSUB){ if($_[$iSUB] > 0){ $sumSUB = $sumSUB + $_[$iSUB]; $validnSUB = $validnSUB + 1; } } $mean = 0; if($validnSUB > 0){ $mean = $sumSUB/$validnSUB; } return $mean; } # end sub #------------------------------- # Reverse keys items Subroutine #------------------------------- sub revKey { # first element should be max + 1 value # second element is one to reverse key $highSUB = $_[0]; $valueSUB = $_[1]; $newValue = 0; if($valueSUB > 0){ $newValue = $highSUB-$valueSUB; } return $newValue; } # end sub print $query->end_html;