diff --git a/mod/questionnaire/locallib.php b/mod/questionnaire/locallib.php new file mode 100644 index 00000000000..2db58bad742 --- /dev/null +++ b/mod/questionnaire/locallib.php @@ -0,0 +1,2406 @@ +dirroot.'/mod/questionnaire/css/'; + + +require_once('questiontypes/questiontypes.class.php'); + +define ('QUESTIONNAIREDEFAULTNUMCHOICES', 10); + +class questionnaire { + +/// Class Properties + /** + * The survey record. + * @var object $survey + */ + var $survey; + +/// Class Methods + + /** + * The class constructor + * + */ + function questionnaire($id = 0, $questionnaire = null, &$course, &$cm, $addquestions = true) { + + if ($id) { + $questionnaire = get_record('questionnaire', 'id', $id); + } + + if (is_object($questionnaire)) { + $properties = get_object_vars($questionnaire); + foreach ($properties as $property => $value) { + $this->$property = $value; + } + } + + $this->add_survey($this->sid); + + $this->course = $course; + $this->cm = $cm; + + if ($addquestions) { + $this->add_questions($this->sid); + } + + $this->usehtmleditor = can_use_html_editor(); + } + + /** + * Fake constructor to keep PHP5 happy + * + */ + function __construct($id = 0, $questionnaire = null, &$course, &$cm, $addquestions = true) { + $this->questionnaire($id, $questionnaire, $course, $cm, $addquestions); + } + + /** + * Adding a survey record to the object. + * + */ + function add_survey($sid = 0, $survey = null) { + + if ($sid) { + $this->survey = get_record('questionnaire_survey', 'id', $sid); + } else if (is_object($survey)) { + $this->survey = clone($survey); + } + } + + /** + * Adding questions to the object. + */ + function add_questions($sid = false, $section = false) { + + if ($sid === false) { + $sid = $this->sid; + } + + $select = 'survey_id = '.$sid.' AND deleted != \'Y\''; + if ($records = get_records_select('questionnaire_question', $select, 'position')) { + $sec = 1; + foreach ($records as $record) { + $this->questions[$record->id] = new questionnaire_question(0, $record); +// if ($record->type_id != 100) { + if ($record->type_id != 99) { + $this->questionsbysec[$sec][$record->id] = &$this->questions[$record->id]; + } else { + $sec++; + } +// } + } + } + } + + function view() { + global $CFG, $USER, $QUESTIONNAIRE_STUDENTVIEWRESPONSE; + + if ($this->course->category) { + $navigation = "course->id\">$this->course->shortname ->"; + } + + print_header_simple($this->name, "", + ''.$this->strquestionnaires.' -> '. + $this->name, '', '', true, + update_module_button($this->cm->id, $this->course->id, $this->strquestionnaire), + navmenu($this->course, $this->cm)); + + if (isguest() && !$this->allows_guests()) { + print_heading(get_string("guestsno", "questionnaire")); + print_footer($this->course); + exit; + } + + $select = 'survey_id = '.$this->sid.' AND username = '.$USER->id; + if ($responses = get_records_select('questionnaire_response', $select, 'id DESC', 'id,complete')) { + $response = reset($responses); + } else { + $response->id = 0; + } + + echo '
| '; + echo ''; + echo ' | '; + + if (isteacher($this->course->id)) { + echo '';
+ if ($numresp = $this->count_submissions($USER->id)) {
+ $strviewresponses = get_string('viewyourresponses', 'questionnaire', $numresp);
+ echo ''.$strviewresponses.' '; + } + if ($this->is_survey_owner()) { + if ($numresp = $this->count_submissions()) { + $strviewresponses = get_string('viewresponses', 'questionnaire', $numresp); + echo ''.$strviewresponses.''; + } else { + echo get_string('noresponses', 'questionnaire'); + } + } + echo ' | ';
+ } else if ($this->resp_view == $QUESTIONNAIRE_STUDENTVIEWRESPONSE) {
+ echo '';
+ if ($numresp = $this->count_submissions($USER->id)) {
+ $strviewresponses = get_string('viewresponses', 'questionnaire', $numresp);
+ echo '';
+ } else {
+ echo ' '.get_string('noresponses', 'questionnaire').' '; + } + echo ' | ';
+
+ } else if (!$this->cm->visible) {
+ notice(get_string("activityiscurrentlyhidden"));
+ }
+
+ echo '
".print_r($course, true).print_r($cm, true).print_r($this, true).""; + + if (!$this->is_active()) { + print_string('notavail', 'questionnaire'); + } + else if (!$this->is_open()) { + print_string('notopen', 'questionnaire', userdate($this->opendate)); + } + else if ($this->is_closed()) { + print_string('closed', 'questionnaire', userdate($this->closedate)); + } + else if (!$this->user_is_eligible($USER->id)) { + print_string('noteligible', 'questionnaire'); + } + else if ($this->user_can_take($USER->id)) { + $sid=$this->sid; + + /// If the respondent type is set to fullname, pass the userid. + switch ($this->respondenttype) { + case 'fullname': + $quser = $USER->id; + break; + + /// If the respondent type is set to anonymous, hide the user's name. + case 'anonymous': + default: + $quser = 'Anonymous'; + break; + } + + if ($this->survey->realm == 'template') { + print_string('templatenotviewable', 'questionnaire'); + print_footer($this->course); + exit(); + } else if (!empty($this->survey->theme)) { + echo ''."\n"; + } + + $this->print_survey($USER->id, $quser); + + $viewform = data_submitted($CFG->wwwroot."/mod/questionnaire/view.php"); + + /// If Survey was submitted with all required fields completed ($msg is empty), + /// then record the submittal. + if (isset($viewform->submit) && isset($viewform->submittype) && + ($viewform->submittype == "Submit Survey") && empty($msg)) { + /// If its not an anonymous questionnaire, store the response id. + if ($this->respondenttype != 'anonymous') { + /// If it was a previous save, rid is in the form... + if (!empty($viewform->rid) && is_numeric($viewform->rid)) { + $rid = $viewform->rid; + + /// Otherwise its in this object. + } else { + $rid = $this->rid; + } + } else { + $rid = 0; + } + questionnaire_record_submission($this, $USER->id, $rid); + add_to_log($this->course->id, "questionnaire", "submit", "view.php?id=$this->cm->id", "$this->id", $this->cm->id, $USER->id); + } + + } else { + switch ($this->qtype) { + case QUESTIONNAIREDAILY: + $msgstring = ' '.get_string('today', 'questionnaire'); + break; + case QUESTIONNAIREWEEKLY: + $msgstring = ' '.get_string('thisweek', 'questionnaire'); + break; + case QUESTIONNAIREMONTHLY: + $msgstring = ' '.get_string('thismonth', 'questionnaire'); + break; + default: + $msgstring = ''; + break; + } + print_string("alreadyfilled", "questionnaire", $msgstring); + } + + /// Finish the page + if ($this->usehtmleditor) { + use_html_editor(); + } + print_footer($this->course); + } + + /** + * Function to view an entire responses data. + * + */ + function view_response($rid) { + global $CFG; + + if (!empty($this->survey->theme)) { + echo ''."\n"; + } + + print_simple_box_start(); + $this->print_survey_start('', 1, 1, 0); + + $data = new Object(); + $i = 1; + echo '
| + |
'.$this->survey->info.'+ '; + if($has_required) { + echo ' +
'. + get_string('requiredquestions', 'questionnaire', '*').'
'; + } + echo ' +\n";
+ $mail->SMTPDebug = true;
+ }
+ $mail->Host = "$CFG->smtphosts"; // specify main and backup servers
+
+ if ($CFG->smtpuser) { // Use SMTP authentication
+ $mail->SMTPAuth = true;
+ $mail->Username = $CFG->smtpuser;
+ $mail->Password = $CFG->smtppass;
+ }
+ }
+
+ $mail->Sender = $CFG->noreplyaddress;
+ $mail->From = $CFG->noreplyaddress;
+ $mail->FromName = $name;
+ $mail->Subject = $subject;
+ $mail->AddAddress($email);
+ $mail->WordWrap = 79; // set word wrap
+
+ $mail->IsHTML(true);
+ $mail->Encoding = "quoted-printable"; // Encoding to use
+ $mail->Body = $body;
+ $mail->AltBody = "\n$body\n";
+
+ if ($mail->Send()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function response_select_compact($rid, $qids = null) {
+ $res = $this->response_select($rid, 'type_id', $qids);
+ $cpq = array();
+ reset($res);
+ while(list($qid, $arr) = each($res)) {
+ if (strstr($qid, '_')) {
+ // rank or other
+ if ($arr[0] == 8) {
+ // rank
+ $cpq[] = array($qid, $arr[2], array($arr[1]));
+ } else {
+ // other
+ $cpq[] = array($qid, $arr[1]);
+ }
+ } elseif (is_array($arr[0])) {
+ // multiple
+ $cpq[] = array($qid,
+ array_map(create_function('$a', 'return $a[2];'), $arr),
+ array_map(create_function('$b', 'return $b[1];'), $arr));
+ } else {
+ if ($arr[0] == 4 || $arr[0] == 6)
+ $cpq[] = array($qid, $arr[2], array($arr[1]));
+ else
+ $cpq[] = array($qid, $arr[2]);
+ }
+ }
+ return $cpq;
+ }
+
+ function response_insert($sid, $section, $rid, $userid, &$formdata) {
+ global $CFG;
+
+ if(empty($rid)) {
+ // create a uniqe id for this response
+ $record = new object;
+ $record->survey_id = $sid;
+ $record->username = $userid;
+ $rid = insert_record('questionnaire_response', $record);
+ }
+
+ if (!empty($this->questionsbysec[$section])) {
+ foreach ($this->questionsbysec[$section] as $question) {
+ $question->insert_response($rid, $formdata);
+ }
+ }
+ return($rid);
+ }
+
+ function response_select($rid, $col = null, $qids = null) {
+ global $CFG;
+
+ $sid = $this->survey->id;
+ $values = array();
+
+ if ($col == null) {
+ $col = '';
+ }
+ if (!is_array($col) && !empty($col)) {
+ $col = explode(',', preg_replace("/\s/",'', $col));
+ }
+ if (is_array($col) && count($col) > 0) {
+ $col = ',' . implode(',', array_map(create_function('$a','return "q.$a";'), $col));
+ }
+
+ if ($qids == null) {
+ $qids = '';
+ } elseif (is_array($qids)) {
+ $qids = 'AND a.question_id ' . $this->array_to_insql($qids);
+ } elseif (intval($qids) > 0) {
+ $qids = 'AND a.question_id = ' . intval($qids);
+ } else {
+ $qids = '';
+ }
+
+ // --------------------- response_bool ---------------------
+ $sql = 'SELECT q.id '.$col.', a.choice_id '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_bool a, '.$CFG->prefix.'questionnaire_question q '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id '.$qids;
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $val = array_pop($row);
+ $values[$qid] = $row;
+ array_push($values["$qid"], ($val == 'Y') ? get_string('yes') : get_string('no'), $val);
+ }
+ }
+
+ // --------------------- response_single ---------------------
+ $sql = 'SELECT q.id '.$col.',c.content as ccontent,c.id as cid '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_single a, '.
+ $CFG->prefix.'questionnaire_question q, '.
+ $CFG->prefix.'questionnaire_question_choice c '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id AND a.choice_id=c.id '.$qids;
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $c = count($row);
+ $val = $row[$c - 2];
+ if (ereg('^!other', $val))
+ $row[$c - 1] = 'other_' . $row[$c - 1];
+ else
+ settype($row[$c - 1], 'integer');
+ $values[$qid] = $row;
+ }
+ }
+
+ // --------------------- response_multiple ---------------------
+ $sql = 'SELECT a.id as aid, q.id as qid '.$col.',c.content as ccontent,c.id as cid '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_multiple a, '.
+ $CFG->prefix.'questionnaire_question q, '.$CFG->prefix.'questionnaire_question_choice c '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id AND a.choice_id=c.id '.$qids.' '.
+ 'ORDER BY a.id,a.question_id,c.id';
+ $arr = array();
+ $tmp = null;
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ array_shift($row); // get rid of the answer id.
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $c = count($row);
+ $val = $row[$c - 2];
+ if (ereg('^!other', $val))
+ $row[$c - 1] = 'other_' . $row[$c - 1];
+ else
+ settype($row[$c - 1], 'integer');
+ if($tmp == $qid) {
+ $arr[] = $row;
+ continue;
+ }
+ if($tmp != null)
+ $values["$tmp"]=$arr;
+ $tmp = $qid;
+ $arr = array($row);
+ }
+ }
+ if($tmp != null)
+ $values["$tmp"]=$arr;
+ unset($arr);
+ unset($tmp);
+ unset($row);
+
+ // --------------------- response_other ---------------------
+ $sql = 'SELECT q.id,c.id as cid '.$col.',a.response as aresponse '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_other a, '.$CFG->prefix.'questionnaire_question q, '.
+ $CFG->prefix.'questionnaire_question_choice c '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id AND a.choice_id=c.id '.$qids.' '.
+ 'ORDER BY a.question_id,c.id';
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $cid = array_shift($row);
+ array_push($row, $row[count($row) - 1]);
+ $values["${qid}_${cid}"] = $row;
+ }
+ }
+
+ // --------------------- response_rank ---------------------
+ $sql = 'SELECT a.id as aid, q.id AS qid, c.id AS cid '.$col.',c.content as ccontent,a.rank as arank '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_rank a, '.
+ $CFG->prefix.'questionnaire_question q, '.
+ $CFG->prefix.'questionnaire_question_choice c '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id AND a.choice_id=c.id '.$qids.' '.
+ 'ORDER BY aid, a.question_id,c.id';
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hash and numeric keys for each value (2 per).
+ $row = (array)$row;
+ array_shift($row); // get rid of the answer id.
+
+ /// Next two are 'qid' and 'cid', each with numeric and hash keys.
+ $qid = array_shift($row);
+ array_shift($row);
+ $qid .= '_'.array_shift($row);
+ array_shift($row);
+
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ settype($row[count($row) - 1], 'integer');
+ $values[$qid] = $row;
+ }
+ }
+
+ // --------------------- response_text ---------------------
+ $sql = 'SELECT q.id '.$col.',a.response as aresponse '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_text a, '.$CFG->prefix.'questionnaire_question q '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id '.$qids;
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $values["$qid"]=$row;
+ $val = array_pop($values["$qid"]);
+ array_push($values["$qid"], $val, $val);
+ }
+ }
+
+ // --------------------- response_date ---------------------
+ $sql = 'SELECT q.id '.$col.',a.response as aresponse '.
+ 'FROM '.$CFG->prefix.'questionnaire_response_date a, '.$CFG->prefix.'questionnaire_question q '.
+ 'WHERE a.response_id=\''.$rid.'\' AND a.question_id=q.id '.$qids;
+ if ($records = get_records_sql($sql)) {
+ foreach ($records as $row) {
+ /// Change the data object into a numerically indexed array.
+ ///*** Because of the way the following code works, we need to remove the non-numeric keys of the array.
+ ///*** The problem is that the Moodle db calls returns hask and numeric keys for each value (2 per).
+ $row = (array)$row;
+ $qid = array_shift($row);
+ foreach ($row as $key => $val) {
+ if (!is_numeric($key)) unset($row[$key]);
+ }
+ $values["$qid"]=$row;
+ $val = array_pop($values["$qid"]);
+ array_push($values["$qid"], $val, $val);
+ }
+ }
+
+ // --------------------- return ---------------------
+ uksort($values, 'questionnaire_response_key_cmp');
+ return($values);
+ }
+
+ function response_goto_thankyou() {
+ global $CFG;
+
+ $select = 'id = '.$this->survey->id;
+ $fields = 'thanks_page,thank_head,thank_body';
+ if ($result = get_record_select('questionnaire_survey', $select, $fields)) {
+ $thank_url = $result->thanks_page;
+ $thank_head = $result->thank_head;
+ $thank_body = $result->thank_body;
+ } else {
+ $thank_url = '';
+ $thank_head = '';
+ $thank_body = '';
+ }
+ if(!empty($thank_url)) {
+ if(!headers_sent()) {
+ header("Location: $thank_url");
+ exit;
+ }
+ ?>
+
+
+
+
+
+ Return
+
+
+
+
+ survey->id.' AND complete = \'Y\'';
+ if ($userid !== false) {
+ $select .= ' AND username = \''.$userid.'\'';
+ }
+ if (!($responses = get_records_select('questionnaire_response', $select, 'id', 'id,survey_id'))) {
+ return;
+ }
+ $total = count($responses);
+
+ $rids = array();
+ $i = 0;
+ $curr_pos = -1;
+ foreach ($responses as $response) {
+ array_push($rids, $response->id);
+ if ($response->id == $curr_rid) {
+ $curr_pos = $i;
+ }
+ $i++;
+ }
+
+ $prev_rid = ($curr_pos > 0) ? $rids[$curr_pos - 1] : null;
+ $next_rid = ($curr_pos < $total - 1) ? $rids[$curr_pos + 1] : null;
+ $rows_per_page = 1;
+ $pages = ceil($total / $rows_per_page);
+
+ $url = $CFG->wwwroot.'/mod/questionnaire/report.php?where=results&sid='.$this->survey->id;
+
+ $mlink = create_function('$i,$r', 'return "$i";');
+
+ $linkarr = array();
+
+ $display_pos = 1;
+ if ($prev_rid != null) {
+ array_push($linkarr, "".get_string('previous', 'questionnaire').'');
+ }
+ for ($i = 0; $i < $curr_pos; $i++) {
+ array_push($linkarr, "$display_pos");
+ $display_pos++;
+ }
+ array_push($linkarr, "$display_pos");
+ for (++$i; $i < $total; $i++) {
+ $display_pos++;
+ array_push($linkarr, "$display_pos");
+ }
+ if ($next_rid != null)
+ array_push($linkarr, "".get_string('next', 'questionnaire').'');
+
+ ?>
+
+
+
+
+
+
+ 0) {
+ $cidstr = $this->array_to_insql($cids);
+ } else {
+ $cidstr = '';
+ }
+ }
+
+ // build associative array holding whether each question
+ // type has answer choices or not and the table the answers are in
+ /// TO DO - FIX BELOW TO USE STANDARD FUNCTIONS
+ $has_choices = array();
+ $response_table = array();
+ if (!($types = get_records('questionnaire_question_type', '', '', 'id', 'id,has_choices,response_table'))) {
+ $errmsg = sprintf('%s [ %s: question_type ]',
+ 'Error system table corrupt.', 'Table');
+ return($errmsg);
+ }
+ foreach ($types as $type) {
+ $has_choices[$type->id]=$type->has_choices;
+ $response_table[$type->id]=$type->response_table;
+ }
+
+ // load survey title (and other globals)
+ if (empty($this->survey)) {
+ $errmsg = 'Error opening survey.' ." [ ID:${sid} R:";
+ return($errmsg);
+ }
+
+ if (empty($this->questions)) {
+ $errmsg = 'Error opening survey.' .' '. 'No questions found.' ." [ ID:${sid} ]";
+ return($errmsg);
+ }
+
+ // find out more about the question we are cross analyzing on (if any)
+ if($cross) {
+ $crossTable = $response_table[get_field('questionnaire_question', 'type_id', 'id', $qid)];
+ if(!in_array($crossTable, array('response_single','response_bool','response_multiple'))) {
+ $errmsg = 'Error cross-analyzing. Question not valid type.' .' [ '. 'Table' .": ${crossTable} ]";
+ return($errmsg);
+ }
+ }
+
+ // find total number of survey responses
+ // and relevant response ID's
+ if (!empty($rid)) {
+ $rids = $rid;
+ if (is_array($rids)) {
+ $ridstr = "IN (" . ereg_replace("([^,]+)","'\\1'", join(",", $rids)) .")";
+ $navbar = false;
+ } else {
+ $ridstr = "= '${rid}'";
+ $navbar = true;
+ }
+ $total = 1;
+ } else {
+ $navbar = false;
+ $sql = "";
+ if($cross) {
+ if(!empty($cidstr))
+ $sql = "SELECT A.response_id, R.id
+ FROM ".$CFG->prefix.'questionnaire_'.$crossTable." A,
+ ".$CFG->prefix."questionnaire_response R
+ WHERE A.response_id=R.id AND
+ R.complete='Y' AND
+ A.question_id='${qid}' AND
+ A.choice_id ${cidstr}
+ ORDER BY A.response_id";
+ else
+ $sql = "SELECT A.response_id, R.id
+ FROM ".$CFG->prefix.'questionnaire_'.$crossTable." A,
+ ".$CFG->prefix."questionnaire_response R
+ WHERE A.response_id=R.id AND
+ R.complete='Y' AND
+ A.question_id='${qid}' AND
+ A.choice_id = 0
+ ORDER BY A.response_id";
+ } else if ($uid !== false) {
+ $sql = "SELECT r.id, r.survey_id
+ FROM ".$CFG->prefix."questionnaire_response r
+ WHERE r.survey_id='{$this->survey->id}' AND
+ r.username = $uid AND
+ r.complete='Y'
+ ORDER BY r.id";
+ } else {
+ $sql = "SELECT R.id, R.survey_id
+ FROM ".$CFG->prefix."questionnaire_response R
+ WHERE R.survey_id='{$this->survey->id}' AND
+ R.complete='Y'
+ ORDER BY R.id";
+ }
+ if (!($rows = get_records_sql($sql))) {
+ $errmsg = 'Error opening survey.' ." [ ID:${sid} ] [ ";
+ return($errmsg);
+ }
+ $total = count($rows);
+ if($total < 1) {
+ $errmsg = 'Error opening survey.' .' '. 'No responses found.' ." [ ID:${sid} ]";
+ return($errmsg);
+ }
+
+ $rids = array();
+ foreach ($rows as $row) {
+ array_push($rids, $row->id);
+ }
+ // create a string suitable for inclusion in a SQL statement
+ // containing the desired Response IDs
+ // ex: "('304','311','317','345','365','370','403','439')"
+ $ridstr = "IN (" . ereg_replace("([^,]+)","'\\1'", join(",", $rids)) .")";
+ }
+
+ if ($navbar) {
+ // show response navigation bar
+ $this->survey_results_navbar($rid);
+ }
+
+ ?>
+ survey->title); ?>
+ survey->subtitle); ?>
+ survey->info); ?>
+ " ._('Cross analysis on QID:') ." ${qid}\n");
+ }
+ ?>
+ | ". $question->content ." | ||||
+ type_id < 50) {
+ if (!empty($guicross)){
+ echo ('');
+ echo ('');
+ echo ("\n
|
+
|
+
+
+
+ |
+ + |