diff --git a/index.php b/index.php index 5f927fec902..e4dce2d7dbf 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ # > Author: Jason Cleeland # # > E-mail: jason@cleeland.org # # > Mail: Box 99, Trades Hall, 54 Victoria St, # - # > CARLTON SOUTH 3053, AUSTRALIA + # > CARLTON SOUTH 3053, AUSTRALIA # # > Date: 20 February 2003 # # # # This set of scripts allows you to develop, publish and # @@ -34,1437 +34,169 @@ ############################################################# */ -session_start(); - -if ($_GET['sid']) {$_SESSION['sid'] = $_GET['sid'];} -if ($_POST['sid']) {$_SESSION['sid'] = $_POST['sid'];} -$sid = $_SESSION['sid']; -if ($_GET['token']) {$_SESSION['token'] = $_GET['token'];} -if ($_POST['token']) {$_SESSION['token'] = $_POST['token'];} -$token = $_SESSION['token']; -if ($_GET['move']) {$move = $_GET['move'];} -if ($_POST['move']) {$move = $_POST['move'];} -if ($_POST['fvalue']) {$fvalue = $_POST['fvalue'];} -if ($_POST['fvalue1']) {$fvalue1 = $_POST['fvalue1'];} -if ($_POST['multi']) {$multi = $_POST['multi'];} -if ($_POST['thisstep']) {$thisstep = $_POST['thisstep'];} -//$thisstep = $_POST['thisstep']; if (!$thisstep) {$thisstep=$_SESSION['thisstep'];} -#$totalsteps = $_SESSION['totalsteps']; -#$fieldarray = $_SESSION['fieldarray']; -#$insertarray = $_SESSION['insertarray']; -if ($_POST['lastgroupname']) {$lastgroupname = $_POST['lastgroupname'];} -if ($_POST['newgroup']) {$newgroup = $_POST['newgroup'];} -if ($_POST['lastfield']) {$lastfield = $_POST['lastfield'];} - -if ($move == "clearall" || $move == "here" || $move == "completed") - { - session_unset(); - session_destroy(); - } - -if ($fvalue || $fvalue == "0") - { - if ($fvalue == " ") - { - //$$lastfield = ""; - $_SESSION[$lastfield] = ""; - } - else - { - //$$lastfield = $fvalue; - $_SESSION[$lastfield] = $fvalue; - } - } - -if ($multi) - { - $myfields = explode("|", $lastfield); - $multimandatory="N"; - $j=0; - for ($i=1; $i<=$multi; $i++) - { - $mylist = "fvalue$i"; - $arrayno = $i-1; - $_SESSION[$myfields[$arrayno]] = $_POST[$mylist]; - //echo "$mylist -> " . $_POST[$mylist] ." -> " . $myfields[$arrayno] . " -> {$_SESSION[$myfields[$arrayno]]}
"; - //echo "$mylist: " . $_POST[$mylist] . " (session: " . $myfields[$arrayno] . ")
"; - if ($_POST[$mylist]) {$multimandatory="Y";} //if there are any answers, set this to true - if ($_POST[$mylist] && ($_POST['lasttype'] == "R" || $_POST['lasttype'] == "A" || $_POST['lasttype'] == "B" || $_POST['lasttype'] == "C")) - { - $j++; - } - } - if ($_POST['lasttype'] == "R" || $_POST['lasttype'] == "A" || $_POST['lasttype'] == "B" || $_POST['lasttype'] == "C") - { - //echo "$j == $i == $multi"; - if ($j == $multi) - { - $multimandatory="Y"; - } else { - $multimandatory="N"; - } - } - $mylist = substr($mylist, 0, strlen($mylist)-1); - } -//This section handles the question number that will be answered - moving backwards and forwards as required -if ($_POST['mandatory'] == "Y" && ($_POST['fvalue'] != "0" && !$_POST['fvalue'] || $_POST['fvalue'] == " ") && !$multimandatory) //if the last question was mandatory but there is no data - { - //Repeat last question until an answer is shown - if ($move == " last ") {$move = " next >> ";} //avoids going to submit if last question isn't answered - $repeatmandatory="Y"; //avoids repeating group description if this is the first question of a group (see group description section at top of else{}) - } -elseif ($_POST['mandatory'] == "Y" && $multi && $multimandatory != "Y") - { - if ($move == " last ") {$move = " next >> ";} - $repeatmandatory="Y"; //avoids repeating group description if this is the first question of a group - } -else - { - if ($move == " << prev " && $newgroup != "yes") {$_SESSION['step'] = $thisstep-1;} else {$_SESSION['step'] = $thisstep;} - if ($move == " next >> ") {$_SESSION['step'] = $thisstep+1;} - if ($move == " last ") {$_SESSION['step'] = $thisstep+1;} - } +session_start(); include("./admin/config.php"); -//if ($sid != $_GET['sid'] && $sid != $_POST['sid']){$sid = $_GET['sid'];} - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past -header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - // always modified +header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 +//DEFAULT SETTINGS FOR TEMPLATES +if (!$publicdir) {$publicdir=".";} +$tpldir="$publicdir/templates"; -echo "\n\n$sitename\n\n\n\n"; - -//FIRST, LETS HANDLE SOME CONTINGENCIES - -if (!$sid && (!$move == "clearall" || !$move=="here")) +//CHECK FOR REQUIRED INFORMATION (sid) +if (!$_GET['sid'] && !$_POST['sid']) { - echo "
$sitename
\n
\nYou cannot access this website without a valid Survey ID code.
\n"; - echo "
\nPlease contact $siteadminemail for information."; - echo "\n"; - exit; - } - -if (!mysql_selectdb ($databasename, $connect)) - { - echo "
$sitename
\n
\nERROR

\n
\n"; - echo "This system has not yet been installed properly.
\n"; - echo "Contact your $siteadminemail for information"; - echo "\n"; - exit; - } - -// NOW LETS GATHER SOME INFORMATION ABOUT THIS PARTICULAR SURVEY (This happens on every page) -if ($sid && $move != "clearall" && $move != "completed") - { - $desquery = "SELECT * FROM surveys WHERE sid=$sid"; - $desresult = mysql_query($desquery) or die ("Couldn't get survey with sid of $sid
$desquery
".mysql_error()); - $descount = mysql_num_rows($desresult); - while ($desr = mysql_fetch_array($desresult)) {$expirydate = $desr['expires'];} - if ($descount == 0) - { - echo "There is no survey with that SID. Sorry. [$descount][$desquery]"; - echo "\n"; - exit; - } - elseif ($expirydate < date("Y-m-d") && $expirydate != "0000-00-00") + //A nice crashout + $output=file("$tpldir/default/startpage.pstpl"); + foreach($output as $op) { - echo "
$sitename
\n
\nERROR

\n
\n"; - echo "Sorry. This survey has expired and is no longer available.
\n(Expiry date $expirydate)"; - echo "\n"; - exit; + echo templatereplace($op); } - $desresult = mysql_query($desquery); - while ($desrow = mysql_fetch_array($desresult)) + echo "\t\t

\n"; + echo "\t\t\tERROR:
\n"; + echo "\t\t\tYou have not provided a survey identification number.

\n"; + echo "\t\t\tPlease contact $siteadminname at $siteadminemail for further assistance.

\n"; + $output=file("$tpldir/default/endpage.pstpl"); + foreach($output as $op) { - $surveyname = $desrow['short_title']; - $surveydesc = $desrow['description']; - $surveyactive = $desrow['active']; - $surveytable = "survey_{$desrow['sid']}"; - $surveywelcome = $desrow['welcome']; - $surveyadminname = $desrow['admin']; - $surveyadminemail = $desrow['adminemail']; - $surveyprivate = $desrow['private']; - $surveyformat = $desrow['format']; + echo templatereplace($op); } - $surveyheader = "\n"; - $surveyheader .= "\t\n"; - $surveyheader .= "\t\t\n"; - $surveyheader .= "\t\n"; - - //LETS SEE IF THERE ARE TOKENS FOR THIS SURVEY - $i = 0; $tokensexist = 0; - $tresult = @mysql_list_tables($databasename); - while($tbl = @mysql_tablename($tresult, $i++)) - { - if ($tbl == "tokens_$sid") {$tokensexist = 1;} - } - } - -//THIS CLEARS ALL DATA WHEN CLEARALL OR FINISH HAS BEEN CHOSEN -if ($move == "clearall" || $move == "here") - { - $fieldname = ""; - $_SESSION['fieldarray'] = ""; - $_SESSION['step'] = ""; - $_SESSION['totalsteps'] = ""; - $_SESSION['token'] = ""; - echo "
\n 
\n"; - echo "
All data has been deleted.
\n 
\n"; - echo "Close
\n
\n 
\n"; - echo "\n"; - exit; - } - - -// This is the LAST POINT. The survey is completed and saved and now we're just letting the user close the window -if ($move == "completed") - { - echo "
\n"; - $surveyheader .= "\t\t\t$surveyname
\n"; - $surveyheader .= "\t\t\t$surveydesc\n"; - $surveyheader .= "\t\t
\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "
\n"; - echo "\t\t\t$sitename
\n"; - echo "\t\t\t \n"; - echo "\t\t
\n"; - echo "\t\t\t$setfont
\nThis is the \"$sitename\" Survey site.
\n"; - echo "\t\t\t
\n"; - echo "\t\t\tClose Window
\n"; - echo "\t\t\t
\n"; - echo "\t\t
\n"; - echo "\n"; exit; } -// Here we present the user with the option to submit their responses and provide general information about stopping, and privacy (if appropriate) -if ($move == " last ") - { - submit($surveyheader, $_SESSION['step'], $_SESSION['totalsteps'], $sid, $setfont, $surveyprivate); - exit; - } - -//THIS IS THE SECOND LAST POINT. HERE, WE GATHER ALL THE SESSION VARIABLES AND INSERT THEM INTO THE DATABASE. -if ($move == " submit ") - { - echo "$surveyheader"; - //echo $surveyactive; - echo "\t\n"; - echo "\t\t
\n"; - echo "\t\t\t
 
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - $subquery = "INSERT INTO $surveytable "; - foreach ($_SESSION['insertarray'] as $value) - { - $col_name .= ", " . substr($value, 1); //Add separator and strip off leading 'F' - if (get_magic_quotes_gpc() == "0") - { - if (phpversion() >= "4.3.0") - { - $values .= ", '" . mysql_real_escape_string($_SESSION[$value], "'") . "'"; - } - else - { - $values .= ", '" . mysql_escape_string($_SESSION[$value]) . "'"; - } - } - else - { - $values .= ", '" . $_SESSION[$value] . "'"; - } - //echo "$value
\n"; //Debugging info +//GET BASIC INFORMATION ABOUT THIS SURVEY +$sid=$_GET['sid']; if (!$sid) {$sid=$_POST['sid'];} +$query="SELECT * FROM surveys WHERE sid=$sid"; +$result=mysql_query($query) or die ("Couldn't access surveys
$query
".mysql_error()); +$surveyexists=mysql_num_rows($result); +while ($row=mysql_fetch_array($result)) + { + $surveyname=$row['short_title']; + $surveydescription=$row['description']; + $surveywelcome=$row['welcome']; + $templatedir=$row['template']; + $surveyadminname=$row['admin']; + $surveyadminemail=$row['adminemail']; + $surveyactive = $row['active']; + $surveyexpiry = $row['expires']; + $surveyprivate = $row['private']; + $surveytable = "survey_{$row['sid']}"; + $surveyurl = $row['url']; + $surveyurldescrip = $row['urldescrip']; + $surveyformat = $row['format']; + } + +//SET THE TEMPLATE DIRECTORY +if (!$templatedir) {$thistpl=$tpldir."/default";} else {$thistpl=$tpldir."/$templatedir";} +if (!is_dir($thistpl)) {$thistpl=$tpldir."/default";} +//CLEAR SESSION IF REQUESTED +if ($_GET['move'] == "clearall") + { + echo "\n"; + foreach(file("$thistpl/startpage.pstpl") as $op) + { + echo templatereplace($op); + } + echo "\t
\n"; + echo "\t
\n"; - echo "\t\t\t\t\t\t
Results are being submitted...

\n"; - echo "\t\t\t\t\t
\n"; + echo "\t
\n"; + echo "\t\t\n"; + echo "\t\tAnswers Cleared.

"; + echo "Restart This Survey
\n"; + echo "\t\tClose Window\n"; + echo "\t\t
\n"; + echo "\t
\n\t
\n"; + foreach(file("$thistpl/endpage.pstpl") as $op) + { + echo templatereplace($op); } - $col_name = substr($col_name, 2); //Strip off first comma & space - $values = substr($values, 2); //Strip off first comma & space - $subquery .= "\n($col_name) \nVALUES \n($values)"; - //echo "
$subquery
\n"; //Debugging info - if ($surveyactive == "Y") - { - $subresult = mysql_query($subquery) or die ("
\n\n\n\nCouldn't update $surveytable
\n".mysql_error()."
\n
$subquery
\n"); - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t
Thank you!
\n"; - echo "\t\t\t\t\t\tResults have been successfully updated.
 \n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - if ($token) - { - $utquery = "UPDATE tokens_$sid SET completed='Y' WHERE token='$token'"; - $utresult = mysql_query($utquery) or die ("Couldn't update tokens table!
\n$utquery
\n".mysql_error()); - - //MAIL CONFIRMATION TO PARTICIPANT - $cnfquery = "SELECT * FROM tokens_$sid WHERE token='$token' AND completed='Y'"; - $cnfresult = mysql_query($cnfquery); - while ($cnfrow = mysql_fetch_array($cnfresult)) - { - $headers = "From: $surveyadminemail\r\n"; - $headers .= "X-Mailer: $sitename Email Inviter"; - $to = $cnfrow['email']; - $subject = "Confirmation: $surveyname Survey Completed"; - $message = "Dear {$cnfrow['firstname']},\n\n"; - $message .= "This email is to confirm that you have completed the survey titled \"$surveyname\" "; - $message .= "and your response has been saved. Thank you for participating.\n\n"; - if ($surveyprivate != "N") - { - $message .= "Please note that your survey submission does not contain any link to your personal "; - $message .= "information used to send you this confirmation or the original invitation.\n"; - $message .= "The information you submitted in the survey is anonymous unless a question in the "; - $message .= "survey itself actually asks for such information.\n\n"; - } - else - { - //just in case we want to add info about it not being private - } - $message .= "If you have any questions about this survey please contact $surveyadminname on "; - $message .= "$surveyadminemail.\n\n"; - $message .= "Sincerely,\n\n"; - $message .= "$surveyadminname"; - if ($cnfrow['email']) {mail($to, $subject, $message, $headers);} //Only send confirmation email if there is an email address - } - } - } - else - { - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t
Sorry!
\n"; - echo "\t\t\t\t\t\tCould not submit results - survey has not been activated
 \n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - // debugging info - echo "\n"; - // end debugging info - } - echo "\t\t\t\n"; - echo "\t\t\t

Finish

\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\n"; + session_unset(); + session_destroy(); + exit; + } + +//CALL APPROPRIATE SCRIPT +switch ($surveyformat) + { + case "A": //All in one + include("survey.php"); + break; + case "S": //One at a time + include("question.php"); + break; + case "G": //Group at a time + include("group.php"); + break; + default: + include("question.php"); + } + +function templatereplace($line) + { + global $surveyname, $surveydescription; + global $surveywelcome, $percentcomplete; + global $groupname, $groupdescription, $question; + global $questioncode, $answer, $navigator; + global $help, $totalquestions; + global $completed, $surveyurl, $surveyurldescrip; + global $notanswered, $privacy, $sid; - // debugging info - echo "\n"; - // end debugging info - echo "\n"; - exit; - } -// THIS IS FOR WHEN THE SURVEY SCRIPTS AND STUFF HAVEN'T STARTED YET -if (!$_SESSION['step']) - { - if ($tokensexist == 1 && !$_GET['token']) + if (ereg("^$sitename
\n
\nYou cannot access this website without a valid token.
\n"; - echo "Tokens are issued to invited participants. If you have been invited to participate in this
\n"; - echo "survey but have not got a token, please contact $siteadminemail for information.
\n "; - echo "\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "
\n"; - echo "\t\t\tIf you have been issued a token, please enter it here to proceed:
\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t
\n"; - echo "\n"; - exit; - } - if ($tokensexist == 1 && $_GET['token']) - { - //check if token actually does exist - $tkquery = "SELECT * FROM tokens_$sid WHERE token='{$_GET['token']}' AND completed != 'Y'"; - $tkresult = mysql_query($tkquery); - $tkexist = mysql_num_rows($tkresult); - if ($tkexist > 0) + if (!ereg("^checkconditions()", $line) && ($_SESSION['step'] || $_SESSION['step'] > 0) && ($_POST['move'] != " last " || ($_POST['move'] == " last " && $notanswered)) && ($_POST['move'] != " submit " || ($_POST['move']== " submit " && $notanswered))) { -# session_register("token"); //No need to register $token as long as it's passed via GET - } - else - { - echo "
$sitename
\n
\nThe token you have submitted has either been used or does not exist.
\n"; - echo "Tokens are issued to invited participants. If you have been invited to participate in this
\n"; - echo "survey but your token has failed, please contact $siteadminemail for more information.
\n "; - echo "\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "
\n"; - echo "\t\t\tIf you have been issued a token, please enter it here to proceed:
\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t
\n"; - echo "\n"; - exit; + $line=str_replace("\n"; - echo "\t\n"; - echo "\t\t$sitename\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\tWelcome\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t 
\n"; - echo "\t\t\t$surveyname
\n"; - //echo "\t\t\t$setfont$surveydesc
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\t\t\t$setfont
$surveywelcome
 \n"; - echo "\t\t\t\t\t
\n"; - echo "\t\t\tClick \"Next\" to begin.
 \n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t
\n"; - echo "\t\n"; - echo "\t\n"; - - $aquery = "SELECT * FROM questions, groups WHERE questions.gid=groups.gid AND questions.sid=$sid ORDER BY group_name"; - $aresult = mysql_query($aquery); - $_SESSION['totalsteps'] = mysql_num_rows($aresult); - if ($_SESSION['totalsteps'] == "0") //break out and crash if there are no questions! - { - echo "\t\n"; - echo "\t\t\n"; - echo "$setfont
$sitename
\n
\nThis survey does not yet have any questions, and so cannot be accessed.
\n"; - echo "
\nPlease contact $siteadminemail for information.

\n"; - echo "Close Window\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\n"; - echo "\n"; - exit; - } + $line=str_replace("{SURVEYNAME}", $surveyname, $line); + $line=str_replace("{SURVEYDESCRIPTION}", $surveydescription, $line); + $line=str_replace("{WELCOME}", $surveywelcome, $line); + $line=str_replace("{PERCENTCOMPLETE}", $percentcomplete, $line); + $line=str_replace("{GROUPNAME}", $groupname, $line); + $line=str_replace("{GROUPDESCRIPTION}", $groupdescription, $line); + $line=str_replace("{QUESTION}", $question, $line); + $line=str_replace("{QUESTION_CODE}", $questioncode, $line); + $line=str_replace("{ANSWER}", $answer, $line); + $line=str_replace("{NUMBEROFQUESTIONS}", $totalquestions, $line); + if ($help) + {$line=str_replace("{QUESTIONHELP}", "".$help, $line);} else - { - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\t$setfont There are {$_SESSION['totalsteps']} questions in this survey.\n"; - echo "\t\t\n"; - echo "\t\n"; - } - - echo "\t\n"; - echo "\t\t\n"; - - $arows = array(); //Create an empty array in case mysql_fetch_array does not return any rows - while ($arow = mysql_fetch_assoc($aresult)) {$arows[] = $arow;} // Get table output into array - - // Perform a case insensitive natural sort on group name then question title of a multidimensional array - usort($arows, 'CompareGroupThenTitle'); - - if (!$_SESSION['insertarray']) - { - if ($surveyprivate == "N") - { - # session_register("Ftoken"); - # $Ftoken=$token; - $_SESSION['Ftoken'] = $token; - $_SESSION['insertarray'][]= "Ftoken"; - } - - foreach ($arows as $arow) - { - //WE ARE CREATING A SESSION VARIABLE FOR EVERY FIELD IN THE SURVEY - $fieldname = "{$arow['sid']}X{$arow['gid']}X{$arow['qid']}"; - if ($arow['type'] == "M" || $arow['type'] == "A" || $arow['type'] == "B" || $arow['type'] == "C" || $arow['type'] == "P") - { - $abquery = "SELECT answers.*, questions.other FROM answers, questions WHERE answers.qid=questions.qid AND sid=$sid AND questions.qid={$arow['qid']} ORDER BY answers.code"; - $abresult = mysql_query($abquery); - while ($abrow = mysql_fetch_array($abresult)) - { - $_SESSION['insertarray'][] = "F$fieldname".$abrow['code']; - $alsoother = ""; - if ($abrow['other'] == "Y") {$alsoother = "Y";} - if ($arow['type'] == "P") - { - $_SESSION['insertarray'][] = "F$fieldname".$abrow['code']."comment"; - } - } - if ($alsoother) - { - $_SESSION['insertarray'][] = "F$fieldname"."other"; - if ($arow['type'] == "P") - { - $_SESSION['insertarray'][] = "F$fieldname"."othercomment"; - } - } - } - elseif ($arow['type'] == "R") - { - $abquery = "SELECT answers.*, questions.other FROM answers, questions WHERE answers.qid=questions.qid AND sid=$sid AND questions.qid={$arow['qid']} ORDER BY answers.code"; - $abresult = mysql_query($abquery); - $abcount = mysql_num_rows($abresult); - for ($i=1; $i<=$abcount; $i++) - { - $_SESSION['insertarray'][] = "F$fieldname".$i; - } - } - elseif ($arow['type'] == "O") - { -# session_register("F$fieldname"); - $_SESSION['insertarray'][] = "F$fieldname"; - $fn2 = "F$fieldname"."comment"; -# session_register("$fn2"); - $_SESSION['insertarray'][] = "$fn2"; - - } - else - { -# session_register("F$fieldname"); - $_SESSION['insertarray'][] = "F$fieldname"; - } - - //Check to see if there are any conditions set for this question - if (conditionscount($arow['qid']) > 0) - { - $conditions = "Y"; - } else { - $conditions = "N"; - } - //echo "F$fieldname, {$arow['title']}, {$arow['question']}, {$arow['type']}
\n"; //MORE DEBUGGING STUFF - //NOW WE'RE CREATING AN ARRAY CONTAINING EACH FIELD AND RELEVANT INFO - //ARRAY CONTENTS - [0]=questions.qid, [1]=fieldname, [2]=questions.title, [3]=questions.question - // [4]=questions.type, [5]=questions.gid, [6]=questions.mandatory, [7]=conditionsexist? - - $_SESSION['fieldarray'][] = array("{$arow['qid']}", "$fieldname", "{$arow['title']}", "{$arow['question']}", "{$arow['type']}", "{$arow['gid']}", "{$arow['mandatory']}", $conditions); - } - } - //echo count($_SESSION['fieldarray']); - echo "\t\t\n"; - echo "\t\n"; - //$_SESSION['step'] = 1; - } - -else - { - $s = $_SESSION['step']; - //$t indicates which question in the array we should be displaying - $t = $s-1; - $v = $t-1; - $u = $_SESSION['totalsteps']; - $chart = (($s-1)/$u*100); - - // CHECK FOR CONDITIONS. This will keep cycling through questions until it finds a question where the conditions are not met - $conditionforthisquestion=$_SESSION['fieldarray'][$t][7]; - while ($conditionforthisquestion == "Y") - { - //There are conditions for this question, so lets see whether they are met: - //First lets make sure we haven't started a new group - $gdquery = "SELECT group_name, groups.description FROM groups, questions WHERE groups.gid=questions.gid and qid={$_SESSION['fieldarray'][$t][0]}"; - $gdresult = mysql_query($gdquery); - while ($gdrow = mysql_fetch_array($gdresult)) - { - $currentgroupname = $gdrow['group_name']; - $groupdescription = $gdrow['description']; - } - if ($_SESSION['fieldarray'][$t][5] != $_SESSION['fieldarray'][$v][5] && $newgroup != "yes" && $groupdescription && $move != " << prev " && !$repeatmandatory) - { - //If a new group is starting, just go to the group description if there is one. - $conditionforthisquestion="N"; - } - else - { - $cquery="SELECT distinct cqid FROM conditions WHERE qid={$_SESSION['fieldarray'][$t][0]}"; - $cresult=mysql_query($cquery) or die("Couldn't count cqids
$cquery
".mysql_error()); - $cqidcount=mysql_num_rows($cresult); - $cqidmatches=0; - while ($crows=mysql_fetch_array($cresult)) - { - //cycle through each distinct cqid - $qquery="SELECT qid FROM conditions WHERE qid={$_SESSION['fieldarray'][$t][0]} AND cqid={$crows['cqid']}"; - $qresult=mysql_query($qquery) or die("Couldn't count conditions for this cqid
$qquery
".mysql_error()); - $cconcount[$crows['cqid']]=mysql_num_rows($qresult); - //See if either of the conditions in this cqid match - $cqquery = "SELECT cfieldname, value, cqid FROM conditions WHERE qid={$_SESSION['fieldarray'][$t][0]} AND cqid={$crows['cqid']}"; - $cqresult = mysql_query($cqquery) or die("Couldn't get conditions for this question/cqid
$cquery
".mysql_error()); - $amatchhasbeenfound="N"; - while ($cqrows=mysql_fetch_array($cqresult)) - { - $currentcqid=$cqrows['cqid']; - $conditionfieldname="F".$cqrows['cfieldname']; - if (!$cqrows['value']) {$conditionvalue="NULL";} else {$conditionvalue=$cqrows['value'];} - if (!$_SESSION[$conditionfieldname]) {$currentvalue="NULL";} else {$currentvalue=$_SESSION[$conditionfieldname];} - if ($currentvalue == $conditionvalue) {$amatchhasbeenfound="Y";} - } - if ($amatchhasbeenfound == "Y") {$cqidmatches++;} - } - if ($cqidmatches == $cqidcount) - { - //a match has been found in BOTH distinct cqids. The question WILL be displayed - $conditionforthisquestion="N"; - } - else - { - //matches have not been found in BOTH distinct cqids. The question WILL NOT be displayed - echo "\n"; - if ($move == " next >> ") - { - $_SESSION['step']++; - $s = $_SESSION['step']; - $t++; - $v++; - $chart = (($s-1)/$u*100); - if ($t == $u) - { - //The last question was conditional and has been skipped. Move into panic mode. - $conditionforthisquestion="N"; - submit($surveyheader, $_SESSION['step'], $_SESSION['totalsteps'], $sid, $setfont, $surveyprivate); - exit; - } - } - elseif ($move == " << prev ") - { - $_SESSION['step']--; - $s = $_SESSION['step']; - $t--; - $v--; - $chart = (($s-1)/$u*100); - } - $conditionforthisquestion=$_SESSION['fieldarray'][$t][7]; - } - } - } - - echo $surveyheader; - //echo "STEP: $_SESSION['step'], TOTALSTEPS: {$_SESSION['totalsteps']}, LASTFIELD: $lastfield"; - echo "\n"; - - // GET AND SHOW GROUP NAME - $gdquery = "SELECT group_name, groups.description FROM groups, questions WHERE groups.gid=questions.gid and qid={$_SESSION['fieldarray'][$t][0]}"; - $gdresult = mysql_query($gdquery); - while ($gdrow = mysql_fetch_array($gdresult)) - { - $currentgroupname = $gdrow['group_name']; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\t$setfont$currentgroupname\n"; - echo "\t\t\n"; - echo "\t\n"; - $groupdescription = $gdrow['description']; - } - - //if (($currentgroupname != $lastgroupname) && ($move != " << prev ")) - //SHOWS GROUP DESCRIPTION AT BEGINNING OF A GROUP - if ($_SESSION['fieldarray'][$t][5] != $_SESSION['fieldarray'][$v][5] && $newgroup != "yes" && $groupdescription && $move != " << prev " && !$repeatmandatory) - { - $presentinggroupdescription = "yes"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\t\t\t$setfont
$groupdescription
 \n"; - echo "\t\t\t\t\t
\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - } - else - { - // SHOW % CHART - echo "\t\n";; - echo "\t\t$setfont\n"; - - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
0%100%
\n"; - - echo "\t\t\n"; - echo "\t\n"; - - - // PRESENT QUESTION - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - - // QUESTION STUFF - echo "\t\n"; - echo "\t\t\n"; - echo "\n"; - echo "\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - $fname = "F".$_SESSION['fieldarray'][$t][1]; - - // THE FOLLOWING PRESENTS THE QUESTION BASED ON THE QUESTION TYPE - switch ($_SESSION['fieldarray'][$t][4]) - { - case "5": //5 POINT CHOICE radio-buttons - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - - - //SHOW HELP INFORMATION IF THERE IS ANY - $helpquery = "SELECT help FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $helpresult = mysql_query($helpquery); - while ($helprow = mysql_fetch_array($helpresult)) - { - if ($helprow['help']) - { - echo "\t\n"; - echo "\t\t\n"; - echo "\t\n"; - } - } - - echo "\t\n"; - echo "
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t
\n"; - echo "\t\t\t\n"; - echo nl2br($_SESSION['fieldarray'][$t][3])."\n"; - echo "\t\t\t\n"; - if ($_SESSION['fieldarray'][$t][6] == "Y") //question is mandatory: inform participant - { - echo "\t\t\t\n"; - //if ($_POST['mandatory'] == "Y" && ($_POST['fvalue']==" " || !$_POST['fvalue'])) //If we are repeating a question because it wasn't answered, tell the participant why - if ($repeatmandatory) - { - echo "\t\t\t
This is required information"; - if ($_POST['lasttype'] == "R" || $_POST['lasttype'] == "A" || $_POST['lasttype'] == "B" || $_POST['lasttype'] == "C") - {echo ". Please complete all sections.";} - echo "\n"; - } - } - echo "\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t
\n"; - echo "\t\t\t\n"; - for ($fp=1; $fp<=5; $fp++) - { - echo "\t\t\t$fp\n"; - } - break; - case "D": //DATE - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\t\t\tFormat: YYYY-MM-DD
\n"; - echo "\t\t\t\t\t\t(eg: 2003-12-25 for Christmas day)\n"; - echo "\t\t\t\t\t
\n"; - break; - case "L": //LIST drop-down/radio-button list - echo "\t
\n"; - echo "\t\t\t\n"; - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - if ($dropdowns == "L" || !$dropdowns) - { - echo "\t\t\t\n"; - } - elseif ($dropdowns == "R") - { - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
$setfont\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - echo "\t\t\t\t\t\t {$ansrow['answer']}
\n"; - } - if (!$_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\t No answer\n";} - elseif ($_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\t No answer\n";} - echo "\t\t\t\t\t
\n"; - } - break; - case "O": //LIST WITH COMMENT drop-down/radio-button list + textarea - echo "\t
\n"; - //echo "\t\t\t\n"; - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - $fname2 = $fname."comment"; - if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;} - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
$setfontChoose one of the following:$setfontPlease enter your comment here:
$setfont\n"; - - while ($ansrow=mysql_fetch_array($ansresult)) - { - echo "\t\t\t\t\t\t{$ansrow['answer']}
\n"; - } - if ($_SESSION['fieldarray'][$t][6] != "Y") - { - if (!$_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} - elseif ($_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} - } - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\t\t\t\n"; - $multifields = "$fname|$fname"."comment|"; - echo "\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t
\n"; - break; - case "R": //RANKING STYLE - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - echo "\t\t\t\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $answers[] = array($ansrow['code'], $ansrow['answer']); - } - - for ($i=1; $i<=$anscount; $i++) - { - $myfname=$fname.$i; - if ($_SESSION[$myfname]) - { - $existing++; - } - } - for ($i=1; $i<=$anscount; $i++) - { - $myfname = $fname.$i; - $multifields .= "$fname$i|"; - if ($_SESSION[$myfname]) - { - foreach ($answers as $ans) - { - if ($ans[0] == $_SESSION[$myfname]) - { - $thiscode=$ans[0]; - $thistext=$ans[1]; - } - } - } - $ranklist .= "\t\t\t\t\t\t $i: \n"; - $ranklist .= "\t\t\t\t\t\t\n"; - $ranklist .= "\t\t\t\t\t\t
\n"; - } - - $choicelist .= "\t\t\t\t\t\t\n"; - - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\tClick on an item in the list on the left, starting with your
"; - echo "\t\t\t\t\t\thighest ranking item, moving through to the last one."; - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\t\t\t$setfont     Your Choices:
\n"; - echo "    ".$choicelist; - echo "\t\t\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\t$setfont     Your Ranking:
\n"; - echo $ranklist; - echo "\t\t\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\tClick on the scissors next to each item on the right
"; - echo "\t\t\t\t\t\tto remove the last entry in your ranked list."; - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "M": //MULTIPLE OPTIONS checkbox - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
 \n"; - $qquery = "SELECT other FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $qresult = mysql_query($qquery); - while($qrow = mysql_fetch_array($qresult)) {$other = $qrow['other'];} - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - $fn = 1; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $myfname = $fname.$ansrow['code']; - $multifields .= "$fname{$ansrow['code']}|"; - echo "\t\t\t\t\t\t$setfont{$ansrow['answer']}
\n"; - $fn++; - } - $multifields = substr($multifields, 0, strlen($multifields)-1); - if ($other == "Y") - { - $myfname = $fname."other"; - echo "\t\t\t\t\t\tOther: \n"; - $multifields .= "|$fname"."other"; - $anscount++; - } - echo "\t\t\t\t\t
 
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "P": //MULTIPLE OPTIONS WITH COMMENTS checkbox + text - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
 \n"; - $qquery = "SELECT other FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $qresult = mysql_query($qquery); - while ($qrow = mysql_fetch_array($qresult)) {$other = $qrow['other'];} - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult)*2; - $fn = 1; - echo "\t\t\t\t\t\t\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $myfname = $fname.$ansrow['code']; - $myfname2 = $myfname."comment"; - $multifields .= "$fname{$ansrow['code']}|$fname{$ansrow['code']}comment|"; - echo "\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t\n"; - $fn++; - echo "\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\n"; - $fn++; - } - $multifields = substr($multifields, 0, strlen($multifields)-1); - if ($other == "Y") - { - $myfname = $fname."other"; - $myfname2 = $myfname."comment"; - $multifields .= "|$fname"."other|$fname"."othercomment"; - $anscount = $anscount + 2; - echo "\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t\n"; - $fn++; - echo "\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\n"; - } - echo "\t\t\t\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\t\t\t\t{$ansrow['answer']}\n"; - echo "\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\t\t\t\tOther:
\n"; - echo "\t\t\t\t\t\t\t\t
\n"; - echo "\t\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t
\n"; - echo "\t\t\t\t\t
 
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "N": //NUMERICAL QUESTION TYPE - echo keycontroljs(); - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t\tOnly numbers can be entered in this field\n"; - break; - case "S": //SHORT FREE TEXT - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "T": //LONG FREE TEXT - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "Y": //YES/NO radio-buttons - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\tYes
\n"; - echo "\t\t\t\t\t\tNo
\n"; - if ($_SESSION['fieldarray'][$t][6] != "Y") - { - echo "\t\t\t\t\t\tNo Answer
\n"; - } - echo "\t\t\t\t\t
\n"; - break; - case "G": //GENDER drop-down list - echo "\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
$setfont\n"; - echo "\t\t\t\t\t\tFemale
\n"; - echo "\t\t\t\t\t\tMale
\n"; - if ($_SESSION['fieldarray'][$t][6] != "Y") - { - echo "\t\t\t\t\t\tNo Answer\n"; - } - echo "\t\t\t\t\t
\n"; - //echo "\t\t\t\n"; - break; - case "A": //ARRAY (5 POINT CHOICE) radio-buttons - echo "\t
\n"; - $qquery = "SELECT other FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $qresult = mysql_query($qquery); - while($qrow = mysql_fetch_array($qresult)) {$other = $qrow['other'];} - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - $fn = 1; - echo "\t\t\t\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $myfname = $fname.$ansrow['code']; - $multifields .= "$fname{$ansrow['code']}|"; - if ($trbc == "#E1E1E1" || !$trbc) {$trbc = "#F1F1F1";} else {$trbc = "#E1E1E1";} - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - $fn++; - } - echo "\t\t\t
$setfont{$ansrow['answer']}"; - for ($i=1; $i<=5; $i++) - { - echo "\t\t\t\t\t$setfont$i \n"; - } - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "B": //ARRAY (10 POINT CHOICE) radio-buttons - echo "\t
\n"; - $qquery = "SELECT other FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $qresult = mysql_query($qquery); - while($qrow = mysql_fetch_array($qresult)) {$other = $qrow['other'];} - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - $fn = 1; - echo "\t\t\t\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $myfname = $fname.$ansrow['code']; - $multifields .= "$fname{$ansrow['code']}|"; - if ($trbc == "#E1E1E1" || !$trbc) {$trbc = "#F1F1F1";} else {$trbc = "#E1E1E1";} - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - $fn++; - } - echo "\t\t\t
$setfont{$ansrow['answer']}\n"; - for ($i=1; $i<=10; $i++) - { - echo "\t\t\t\t\t\t$setfont$i \n"; - } - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - case "C": //ARRAY (YES/UNCERTAIN/NO) radio-buttons - echo "\t
\n"; - $qquery = "SELECT other FROM questions WHERE qid=".$_SESSION['fieldarray'][$t][0]; - $qresult = mysql_query($qquery); - while($qrow = mysql_fetch_array($qresult)) {$other = $qrow['other'];} - $ansquery = "SELECT * FROM answers WHERE qid={$_SESSION['fieldarray'][$t][0]} ORDER BY code"; - $ansresult = mysql_query($ansquery); - $anscount = mysql_num_rows($ansresult); - $fn = 1; - echo "\t\t\t\n"; - while ($ansrow = mysql_fetch_array($ansresult)) - { - $myfname = $fname.$ansrow['code']; - $multifields .= "$fname{$ansrow['code']}|"; - if ($trbc == "#E1E1E1" || !$trbc) {$trbc = "#F1F1F1";} else {$trbc = "#E1E1E1";} - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - $fn++; - } - echo "\t\t\t
$setfont{$ansrow['answer']}\n"; - echo "\t\t\t\t\t\t$setfontYes \n"; - echo "\t\t\t\t\t\t$setfontUncertain \n"; - echo "\t\t\t\t\t\t$setfontNo \n"; - echo "\t\t\t\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\n"; - break; - } - - echo "\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
\n"; - echo "\t\t\t\t\t\tHelp for this question..\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t{$helprow['help']}
\n"; - echo "\t\t
\n"; - echo "\n"; - echo "\t\t\n"; - echo "\t\n"; - //echo "$token\n"; - } - } - -echo surveymover(); -echo "\t\n"; -echo "\t\n"; -if ($surveyactive != "Y") - { - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\t$setfontWarning: Survey Not Active. Your survey results will not be recorded.\n"; - echo "\t\t\n"; - echo "\t\n"; - } -echo "\n"; -echo "\n"; - -function surveymover() - { - global $presentinggroupdescription; - $surveymover = "\t\n"; - $surveymover .= "\t\t\n"; - $surveymover .= "\t\t\t\n"; - $surveymover .= "\t\t\t\t\n"; - $surveymover .= "\t\t\t\t\t\n"; - $surveymover .= "\t\t\t\t\n"; - $surveymover .= "\t\t\t
\n"; - if ($_SESSION['step'] > 0) - {$surveymover .= "\t\t\t\t\t\t\n";} - if ($_SESSION['step'] && (!$_SESSION['totalsteps'] || ($_SESSION['step'] < $_SESSION['totalsteps']))) - {$surveymover .= "\t\t\t\t\t\t";} - if (!$_SESSION['step']) - {$surveymover .= "\t\t\t\t\t\t";} - if ($_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps']) && $presentinggroupdescription == "yes") - {$surveymover .= "\t\t\t\t\t\t";} - if ($_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps']) && !$presentinggroupdescription) - {$surveymover .= "\t\t\t\t\t\t ";} - //if ($_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps']+1)) - //{$surveymover .= "\t\t\t\t\t\t";} - //$surveymover .= " X"; - $surveymover .= "\t\t\t\t\t
\n"; - $surveymover .= "\t\t\t[Exit and Clear Survey]\n"; - $surveymover .= "\t\t\n"; - $surveymover .= "\t\n"; - return $surveymover; - } - -function submit($surveyheader, $step, $totalsteps, $sid, $setfont, $surveyprivate) - { - echo $surveyheader; - $s = $step-1; - $t = $s-1; - $u = $totalsteps; - $chart = 105; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\tSurvey Complete
\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
0%100%
\n"; - echo "\t\t\n"; - echo "\t\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\t\n"; - echo "\t\t\n"; - echo "\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\t\n"; - echo "\t\t\t\t\n"; - echo "\t\t\t
 \n"; - echo "$setfont

Congratulations. You have completed answering
the questions in this survey.
\n"; - echo "

Click on \"Submit\" now to complete the process and submit your answers to our records. "; - echo "If you want to check any of the answers you have made, and/or change them, you can do that now by "; - echo "clicking on the \" << prev \" button and browsing through your responses.
\n"; - echo " 
\n"; - echo "
 \n"; - if ($surveyprivate != "N") - { - echo "\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t\t\n"; - echo "\t\t\t\t\t\t
\n"; - echo "$setfontA note on privacy
\n"; - echo "The record kept of your survey responses does not contain any identifying information about you unless "; - echo "a specific question in the survey has asked for this. If you have responded to a survey that "; - echo "used an identifying token to allow you to access the survey, you can rest assured that the "; - echo "identifying token is not kept with your responses. It is managed in a seperate database, and will "; - echo "only be updated to indicate that you have (or haven't) completed this survey. There is no way of "; - echo "matching identification tokens with survey responses in this survey.\n"; - echo "\t\t\t\t\t\t\t\t
\n"; - } - else - { - // Just in case we want to add a comment for non-private surveys - } - echo " 
\nIf you do not wish to submit responses to this survey, "; - echo "and you would like to delete
all the responses you have made, "; - echo "click here
 \n"; - //echo "\n"; - echo "\t\t\t\t\t

 
\n"; - echo "\t\t\n"; - echo "\t\n"; - echo surveymover(); - echo "\n"; - echo "\n"; + {$line=str_replace("{QUESTIONHELP}", $help, $line);} + $line=str_replace("{NAVIGATOR}", $navigator, $line); + $submitbutton=""; + $line=str_replace("{SUBMITBUTTON}", $submitbutton, $line); + $line=str_replace("{COMPLETED}", $completed, $line); + $line=str_replace("{URL}", "$surveyurldescrip", $line); + $line=str_replace("{PRIVACY}", $privacy, $line); + $line=str_replace("{CLEARALL}", $clearall, $line); + return $line; + } + +function makegraph($thisstep, $total) + { + global $thistpl, $templatedir, $publicurl; + $chart=$thistpl."/chart.jpg"; + if (!is_file($chart)) {$shchart="chart.jpg";} + else {$shchart = "$publicurl/templates/$templatedir/chart.jpg";} + $graph = "\n
\n"; + $graph .= "\n"; + $graph .= "\n"; + $size=($thisstep-1)/$total*100; + $graph .= "\n"; + $graph .= "\n"; + $graph .= "
0%$size% complete100%
\n"; + $graph .= "
\n"; + return $graph; } ?> \ No newline at end of file