Skip to content

Commit

Permalink
MDL-20636 Tidy-up of numerical questiontype.php.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Apr 28, 2011
1 parent d7d8cee commit 52ad7e0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 392 deletions.
19 changes: 19 additions & 0 deletions question/type/numerical/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ public function classify_response(array $response) {
$response['answer'],
$this->apply_unit_penalty($ans->fraction, $unit)));
}

function check_file_access($question, $state, $options, $contextid, $component,
$filearea, $args) {
if ($component == 'question' && $filearea == 'answerfeedback') {
$currentanswer = $qa->get_last_qt_var('answer');
$answer = $qa->get_question()->get_matching_answer(array('answer' => $currentanswer));
$answerid = reset($args); // itemid is answer id.
return $options->feedback && $answerid == $answer->id;

} else if ($component == 'question' && $filearea == 'hint') {
return $this->check_hint_file_access($qa, $options, $args);

} else if ($component == 'qtype_numerical' && $filearea == 'instruction') {
return true;

} else {
return parent::check_file_access($qa, $options, $component, $filearea, $args, $forcedownload);
}
}
}


Expand Down

0 comments on commit 52ad7e0

Please sign in to comment.