mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-64941 qtype_multianswer: keep order of existing wrapped questions
This commit is contained in:
parent
89d1238962
commit
3e24d6f663
1 changed files with 11 additions and 5 deletions
|
@ -91,12 +91,18 @@ class qtype_multianswer extends question_type {
|
||||||
// will also create difficulties if questiontype specific tables reference the id.
|
// will also create difficulties if questiontype specific tables reference the id.
|
||||||
|
|
||||||
// First we get all the existing wrapped questions.
|
// First we get all the existing wrapped questions.
|
||||||
if (!$oldwrappedids = $DB->get_field('question_multianswer', 'sequence',
|
$oldwrappedquestions = [];
|
||||||
|
if ($oldwrappedids = $DB->get_field('question_multianswer', 'sequence',
|
||||||
array('question' => $question->id))) {
|
array('question' => $question->id))) {
|
||||||
$oldwrappedquestions = array();
|
$oldwrappedidsarray = explode(',', $oldwrappedids);
|
||||||
} else {
|
$unorderedquestions = $DB->get_records_list('question', 'id', $oldwrappedidsarray);
|
||||||
$oldwrappedquestions = $DB->get_records_list('question', 'id',
|
|
||||||
explode(',', $oldwrappedids), 'id ASC');
|
// Keep the order as given in the sequence field.
|
||||||
|
foreach ($oldwrappedidsarray as $questionid) {
|
||||||
|
if (isset($unorderedquestions[$questionid])) {
|
||||||
|
$oldwrappedquestions[] = $unorderedquestions[$questionid];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sequence = array();
|
$sequence = array();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue