1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-07 00:36:01 +02:00

MDL-57587 question file access: fix regression caused by MDL-53744

This commit is contained in:
Tim Hunt 2017-01-26 18:53:16 +00:00
parent 5130953c8a
commit c28bfbef24
5 changed files with 17 additions and 4 deletions

@ -321,7 +321,7 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
if ($component == 'question' && in_array($filearea,
array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
return $this->check_combined_feedback_file_access($qa, $options, $filearea);
return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
} else if ($component == 'question' && $filearea == 'hint') {
return $this->check_hint_file_access($qa, $options, $args);

@ -342,7 +342,7 @@ class qtype_match_question extends question_graded_automatically_with_countback
} else if ($component == 'question' && in_array($filearea,
array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
return $this->check_combined_feedback_file_access($qa, $options, $filearea);
return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
} else if ($component == 'question' && $filearea == 'hint') {
return $this->check_hint_file_access($qa, $options, $args);

@ -113,7 +113,7 @@ abstract class qtype_multichoice_base extends question_graded_automatically {
public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
if ($component == 'question' && in_array($filearea,
array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) {
return $this->check_combined_feedback_file_access($qa, $options, $filearea);
return $this->check_combined_feedback_file_access($qa, $options, $filearea, $args);
} else if ($component == 'question' && $filearea == 'answer') {
$answerid = reset($args); // Itemid is answer id.

@ -668,11 +668,18 @@ abstract class question_graded_automatically extends question_with_responses
* @param question_attempt $qa the question attempt being displayed.
* @param question_display_options $options the options that control display of the question.
* @param string $filearea the name of the file area.
* @param array $args the remaining bits of the file path.
* @return bool whether access to the file should be allowed.
*/
protected function check_combined_feedback_file_access($qa, $options, $filearea) {
protected function check_combined_feedback_file_access($qa, $options, $filearea, $args = null) {
$state = $qa->get_state();
if ($args === null) {
debugging('You must pass $args as the fourth argument to check_combined_feedback_file_access.',
DEBUG_DEVELOPER);
$args = array($this->id); // Fake it for now, so the rest of this method works.
}
if (!$state->is_finished()) {
$response = $qa->get_last_qt_data();
if (!$this->is_gradable_response($response)) {

@ -1,5 +1,11 @@
This files describes API changes for question type plugins.
=== 3.1.5, 3.2.2, 3.3 ===
* If you are using check_combined_feedback_file_access in your check_file_access method,
then you must now pass $args as the 4th argument, so the correct permission checks
can be performed. If you don't, you will get a developer debug notice.
=== 3.1 ===
* The following functions, previously used (exclusively) by upgrade steps are not available