MDL-79863 qtype_ordering: qtype/ordering ensure get_possible_responses does not fail even if there is no correct response

This commit is contained in:
Gordon Bateson 2018-06-29 13:52:40 +09:00 committed by Mathew May
parent 32559a356c
commit b307db44c8
2 changed files with 10 additions and 9 deletions

View File

@ -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)
);
}
/**

View File

@ -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)';