Пример #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>';
     }
 }