MDL-53744 question file access: fix access checks

This commit is contained in:
Tim Hunt 2016-09-26 19:46:22 +01:00 committed by Mr. Jenkins (CiBoT)
parent 42778e124e
commit cf0b9432d8
2 changed files with 6 additions and 5 deletions

View File

@ -140,7 +140,7 @@ class qtype_essay_question extends question_with_responses {
return $this->responseformat === 'editorfilepicker';
} else if ($component == 'qtype_essay' && $filearea == 'graderinfo') {
return $options->manualcomment;
return $options->manualcomment && $args[0] == $this->id;
} else {
return parent::check_file_access($qa, $options, $component,

View File

@ -413,11 +413,11 @@ abstract class question_definition {
*/
public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) {
if ($component == 'question' && $filearea == 'questiontext') {
// Question text always visible.
return true;
// Question text always visible, but check it is the right question id.
return $args[0] == $this->id;
} else if ($component == 'question' && $filearea == 'generalfeedback') {
return $options->generalfeedback;
return $options->generalfeedback && $args[0] == $this->id;
} else {
// Unrecognised component or filearea.
@ -681,7 +681,8 @@ abstract class question_graded_automatically extends question_with_responses
list($notused, $state) = $this->grade_response($response);
}
return $options->feedback && $state->get_feedback_class() . 'feedback' == $filearea;
return $options->feedback && $state->get_feedback_class() . 'feedback' == $filearea &&
$args[0] == $this->id;
}
/**