From 03b2b8fa296b71488d82fd7e0b62bd44ce596cdf Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 15 Jun 2011 16:02:05 +0100 Subject: [PATCH] MDL-27869 Fix images in numerical and calculated questions. Also fix an embarassing TODO in multianswer quetsions. --- question/type/multianswer/question.php | 18 +++++++++++++++++- question/type/numerical/question.php | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/question/type/multianswer/question.php b/question/type/multianswer/question.php index 42a8b8fee5e..94f374c366e 100644 --- a/question/type/multianswer/question.php +++ b/question/type/multianswer/question.php @@ -245,6 +245,22 @@ class qtype_multianswer_question extends question_graded_automatically { } public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload) { - // TODO + if ($component == 'question' && $filearea == 'answer') { + return true; + + } else if ($component == 'question' && $filearea == 'answerfeedback') { + // Full logic to control which feedbacks a student can see is too complex. + // Just allow access to all images. There is a theoretical chance the + // students could see files they are not meant to see by guessing URLs, + // but it is remote. + return $options->feedback; + + } else if ($component == 'question' && $filearea == 'hint') { + return $this->check_hint_file_access($qa, $options, $args); + + } else { + return parent::check_file_access($qa, $options, $component, $filearea, + $args, $forcedownload); + } } } diff --git a/question/type/numerical/question.php b/question/type/numerical/question.php index 7adacae84a2..764552834f1 100644 --- a/question/type/numerical/question.php +++ b/question/type/numerical/question.php @@ -240,8 +240,8 @@ class qtype_numerical_question extends question_graded_automatically { $this->apply_unit_penalty($ans->fraction, $unit))); } - public function check_file_access($question, $state, $options, $contextid, $component, - $filearea, $args) { + public function check_file_access($qa, $options, $component, $filearea, $args, + $forcedownload) { if ($component == 'question' && $filearea == 'answerfeedback') { $currentanswer = $qa->get_last_qt_var('answer'); $answer = $qa->get_question()->get_matching_answer(array('answer' => $currentanswer));