### Eclipse Workspace Patch 1.0 #P moodle19 Index: mod/questionnaire/questiontypes/questiontypes.class.php =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/questionnaire/questiontypes/questiontypes.class.php,v retrieving revision 1.31.2.51 diff -u -r1.31.2.51 questiontypes.class.php --- mod/questionnaire/questiontypes/questiontypes.class.php 3 Oct 2010 13:11:21 -0000 1.31.2.51 +++ mod/questionnaire/questiontypes/questiontypes.class.php 18 Nov 2010 11:10:56 -0000 @@ -619,21 +619,21 @@ } else if (is_int($rids)) { $prtotal = 0; } - + $isnumeric = $this->type_id == 10; if ($rows = $this->get_response_text_results($rids)) { - /// Count identical answers (case insensitive) + if ($isnumeric) { + /// Count identical answers (numeric questions only) foreach ($rows as $row) { + if(!empty($row->response)) { $this->text = $row->response; - if(!empty($this->text)) { $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->type_id == 10; - if ($isnumeric) { $this->mkreslistnumeric(count($rids), $this->precise); } else { - $this->mkreslist(count($rids), $this->precise, $prtotal); + $this->mkreslisttext($rows); } } else { print_string('noresponsedata', 'questionnaire'); @@ -1651,7 +1651,7 @@ $bg=''; $image_url = $CFG->wwwroot.'/mod/questionnaire/images/'; $currhbar = $this->theme_bars_url(); - $strtotal = get_string('total', 'questionnaire'); + $strtotal = get_string('total', 'questionnaire'); //devjr $table = new Object(); $table->size = array(); $table->align = array(); @@ -1667,7 +1667,7 @@ $table->align = array_merge($table->align, array('left', 'left', 'right')); $table->wrap = array_merge($table->wrap, array('', 'nowrap', '')); $table->head = array_merge($table->head, array(get_string('response', 'questionnaire'), - get_string('average', 'questionnaire'), get_string('total', 'questionnaire'))); + get_string('average', 'questionnaire'), get_string('total', 'questionnaire'))); //devjr if (!empty($this->counts) && is_array($this->counts)) { $pos = 0; @@ -1679,8 +1679,13 @@ arsort($this->counts); // DEV JR break; } + $numresponses = 0; //devjr + foreach ($this->counts as $key => $value) { + $numresponses = $numresponses + $value; + } + reset ($this->counts); while(list($content,$num) = each($this->counts)) { - if($num>0) { $percent = $num/$total*100.0; } + if($num>0) { $percent = $num/$numresponses*100.0; } //devjr else { $percent = 0; } if($percent > 100) { $percent = 100;