From b3753e60faeaf0bb657b7441a5831e9aa7b72e9a Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 15 Apr 2018 17:29:04 +0800 Subject: [PATCH] MDL-61407 question: Allow formatters to ignore caps --- lib/questionlib.php | 2 +- question/format.php | 12 +++++++----- question/upgrade.txt | 6 ++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index 57021a71491..df694f63561 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1789,7 +1789,7 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f } // export data to moodle file pool - if (!$content = $qformat->exportprocess(true)) { + if (!$content = $qformat->exportprocess()) { send_file_not_found(); } diff --git a/question/format.php b/question/format.php index 20b92fec95a..8c41d05cafc 100644 --- a/question/format.php +++ b/question/format.php @@ -759,11 +759,13 @@ class qformat_default { } /** - * Do the export - * For most types this should not need to be overrided - * @return stored_file + * Perform the export. + * For most types this should not need to be overrided. + * + * @param bool $checkcapabilities Whether to check capabilities when exporting the questions. + * @return string The content of the export. */ - public function exportprocess() { + public function exportprocess($checkcapabilities = true) { global $CFG, $OUTPUT, $DB, $USER; // get the questions (from database) in this category @@ -823,7 +825,7 @@ class qformat_default { // export the question displaying message $count++; - if (question_has_capability_on($question, 'view', $question->category)) { + if (!$checkcapabilities || question_has_capability_on($question, 'view', $question->category)) { $expout .= $this->writequestion($question, $contextid) . "\n"; } } diff --git a/question/upgrade.txt b/question/upgrade.txt index 7d0bbe35ff3..f34bd6a4626 100644 --- a/question/upgrade.txt +++ b/question/upgrade.txt @@ -1,5 +1,11 @@ This files describes API changes for code that uses the question API. +=== 3.5 === + +1) The question format exportprocess function now adds a + $checkcapabilities boolean to allow questions to be exported in + certain circumstances. + === 3.2 === 1) The following renderers have been deprecated in favour of the renderable