-
Improvement
-
Resolution: Won't Fix
-
Minor
-
1.9.2
-
None
-
Easy
-
MOODLE_19_STABLE
-
MOODLE_19_STABLE
enabling embedded (on the fly generated) pie chart graphs
when viewing reports of multiple choose questions.
(a link to the original patch : http://tracker.moodle.org/browse/MDL-19054)
1. get the code of the pie chart image generator from : http://www.peters1.dk/webtools/php/lagkage.php?sprog=en
copy that file and put it into moodle/lib (call it makechart.php)
2. i am pasting the affected and changed function here.
new added lines are marked (at the end of the line) with // add this line to patch
function display_resp_single_results($rids=false, $guicross=false) {
|
echo clean_text($this->content).'</div>';
|
if (is_array($rids)) {
|
$prtotal = 1;
|
} else if (is_int($rids)) {
|
$prtotal = 0;
|
}
|
$response_pie_data = ''; // add this line to patch
|
$response_pie_data_label = ''; // add this line to patch
|
if ($rows = $this->get_response_single_results($rids)) {
|
foreach ($rows as $idx => $row) {
|
if (strpos($idx, 'other') === 0) {
|
$answer = $row->response;
|
$ccontent = $row->content;
|
$count = $row->num;
|
$content = preg_replace(array('/^!other=/', '/^!other/'),
|
array('', get_string('other', 'questionnaire')), $ccontent);
|
$content .= ' ' . clean_text($answer);
|
$this->counts[$content] = $count;
|
} else {
|
$contents = choice_values($row->content);
|
$this->choice = $contents->text.$contents->image;
|
$count = $row->num;
|
$this->counts[$this->choice] = $count;
|
}
|
$response_pie_data .= $row->num.'*'; // add this line to patch
|
$response_pie_data_label .= $row->num.'*'; // add this line to patch
|
}
|
$response_pie_data = rtrim($response_pie_data,'*'); // add this line to patch
|
$response_pie_data_label = rtrim($response_pie_data_label,'*'); // add this line to patch
|
$this->mkrespercent(count($rids), $this->precise, $prtotal, $guicross);
|
echo '<img src="/moodle/lib/makechart.php?data='.$response_pie_data.'&label='.$response_pie_data_label.'" />'; // add this line to patch
|
} else {
|
print_string('noresponsedata', 'questionnaire');
|
}
|
}
|