#!/usr/bin/perl ############################################################################## ############################################################################## # StellarStuff.com # # All-Test # # Copyright 2000 StellarStuff.com # # Created 1/1/2000 # # with heavy modifications by Michael Wu 3/10/2002 # # Available at http://www.stellarstuff.com # ############################################################################## # COPYRIGHT NOTICE # # Copyright 2000 StellarStuff.com All Rights Reserved. # # # # This script can be used\modified as long as you have paid for a registered # # version. To order, go to http://www.stellarstuff.com # # By using this script you agree to indemnify StellarStuff.com from any # # liability that might arise from its use. # # # # Redistributing\selling the code for this program without prior written # # consent is expressly forbidden. # ############################################################################## require "alltest.cfg"; ############################################################################## print "Content-type: text/html\n\n"; ########### Put the posted data into variables ############################### if ($ENV{"REQUEST_METHOD"} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } ####### Decide what to do based on the $FORM{'action'} variable ############# if ($FORM{'action'} eq "askquestions") { &askquestions; } elsif ($FORM{'action'} eq "checkanswers") { &checkanswers; } else { #### FIRST TIME IN #### &askquestions; } ############################################################################# ############################################################################# sub header { open (FILE, "header.txt"); @header = ; close(FILE); foreach $header(@header) { print "$header"; } } ############################################################################# ############################################################################# sub footer { open (FILE, "footer.txt"); @footer = ; close(FILE); foreach $footer(@footer) { print "$footer"; } } ############################################################################# ############################################################################# sub askquestions { if ($usessi == 0) { &header; } print "Read the related article, The Joy of Thanks.\n"; print "

\n"; print "To study anything effectively, you need to be able to measure it. So for the past two years, I have been working with Southern Methodist University's Michael E. McCullough and Jo-Ann Tsang to devleop an accurate measure of gratitude and to find out how people's gratitude scores relate to their own health and well-being. This research, which was published in Janurary 2002, in the Journal of Personality and Social Psychology, was conducted in part via an extensive questionnaire on SpiritualityHealth.com, as well as with groups of university students.\n"; print "

\n"; print "After analyzing the date, we were able to refine a measure of gratitude to six key factors. To understand the role gratitude plays in your own life, take a moment to complete the test below.\n"; print "

\n"; print "Choose how much you agree with each statement. Please read the choices carefully. Note that E and F are in reverse order.\n"; print "

\n"; print " \n"; print "

\n"; print " \n"; print " \n"; open (FILE, "questions.txt"); @questions = ; close(FILE); $incidx = 0; foreach $questions(@questions) { ($idx,$ques,$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$val,$mul,$blk) = split(/\|/, $questions); if ($mul eq "1") { $itype = "Checkbox"; } else { $itype = "Radio"; } ## Question Row ## print " \n"; if ($mul eq "1") { $incidx = $incidx + 100; $newidx = $incidx + 1; ## Up to Ten Possible Answers ## if ($a) { print " \n"; if ($c) { $newidx++; print " \n"; } else { print " \n"; } } $newidx++; if ($e) { print " \n"; if ($g) { $newidx++; print " \n"; } else { print " \n"; } } $newidx++; if ($i) { print " \n"; if ($k) { $newidx++; print " \n"; } else { print " \n"; } } $newidx++; if ($m) { print " \n"; if ($o) { $newidx++; print " \n"; } else { print " \n"; } } $newidx++; if ($q) { print " \n"; if ($s) { $newidx++; print " \n"; } else { print " \n"; } } } else { ## Up to Ten Possible Answers ## if ($a) { print " \n"; } } } ## Spacer Row ## ## print " \n"; ## } print " \n"; print "
$myfont$ques
$myfont$a$myfont$c
 
$myfont$e$myfont$g
 
$myfont$i$myfont$k
 
$myfont$m$myfont$o
 
$myfont$q$myfont$s
 
$myfont$a
\n"; if ($c) { print " $myfont$c
\n"; } else { print "   \n"; } } if ($e) { print " $myfont$e
\n"; if ($g) { print " $myfont$g
\n"; } else { print "   \n"; } } if ($i) { print " $myfont$i
\n"; if ($k) { print " $myfont$k
\n"; } else { print "   \n"; } } if ($m) { print " $myfont$m
\n"; if ($o) { print " $myfont$o
\n"; } else { print "   \n"; } } if ($q) { print " $myfont$q
\n"; if ($s) { print " $myfont$s
\n"; } else { print "  
 
 
   
\n"; print "
\n"; if ($usessi == 0) { &footer; } } ############################################################################# ############################################################################# sub checkanswers { if ($usessi == 0) { &header; } print " \n"; print " \n"; open (FILE, "questions.txt"); @questions = ; close(FILE); ## Get Total Scores Here ## $totalpossible = 0; $totaluserscore = 0; $incidx = 0; foreach $questions(@questions) { ($idx,$ques,$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$val,$mul,$blk) = split(/\|/, $questions); $totalpossible = $totalpossible + $val; if ($mul ne "1") { $totaluserscore = $totaluserscore + $FORM{$idx}; } else { $incidx = $incidx + 100; $newidx = $incidx + 1; for ($x = 1; $x <= 10; $x++) { $totaluserscore = $totaluserscore + $FORM{$newidx}; $newidx++; } } } ## OPEN RANK FILE HERE ## open (FILE, "ranks.txt"); @ranks = ; close(FILE); ## Statistics Display ## foreach $ranks(@ranks) { ($rnka,$rnkb,$txt,$desc,$blk) = split(/\|/, $ranks); if ($totaluserscore >= $rnka) { if ($totaluserscore <= $rnkb) { $usertext = $txt; $userdesc = $desc; } } } $userpercent = sprintf("%.2f",100 * ($totaluserscore / $totalpossible)); $score = $totaluserscore; ## Display Total Scores Now ## if ($usepercent eq "1") { print " \n"; } else { print " \n"; } print "
 
$myfontYour Total Score : $totaluserscore ($userpercent %)
$usertext

 
$myfontYour Total Score : $totaluserscore
$usertext


\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
Your score compared to the benchmarks from the 1,224 adults who recently took the GQ on this site:

42 You scored among the top 13% of our sample.

 
41 You scored among the top 25% of our sample.

 
38-40 You scored among the top 50% of our sample.

 
34-37 You scored among the top 75% of our sample.

 
1-34 You scored in the bottom 25% of our sample.

 
\n"; print "In our research we correlated people's gratitude scores with their scores on standard measures of psychological health. We found that compared to their less grateful counterparts, grateful people are higher in positive emotions and life satisfaction, and lower in negative emotions such as depression, anxiety, and envy. They also appear to be more socially oriented - they are more empathic, forgiving, helpful, and supportive than are their less grateful counterparts. In addition, grateful people are less focused on material goals. Finally, people with stronger dispositions toward gratitude tend to be more spiritually and religiously minded. They score higher not only on measures of traditional religiousness, but also on nonsectarian measures of spirituality that assess spiritual experiences (such as a sense of contact with a divine power) and sentiments (such as the belief that all living things are connected).\n"; print "

\n"; print "If you scored low - or simply would like to score higher - on the gratitude scale, feel grateful. Why? Our research suggests that this beneficial emotional state can be learned and nurtured. A low score means that some simple practices will likely make you happier and healthier.\n"; print "

\n"; print "Read more about gratitude: \n"; print "
\n"; print "

  • Giving Thanks for All the Little (and Big) Things in Life \n"; print "
  • The Joy of Thanks

    \n"; if ($usessi == 0) { &footer; } }