/* {{{ proto string survey_report(int survey_id, bool details, string format) Build a description of a survey, including all unique ids. Rerturns an empty string on success, else an error message. */ function survey_report($sid, $details = 0, $format = '') { if(empty($sid)) return; $bg = ''; // build associative array holding weather each question // type has answer choices or not and the table the answers are in $has_choices = array(); $response_table = array(); $sql = 'SELECT id,has_choices,response_table FROM '.$GLOBALS['ESPCONFIG']['question_type_table'].' ORDER BY id'; if(!($result = execute_sql($sql))) { $errmsg = _('Error system table corrupt.') ." [ ". _('Table') .": question_type ]"; return($errmsg); } while($row = fetch_row($result)) { $result->MoveNext(); $has_choices[$row[0]]=$row[1]; $response_table[$row[0]]=$row[2]; } db_close($result); // load survey title (and other globals) $sql = "SELECT * FROM ".$GLOBALS['ESPCONFIG']['survey_table']." WHERE id=$sid"; if(!($result = execute_sql($sql,"",ADODB_FETCH_ASSOC))) { $errmsg = _('Error opening survey.') ." [ ID:${sid} R:" . record_count($result) ."]"; return($errmsg); } $survey = fetch_row($result); db_close($result); // load survey questions $sql = "SELECT * FROM ".$GLOBALS['ESPCONFIG']['question_table']." WHERE survey_id=$sid AND deleted='N' ORDER BY position"; if(!($questions_result = execute_sql($sql,"",ADODB_FETCH_ASSOC))) { $errmsg = _('Error opening survey.') .' '. _('No questions found.') ." [ ID:${sid} ]"; return($errmsg); } ?>

MoveNext(); // process each question $qid = &$question['id']; $tid = &$question['type_id']; $reqd = ($question['required'] == 'Y') ? _('Yes') : _('No'); $publ = ($question['public'] == 'Y') ? _('Yes') : _('No'); $table = &$response_table[$tid]; if($tid == 99) { echo("\n"); continue; } if($bg != '#ffffff') $bg = '#ffffff'; else $bg = '#eeeeee'; ?> MoveNext(); ?>