MDL-79863 qtype_ordering: qtype_ordering fix import of GIFT text files

This commit is contained in:
Gordon Bateson 2018-05-24 12:56:12 +09:00 committed by Mathew May
parent 6f79ea9708
commit 35551217e0
2 changed files with 20 additions and 8 deletions

View File

@ -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 <p>...</p> to plain text.

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 = 2018011768;
$plugin->release = '2018-01-17 (68)';
$plugin->version = 2018052469;
$plugin->release = '2018-05-24 (69)';