Пример #1
0
 public function display_results($rids = false, $sort = '')
 {
     if (is_array($rids)) {
         $prtotal = 1;
     } else {
         if (is_int($rids)) {
             $prtotal = 0;
         }
     }
     if ($rows = $this->get_results($rids, $sort)) {
         $stravgvalue = '';
         // For printing table heading.
         foreach ($this->counts as $key => $value) {
             $ccontent = $key;
             $avgvalue = '';
             if (array_key_exists($ccontent, $rows)) {
                 $avg = $rows[$ccontent]->average;
                 $this->counts[$ccontent]->num = $rows[$ccontent]->num;
                 if (isset($rows[$ccontent]->averagevalue)) {
                     $avgvalue = $rows[$ccontent]->averagevalue;
                     $osgood = false;
                     if ($this->question->precise == 3) {
                         // Osgood's semantic differential.
                         $osgood = true;
                     }
                     if ($stravgvalue == '' && !$osgood) {
                         $stravgvalue = ' (' . get_string('andaveragevalues', 'questionnaire') . ')';
                     }
                 } else {
                     $avgvalue = null;
                 }
             } else {
                 $avg = 0;
             }
             $this->counts[$ccontent]->avg = $avg;
             $this->counts[$ccontent]->avgvalue = $avgvalue;
         }
         \mod_questionnaire\response\display_support::mkresavg($this->counts, count($rids), $this->question->choices, $this->question->precise, $prtotal, $this->question->length, $sort, $stravgvalue);
         \mod_questionnaire\response\display_support::mkrescount($this->counts, $rids, $rows, $this->question, $this->question->precise, $this->question->length, $sort);
     } else {
         echo '<p class="generaltable">&nbsp;' . get_string('noresponsedata', 'questionnaire') . '</p>';
     }
 }
Пример #2
0
 public function display_results($rids = false, $sort = '')
 {
     if (empty($this->stryes)) {
         $this->stryes = get_string('yes');
         $this->strno = get_string('no');
     }
     if (is_array($rids)) {
         $prtotal = 1;
     } else {
         if (is_int($rids)) {
             $prtotal = 0;
         }
     }
     $this->counts = array($this->stryes => 0, $this->strno => 0);
     if ($rows = $this->get_results($rids)) {
         foreach ($rows as $row) {
             $this->choice = $row->choice_id;
             $count = $row->num;
             if ($this->choice == 'y') {
                 $this->choice = $this->stryes;
             } else {
                 $this->choice = $this->strno;
             }
             $this->counts[$this->choice] = intval($count);
         }
         \mod_questionnaire\response\display_support::mkrespercent($this->counts, count($rids), $this->question->precise, $prtotal, $sort = '');
     } else {
         echo '<p class="generaltable">&nbsp;' . get_string('noresponsedata', 'questionnaire') . '</p>';
     }
 }
 public function display_results($rids = false, $sort = '', $anonymous = false)
 {
     $output = '';
     if (is_array($rids)) {
         $prtotal = 1;
     } else {
         if (is_int($rids)) {
             $prtotal = 0;
         }
     }
     if ($rows = $this->get_results($rids, $anonymous)) {
         // Count identical answers (numeric questions only).
         foreach ($rows as $row) {
             if (!empty($row->response) || $row->response === "0") {
                 $this->text = $row->response;
                 $textidx = clean_text($this->text);
                 $this->counts[$textidx] = !empty($this->counts[$textidx]) ? $this->counts[$textidx] + 1 : 1;
                 $this->userid[$textidx] = !empty($this->counts[$textidx]) ? $this->counts[$textidx] + 1 : 1;
             }
         }
         $isnumeric = $this->question->type_id == QUESNUMERIC;
         if ($isnumeric) {
             $output .= \mod_questionnaire\response\display_support::mkreslistnumeric($this->counts, count($rids), $this->question->precise);
         } else {
             $output .= \mod_questionnaire\response\display_support::mkreslisttext($rows);
         }
     } else {
         $output .= '<p class="generaltable">&nbsp;' . get_string('noresponsedata', 'questionnaire') . '</p>';
     }
     return $output;
 }
Пример #4
0
 protected function display_response_choice_results($rows, $rids, $sort)
 {
     if (is_array($rids)) {
         $prtotal = 1;
     } else {
         if (is_int($rids)) {
             $prtotal = 0;
         }
     }
     if ($rows) {
         foreach ($rows as $idx => $row) {
             if (strpos($idx, 'other') === 0) {
                 $answer = $row->response;
                 $ccontent = $row->content;
                 $content = preg_replace(array('/^!other=/', '/^!other/'), array('', get_string('other', 'questionnaire')), $ccontent);
                 $content .= ' ' . clean_text($answer);
                 $textidx = $content;
                 $this->counts[$textidx] = !empty($this->counts[$textidx]) ? $this->counts[$textidx] + 1 : 1;
             } else {
                 $contents = questionnaire_choice_values($row->content);
                 $this->choice = $contents->text . $contents->image;
                 $textidx = $this->choice;
                 $this->counts[$textidx] = !empty($this->counts[$textidx]) ? $this->counts[$textidx] + 1 : 1;
             }
         }
         \mod_questionnaire\response\display_support::mkrespercent($this->counts, count($rids), $this->question->precise, $prtotal, $sort);
     } else {
         echo '<p class="generaltable">&nbsp;' . get_string('noresponsedata', 'questionnaire') . '</p>';
     }
 }
 public function display_results($rids = false, $sort = '', $anonymous = false)
 {
     $output = '';
     if (is_array($rids)) {
         $prtotal = 1;
     } else {
         if (is_int($rids)) {
             $prtotal = 0;
         }
     }
     if ($rows = $this->get_results($rids, $anonymous)) {
         foreach ($rows as $row) {
             // Count identical answers (case insensitive).
             $this->text = $row->response;
             if (!empty($this->text)) {
                 $dateparts = preg_split('/-/', $this->text);
                 $this->text = make_timestamp($dateparts[0], $dateparts[1], $dateparts[2]);
                 // Unix timestamp.
                 $textidx = clean_text($this->text);
                 $this->counts[$textidx] = !empty($this->counts[$textidx]) ? $this->counts[$textidx] + 1 : 1;
             }
         }
         $output .= \mod_questionnaire\response\display_support::mkreslistdate($this->counts, count($rids), $this->question->precise, $prtotal);
     } else {
         $output .= '<p class="generaltable">&nbsp;' . get_string('noresponsedata', 'questionnaire') . '</p>';
     }
     return $output;
 }