diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index 30560ba7a45..f0ef55e9e93 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -46,6 +46,9 @@ $attemptobj = quiz_attempt::create($attemptid); require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm()); $attemptobj->check_review_capability(); +$accessmanager = $attemptobj->get_access_manager(time()); +$options = $attemptobj->get_display_options(true); + $PAGE->set_pagelayout('popup'); $output = $PAGE->get_renderer('mod_quiz'); @@ -54,8 +57,7 @@ if ($attemptobj->is_own_attempt()) { if (!$attemptobj->is_finished()) { echo $output->review_question_not_allowed(get_string('cannotreviewopen', 'quiz')); die(); - } else if (!$options->responses) { - $accessmanager = $attemptobj->get_access_manager(time()); + } else if (!$options->attempt) { echo $output->review_question_not_allowed( $accessmanager->cannot_review_message($attemptobj->get_review_options())); die(); diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php index bb8357fec57..5f29d378d0a 100644 --- a/question/engine/questionattempt.php +++ b/question/engine/questionattempt.php @@ -160,6 +160,15 @@ class question_attempt { } } + /** + * This method exists so that {@link question_attempt_with_restricted_history} + * can override it. You should not normally need to call it. + * @return question_attempt return ourself. + */ + public function get_full_qa() { + return $this; + } + /** @return question_definition the question this is an attempt at. */ public function get_question() { return $this->question; @@ -1200,29 +1209,34 @@ class question_attempt_with_restricted_history extends question_attempt { * annoyting that this needs to be passed, but unavoidable for now. */ public function __construct(question_attempt $baseqa, $lastseq, $preferredbehaviour) { - if ($lastseq < 0 || $lastseq >= $baseqa->get_num_steps()) { - throw new coding_exception('$seq out of range', $seq); + $this->baseqa = $baseqa->get_full_qa(); + + if ($lastseq < 0 || $lastseq >= $this->baseqa->get_num_steps()) { + throw new coding_exception('$lastseq out of range', $lastseq); } - $this->baseqa = $baseqa; - $this->steps = array_slice($baseqa->steps, 0, $lastseq + 1); + $this->steps = array_slice($this->baseqa->steps, 0, $lastseq + 1); $this->observer = new question_usage_null_observer(); // This should be a straight copy of all the remaining fields. - $this->id = $baseqa->id; - $this->usageid = $baseqa->usageid; - $this->slot = $baseqa->slot; - $this->question = $baseqa->question; - $this->maxmark = $baseqa->maxmark; - $this->minfraction = $baseqa->minfraction; - $this->questionsummary = $baseqa->questionsummary; - $this->responsesummary = $baseqa->responsesummary; - $this->rightanswer = $baseqa->rightanswer; - $this->flagged = $baseqa->flagged; + $this->id = $this->baseqa->id; + $this->usageid = $this->baseqa->usageid; + $this->slot = $this->baseqa->slot; + $this->question = $this->baseqa->question; + $this->maxmark = $this->baseqa->maxmark; + $this->minfraction = $this->baseqa->minfraction; + $this->questionsummary = $this->baseqa->questionsummary; + $this->responsesummary = $this->baseqa->responsesummary; + $this->rightanswer = $this->baseqa->rightanswer; + $this->flagged = $this->baseqa->flagged; // Except behaviour, where we need to create a new one. $this->behaviour = question_engine::make_behaviour( - $baseqa->get_behaviour_name(), $this, $preferredbehaviour); + $this->baseqa->get_behaviour_name(), $this, $preferredbehaviour); + } + + public function get_full_qa() { + return $this->baseqa; } public function get_full_step_iterator() {