Skip to content

Commit

Permalink
GHI234 Changing rate results display to work with PDF HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Churchward committed Jan 17, 2020
1 parent 5f53db3 commit 12c85e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions classes/responsetype/display_support.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static function mkresavg($counts, $total, $question, $showtotals, $sort,
}

$imageurl = $CFG->wwwroot.'/mod/questionnaire/images/';
$blankimage = $CFG->wwwroot . '/mod/questionnaire/images/hbartransp.gif';
$llength = $question->length;
if (!$llength) {
$llength = 5;
Expand All @@ -104,7 +105,9 @@ public static function mkresavg($counts, $total, $question, $showtotals, $sort,
$str = $j + 1;
}
}
$out = '<table style="width:100%" cellpadding="2" cellspacing="0" border="1"><tr>';
// Using a hard value so we can have things look right in a PDF as well.
$innertablewidth = 450;
$out = '<table style="width: ' . $innertablewidth . 'px;" cellpadding="2" cellspacing="0" border="1"><tr>';
for ($i = 0; $i <= $llength - 1; $i++) {
if (isset($n[$i])) {
$str = $n[$i];
Expand Down Expand Up @@ -155,14 +158,16 @@ public static function mkresavg($counts, $total, $question, $showtotals, $sort,
if ($avg) {
$out = '';
if (($j = $avg * $width) > 0) {
$marginposition = ($avg - 0.5 ) / ($question->length + $isrestricted) * 100;
$marginposition = ($avg - 0.5 ) / ($question->length + $isrestricted);
}
if (!right_to_left()) {
$out .= '<img style="height:12px; width: 6px; margin-left: '.$marginposition.
'%;" alt="" src="'.$imageurl.'hbar.gif" />';
$out .= '<img style="height: 12px; width: ' . ($marginposition * $innertablewidth) .
'px;" alt="" src="' . $blankimage . '" />' .
'<img style="height:12px; width: 6px;" alt="" src="'.$imageurl.'hbar.gif" />';
} else {
$out .= '<img style="height:12px; width: 6px; margin-right: '.$marginposition.
'%;" alt="" src="'.$imageurl.'hbar.gif" />';
$out .= '<img style="height: 12px; width: ' .($innertablewidth - ($marginposition * $innertablewidth)).
'px;" alt="" src="' . $blankimage . '" />' .
'<img style="height:12px; width: 6px;" alt="" src="'.$imageurl.'hbar.gif" />';
}
} else {
$out = '';
Expand Down
Binary file added images/hbartransp.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lang/en/questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
$string['directwarnings'] = 'Direct dependencies to this question will be removed. This will affect:';
$string['displaymethod'] = 'Display method not defined for question.';
$string['download'] = 'Download';
$string['downloadpdf'] = 'Download PDF';
$string['downloadtextformat'] = 'Download';
$string['downloadtextformat_help'] = 'This feature enables you to save all the responses of a questionnaire to a selectable, supported file format.
You can choose to include extra data items in the export, as well as choose to automatically send the file to selected users.';
Expand Down
2 changes: 1 addition & 1 deletion questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ private function print_survey_start($message, $section, $numsections, $hasrequir
if ($ruser) {
$respinfo = '';
if ($outputtarget == 'html') {
$linkname = 'Download PDF';
$linkname = get_string('downloadpdf', 'mod_questionnaire');
$link = new moodle_url('/mod/questionnaire/report.php',
['action' => 'vresp', 'instance' => $this->id, 'target' => 'pdf', 'individualresponse' => 1, 'rid' => $rid]);
$downpdficon = new pix_icon('b/pdfdown', $linkname, 'mod_questionnaire');
Expand Down

0 comments on commit 12c85e6

Please sign in to comment.