Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questionnaire: Print attempt view - add a 'Print' button #325

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function render_completepage($page) {
*/
public function render_reportpage($page) {
$data = $page->export_for_template($this);
$printparam = optional_param('target', '', PARAM_TEXT);

$data->printparam = $printparam == 'print';

return $this->render_from_template('mod_questionnaire/reportpage', $data);
}

Expand Down Expand Up @@ -553,4 +557,4 @@ public function download_dataformat_selector($label, $base, $name = 'dataformat'

return $this->render_from_template('mod_questionnaire/dataformat_selector', $data);
}
}
}
3 changes: 2 additions & 1 deletion lang/en/questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
$string['previous'] = 'Previous';
$string['previouspage'] = 'Previous Page';
$string['print'] = 'Print this Response';
$string['printbutton'] = 'Print';
$string['printblank'] = 'Print Blank';
$string['printblanktooltip'] = 'Opens printer-friendly window with blank Questionnaire';
$string['printtooltip'] = 'Opens printer-friendly window with current Response';
Expand Down Expand Up @@ -653,4 +654,4 @@
$string['yesno_help'] = 'Simple Yes/No question.';
$string['yourresponse'] = 'Your response';
$string['yourresponses'] = 'Your responses';
$string['crontask'] = 'Questionnaire cleanup job';
$string['crontask'] = 'Questionnaire cleanup job';
12 changes: 11 additions & 1 deletion module.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,14 @@ M.mod_questionnaire.init_sendmessage = function(Y) {
});
}, '#checkstarted');

};
};

M.mod_questionnaire.init_printing = function(Y) {
var printbutton = Y.one('#print-button');
if (printbutton) {
printbutton.on('click', function(e) {
e.preventDefault();
window.print();
});
}
};
3 changes: 2 additions & 1 deletion report.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
$PAGE->set_context($context);
if ($outputtarget == 'print') {
$PAGE->set_pagelayout('popup');
$PAGE->requires->js_init_call('M.mod_questionnaire.init_printing');
}

// Tab setup.
Expand Down Expand Up @@ -847,4 +848,4 @@ function questionnaire_report_start_pdf() {
$pdf->SetFillColor(238, 238, 238);
$pdf->AddPage('L');
return $pdf;
}
}
7 changes: 6 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ td.selected {
#page-mod-questionnaire-complete .notice .buttons form {
display: inline;
}
@media print {
#page-mod-questionnaire-report #print-button {
display: none;
}
}

.floatprinticon {
margin-top: -30px;
Expand Down Expand Up @@ -387,4 +392,4 @@ td.selected {

.qn-indent {
margin-left: 20px;
}
}
7 changes: 6 additions & 1 deletion templates/reportpage.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,10 @@
{{#feedbacknotes}}{{{.}}}{{/feedbacknotes}}
{{#responses}}{{{.}}}{{/responses}}
{{#bottomnavigationbar}}<div class="box respondentsnavbar">{{{.}}}</div>{{/bottomnavigationbar}}
{{#printparam}}
<button id="print-button" title="{{#str}}print, mod_questionnaire{{/str}}">
{{#str}}printbutton, mod_questionnaire{{/str}}
</button>
{{/printparam}}
</div>
</div>
</div>