Skip to content

Commit

Permalink
Merge branch 'MDL-52791' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski authored and David Monllao committed Jan 29, 2016
2 parents 4ce63c9 + fdd6296 commit 4ce6dac
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions mod/quiz/classes/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function can_finish_during_the_attempt($slotnumber) {
return false;
}

if ($this->get_question_type_for_slot($slotnumber) == 'random') {
if (in_array($this->get_question_type_for_slot($slotnumber), array('random', 'missingtype'))) {
return \question_engine::can_questions_finish_during_the_attempt(
$this->quizobj->get_quiz()->preferredbehaviour);
}
Expand All @@ -190,14 +190,19 @@ public function can_finish_during_the_attempt($slotnumber) {
return $this->slotsinorder[$slotnumber]->canfinish;
}

$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
$tempslot = $quba->add_question(\question_bank::load_question(
$this->slotsinorder[$slotnumber]->questionid));
$quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
$quba->start_all_questions();
try {
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $this->quizobj->get_context());
$tempslot = $quba->add_question(\question_bank::load_question(
$this->slotsinorder[$slotnumber]->questionid));
$quba->set_preferred_behaviour($this->quizobj->get_quiz()->preferredbehaviour);
$quba->start_all_questions();

$this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
return $this->slotsinorder[$slotnumber]->canfinish;
$this->slotsinorder[$slotnumber]->canfinish = $quba->can_question_finish_during_attempt($tempslot);
return $this->slotsinorder[$slotnumber]->canfinish;
} catch (\Exception $e) {
// If the question fails to start, this should not block editing.
return false;
}
}

/**
Expand Down

0 comments on commit 4ce6dac

Please sign in to comment.