From a8a8ec51fc5ca605ff178a7c216aba6f8cb7ec79 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Sat, 12 Feb 2011 00:40:43 +0000 Subject: [PATCH] MDL-20636 Fix bug with starting an attempt. Now uses exceptions, so should not check return values. --- lib/questionlib.php | 17 ++++++----------- mod/quiz/attemptlib.php | 4 +--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index 7898cbec329..25e5514875e 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -849,7 +849,6 @@ function question_load_questions($questionids, $extrafields = '', $join = '') { * * @param object $question the question to tidy. * @param boolean $loadtags load the question tags from the tags table. Optional, default false. - * @return boolean true if successful, else false. */ function _tidy_question($question, $loadtags = false) { global $CFG, $QTYPES; @@ -857,16 +856,14 @@ function _tidy_question($question, $loadtags = false) { $question->qtype = 'missingtype'; $question->questiontext = '

' . get_string('warningmissingtype', 'quiz') . '

' . $question->questiontext; } - if ($success = $QTYPES[$question->qtype]->get_question_options($question)) { - if (isset($question->_partiallyloaded)) { - unset($question->_partiallyloaded); - } + $QTYPES[$question->qtype]->get_question_options($question); + if (isset($question->_partiallyloaded)) { + unset($question->_partiallyloaded); } if ($loadtags && !empty($CFG->usetags)) { require_once($CFG->dirroot . '/tag/lib.php'); $question->tags = tag_get_tags_array('question', $question->id); } - return $success; } /** @@ -884,14 +881,12 @@ function _tidy_question($question, $loadtags = false) { function get_question_options(&$questions, $loadtags = false) { if (is_array($questions)) { // deal with an array of questions foreach ($questions as $i => $notused) { - if (!_tidy_question($questions[$i], $loadtags)) { - return false; - } + _tidy_question($questions[$i], $loadtags); } - return true; } else { // deal with single question - return _tidy_question($questions, $loadtags); + _tidy_question($questions, $loadtags); } + return true; } /** diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index dbb96c4ed96..4c3e2e8c31c 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -151,9 +151,7 @@ class quiz { $questionstoprocess[$id] = $this->questions[$id]; } } - if (!get_question_options($questionstoprocess)) { - throw new moodle_quiz_exception($this, 'loadingquestionsfailed', implode(', ', $questionids)); - } + get_question_options($questionstoprocess); } // Simple getters ======================================================================