From b307db44c8a0f44949e8a20dade35bc3d91d8b0a Mon Sep 17 00:00:00 2001 From: Gordon Bateson Date: Fri, 29 Jun 2018 13:52:40 +0900 Subject: [PATCH] MDL-79863 qtype_ordering: qtype/ordering ensure get_possible_responses does not fail even if there is no correct response --- question/type/ordering/questiontype.php | 15 ++++++++------- question/type/ordering/version.php | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/question/type/ordering/questiontype.php b/question/type/ordering/questiontype.php index 3ae41a64ca7..6fb511acefe 100644 --- a/question/type/ordering/questiontype.php +++ b/question/type/ordering/questiontype.php @@ -298,14 +298,15 @@ class qtype_ordering extends question_type { public function get_possible_responses($questiondata) { $responses = array(); $question = $this->make_question($questiondata); - foreach ($question->correctresponse as $position => $answerid) { - $responses[] = $position.': '.$question->answers[$answerid]->answer; + if ($question->correctresponse) { + foreach ($question->correctresponse as $position => $answerid) { + $responses[] = $position.': '.$question->answers[$answerid]->answer; + } } - $responses = array( - 0 => question_possible_response::no_response(), - 1 => implode(', ', $responses) - ); - return; + return array( + 0 => question_possible_response::no_response(), + 1 => implode(', ', $responses) + ); } /** diff --git a/question/type/ordering/version.php b/question/type/ordering/version.php index 60240ab0f16..2bf0a7f9441 100644 --- a/question/type/ordering/version.php +++ b/question/type/ordering/version.php @@ -29,5 +29,5 @@ $plugin->cron = 0; $plugin->component = 'qtype_ordering'; $plugin->maturity = MATURITY_STABLE; $plugin->requires = 2010112400; // Moodle 2.0 -$plugin->version = 2018061870; -$plugin->release = '2018-06-18 (70)'; +$plugin->version = 2018062971; +$plugin->release = '2018-06-29 (71)';