";
}
print $query->end_html;
#This subroutine automates questionnaire generation
sub Questionnaire
{
#Stores questionnaire items
@items =
(
"The mind is equivalent to the brain",
"The mind is a non-physical property",
"It is impossible for science to ever have a complete understanding of the mind",
"My thoughts, personality, preferences, and choices are all just a product of my brain functions",
"Whether one is a good or bad person can be completely altered by changes in the brain",
"In the future, it may be possible to know exactly what another person is thinking by looking at their brain activity",
"People have a non-physical soul (or spirit) that animates the physical body",
"I believe the brain and soul are the same thing",
"I believe the mind and soul are the same thing",
"Free will is an illusion produced by the brain",
"The mind interacts with the brain, but is separate from brain",
"In the future, it may be possible to know someone's personality by looking at their brain activity",
"The true self is not governed by the brain, but by a person's soul"
);
#Prints each questionnaire item separately with radio buttons from 1 - 5
$item = 0;
@variables = ("v01","v02","v03","v04","v05","v06","v07","v08","v09","v10","v11","v12","v13");
foreach $variable (@items)
{
print "$item. $variable ";
print "Strongly Disagree";
print "";
print "";
print "";
print "";
print "";
print "Strongly Agree
";
++$item;
}
}
#This subroutine calculates the mean and standard deviation for a variable in the data set
sub results
{
#The first input indicates the file name to be opened
#The second input indicates which column in the data matrix will be used to find the sample average and standard deviation
$filename = $_[0];
$index = $_[1];
$fullfilename = "$ENV{'DOCUMENT_ROOT_OLD'}/www/heplerlabs.com/P593/" . $filename;
open(INFO, $fullfilename);
@data = ;
close(INFO);
#N is the number of non-zero entries in the column being averaged (i.e. the number of participants who actually responded to this questionnaire)
#sum is the sum of entries in the column being averaged
#ssdiff is the sum of squared differences between each entry in the column and the column average (i.e. ssdiff = SIGMA(xi - xbar)^2)
$N = 0;
$sum = 0;
$ssdiff = 0;
#Finds the cumulative sum and total N for the variable
foreach $row (@data)
{
@a = split(/,/,$row);
if($a[$index] > 0)
{
$N = ++$N;
$sum = $sum + $a[$index];
}
}
#Calculates the mean of the variable
if ($N > 0)
{
$mean = sprintf("%.2f",$sum/$N);
}
else
{
$mean = "The sample average cannot be computed because there are too few cases";
}
#Calculates the standard deviation of the variable
foreach $row (@data)
{
@b = split(/,/,$row);
if($b[$index] > 0)
{
$ssdiff = $ssdiff + (($b[$index] - $mean)*($b[$index] - $mean));
}
}
if ($N > 0)
{
$sd = sprintf("%.2f",sqrt((1/($N - 1))*$ssdiff));
}
else
{
$sd = "The sample standard deviation cannot be computed because there are too few cases";
}
#Returns the mean and standard deviation for the variable
return $mean;
return $sd;
}
#Calculates subject's mean for the questionnaire
sub subjectmean
{
#Stores the array length in N and initializes other variables for later use
$N = @_;
$validN = 0;
$sum = 0;
$mean = 0;
for($i = 0; $i <= ($N-1); ++$i)
{
if($_[$i] > 0)
{
$sum = $sum + $_[$i];
++$validN;
}
}
if($validN > 0)
{
$mean = sprintf("%.2f",$sum/$validN);
}
return $mean;
}
#Passes variables that the user has entered
sub passhidden
{
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
print "";
}