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 #588

Open
wants to merge 1 commit into
base: MOODLE_401_STABLE
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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
1 change: 1 addition & 0 deletions lang/en/questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,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
10 changes: 10 additions & 0 deletions module.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ 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();
});
}
};
M.mod_questionnaire.init_slider = function() {
const allRanges = document.querySelectorAll(".question-slider");
allRanges.forEach(wrap => {
Expand Down
1 change: 1 addition & 0 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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
6 changes: 6 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ td.selected {
display: inline;
}

@media print {
#page-mod-questionnaire-report #print-button {
display: none;
}
}

#page-mod-questionnaire-complete .notice .buttons input {
margin-bottom: 10px;
}
Expand Down
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>
Loading