/* {{{ proto bool survey_render(int survey_id, int section, int resonse_id, string message) Reads current form variables from $_POST. Builds HTML for the survey (prefixed w/ message). */ function survey_render($sid, $section = 1, $rid=0, $message = '') { //global $_POST; @reset($_POST); if(empty($section)) $section = 1; // load survey title (and other globals) $sql = "SELECT * FROM ".$GLOBALS['ESPCONFIG']['survey_table']." WHERE id=${sid}"; $result = execute_sql($sql,"",ADODB_FETCH_ASSOC); if(record_count($result) != 1) return(false); $survey = fetch_row($result); db_close($result); $sections = survey_get_sections($sid); $num_sections = count($sections); if($section-- > $num_sections) return(false); // invalid section $section_questions = survey_get_section_questions($sid); // load survey questions $sec_sql = array_to_insql($sections[$section]); $sql = "SELECT * FROM ".$GLOBALS['ESPCONFIG']['question_table']." WHERE id $sec_sql ORDER BY position,id"; $questions_result = execute_sql($sql,"",ADODB_FETCH_ASSOC); if(record_count($questions_result) < 1) return(false); // check to see if there are required questions $sql = "SELECT COUNT(*) FROM ".$GLOBALS['ESPCONFIG']['question_table']." WHERE id $sec_sql AND required='Y'"; $has_required = get_one($sql); // find out what question number we are on $i $i=0; for($j=0;$j<$section;$j++) $i += count($section_questions[$j]); ?>

1) { ?>

*'); ?>

MoveNext(); $i++; // process each question $qid = &$question['id']; $tid = &$question['type_id']; if ($tid == 100) { // this type should not increase the question number $i--; } #if (!question_conditioncheck($sid,$qid,$_POST['rid'])) { if (question_conditioncheck($sid,$qid,$rid)) { $questions_shown=1; question_render($question,$i,$survey['auto_num']); } elseif (isset($_POST['tab']) && ($_POST['tab']=="preview")) { // also show in preview $questions_shown=1; question_render($question,$i,$survey['auto_num']); } } if ($questions_shown==0) { print "

"; print(_('Sorry, no questions for you to answer in this section.')); print "



"; } ?>
1) { ?>