#!C:/perl/bin/perl.exe
use CGI::Carp qw(fatalsToBrowser);
use CGI;
$query = new CGI;
$v01= $query->param('v01');
$v02= $query->param('v02');
$v03= $query->param('v03');
$v04= $query->param('v04');
$v05= $query->param('v05');
($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";
print $query->header;
print $query->start_html(-title=>'Thank You');
print "";
# Create a composite score (average the responses to all the items). Reverse key items 3 and 5.
$esteem = ($v01 + $v02 + (6-$v03) + $v04 + (6-$v05))/5;
$esteem2 = sprintf("%.2f",$esteem);
open(INFO, ">>$ENV{'DOCUMENT_ROOT'}/P593/form3.txt");
print INFO "$date1,$date2,$v01,$v02,$v03,$v04,$v05,$esteem2,endline\n";
close (INFO);
open(INFO, "$ENV{'DOCUMENT_ROOT'}/P593/form3.txt");
@data = ;
close(INFO);
print "Thank you for your participation. Your self-esteem score is $esteem2 on a scale ranging from 1 (low) to 5 (high).
";
print "The table below shows the self-esteem scores for other people in the sample.
";
print "";
print " Date | Time | Esteem Score |
";
$rowCount = 0;
foreach $key (@data) {
@a = split(/,/,$key);
if($rowCount == 0){
print " $a[0] | $a[1] | $a[7] |
";
$newrowCount = 1;
}
if($rowCount == 1){
print " $a[0] | $a[1] | $a[7] |
";
$newrowCount = 0;
}
$rowCount = $newrowCount;
}
print "
";
print $query->end_html;