tag in each pass.
Important note: We have to attend carefully to data that are
USER created vs. PROGRAMMER created.
Reading in CGI data that comes from the user's input is easy: We simply
use the $_POST global to extract the information from the data packed and
pass it along in a hidden tag. If the information is there, we're done. If it
isn't there, no harm; no foul.
With PROGRAMMER created data (e.g., things, like pass, that are hidden), however,
we have to be sure that we manually pass it along the first time it is created. We can
still include such variables in our passhidden() function, but we must make sure we
manually pass them forward as hidden tags the first time they come into existence. Until
they are available to the CGI data packet, the function as written below will not be
able to operate upon them.
------------------------------------------------------------------------------------
*/
function passhidden(){
// hidden VARIABLES
print " \n";
print " \n";
print " \n";
print " \n";
print " \n";
print " \n";
print " \n";
// hidden ARRAYS
// Note: We have to use isset to see if the array exists otherwise the foreach loop
// will generate an error.
if(isset($_POST['item_index']) | $isset){
foreach ($_POST['item_index'] as $key => $value){
echo ' ';
print " \n";
}
}
}
/*
Here are some arrays we could, theoretically, want access to at any stage of the game.
Thus, let's initialize them here and do so fresh on each pass rather than passing
them forward as hidden tags. (In general, if there is no need to pass data via hidden tags, then
don't do it.)
*/
$item_content = array("tired","hungry","anxious","sad","excited"); // The content/items to be presented
$item_names = array("v01","v02","v03","v04","v05"); // The variable names that will be associated with each item
$number_of_items = count($item_names); // How many items/trials are there?
$max_index = $number_of_items - 1; // Let's take 1 minus the above
/*
If pass == 1, then that signals to us that the user should
receive whatever information we want to display on the
FIRST VISIT (e.g., consent information, overview of study).
*/
// Pass = 1
if($pass == 1){
/*
In addition to presenting a greeting on the first page(pass),
we are also going to decide at this moment the random order
in which the stimuli/items will be presented.
We will do so by
- creating an array that contains an index for each
item (i.e., its place in the array file drawer).
- shuffling/randomizing the order of that array
- using that shuffled array to index the actual items (and their NAMEs)
- Finally, we preserve that random order by passing it forward as hidden data
*/
$item_index = range(0,$max_index);
print "The original index of items is ";
foreach ($item_index as $key => $value){
print "$key --> $value ";
}
shuffle($item_index);
print "The randomized index of items is ";
foreach ($item_index as $key => $value){
print "$key --> $value ";
}
print "
Hello! Welcome to my website.
Please tell me your name.
";
} // End pass == 1
/*
If pass>= 1 AND <= 7, then let's present the trials or items.
Each time through, we increment pass by a value of 1.
Thus, we end the "loop" once pass is 8 or higher.
*/
// We're going to skip the instructions this time, so setting $pass <= 6 instead of <= 7
if($pass >= 2 AND $pass <= 6){
print "
";
} // End if($pass >= 2 OR $pass <= 6)
if($pass == 7){
if($v01 == 1){
$message = "
Hope you're feeling more lively later today! Coffee helps.