/* {{{ 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]); ?>
*'); ?>