function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args) { if ($component == 'question' && $filearea == 'answerfeedback') { $answerid = reset($args); // itemid is answer id. $answers =& $question->options->answers; if (isset($state->responses[''])) { $response = $state->responses['']; } else { $response = ''; } return $options->feedback && !empty($response); } else { return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args); } }
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args) { $itemid = reset($args); if ($filearea == 'subquestion') { // itemid is sub question id if (!array_key_exists($itemid, $question->options->subquestions)) { return false; } return true; } else { return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args); } }
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args) { $itemid = reset($args); if ($component == 'question' && $filearea == 'answerfeedback') { // check if answer id exists $result = $options->feedback && array_key_exists($itemid, $question->options->answers); if (!$result) { return false; } // check response if (!$this->check_response($question, $state)) { return false; } return true; } else { if ($filearea == 'instruction') { // TODO: should it be display all the time like questiontext? // check if question id exists if ($itemid != $question->id) { return false; } else { return true; } } else { if (in_array($filearea, array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) { // TODO: calculated type doesn't display question feedback yet return false; } else { return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args); } } } }
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args) { if ($component == 'question' && $filearea == 'answerfeedback') { $answers =& $question->options->answers; if (isset($state->responses[''])) { $response = $state->responses['']; } else { $response = ''; } $answerid = reset($args); // itemid is answer id. if (empty($options->feedback)) { return false; } foreach ($answers as $answer) { if ($this->test_response($question, $state, $answer)) { return true; } } return false; } else { return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args); } }
function check_file_access($question, $state, $options, $contextid, $component, $filearea, $args) { $itemid = reset($args); if (empty($question->maxgrade)) { $question->maxgrade = $question->defaultgrade; } if (in_array($filearea, array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback'))) { $result = $options->feedback && $itemid == $question->id; if (!$result) { return false; } if ($state->raw_grade >= $question->maxgrade / 1.01) { $feedbacktype = 'correctfeedback'; } else { if ($state->raw_grade > 0) { $feedbacktype = 'partiallycorrectfeedback'; } else { $feedbacktype = 'incorrectfeedback'; } } if ($feedbacktype != $filearea) { return false; } return true; } else { if ($component == 'question' && $filearea == 'answerfeedback') { return $options->feedback && array_key_exists($itemid, $question->options->answers); } else { return parent::check_file_access($question, $state, $options, $contextid, $component, $filearea, $args); } } }