From 35551217e0faad167e9b2b4ecaee884c8c72dc50 Mon Sep 17 00:00:00 2001 From: Gordon Bateson Date: Thu, 24 May 2018 12:56:12 +0900 Subject: [PATCH] MDL-79863 qtype_ordering: qtype_ordering fix import of GIFT text files --- question/type/ordering/questiontype.php | 24 ++++++++++++++++++------ question/type/ordering/version.php | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/question/type/ordering/questiontype.php b/question/type/ordering/questiontype.php index 4a27219f893..5d295db6441 100644 --- a/question/type/ordering/questiontype.php +++ b/question/type/ordering/questiontype.php @@ -161,13 +161,25 @@ class qtype_ordering extends question_type { // Insert all the new answers. foreach ($question->answer as $i => $answer) { + $answertext = ''; + $answerformat = 0; + $answeritemid = null; + // Extract $answer fields. - $answertext = $answer['text']; - $answerformat = $answer['format']; - if (!empty($answer['itemid'])) { - $answeritemid = $answer['itemid']; - } else { - $answeritemid = null; + if (is_string($answer)) { + // import from file + $answertext = $answer; + } else if (is_array($answer)) { + // input from browser + if (isset($answer['text'])) { + $answertext = $answer['text']; + } + if (isset($answer['format'])) { + $answerformat = $answer['format']; + } + if (isset($answer['itemid'])) { + $answeritemid = $answer['itemid']; + } } // Reduce simple

...

to plain text. diff --git a/question/type/ordering/version.php b/question/type/ordering/version.php index 2bd0a0d85b4..b8064ede8ac 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 = 2018011768; -$plugin->release = '2018-01-17 (68)'; +$plugin->version = 2018052469; +$plugin->release = '2018-05-24 (69)';