From 013fa7a444937df3f4dc4dcb7cab3ec23b54f723 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 8 Aug 2014 14:36:03 +0100 Subject: [PATCH] MDL-46308 qformat_xml: fix import of broken calculated questions. Questions like this should not exist, of course. But they do, so we should avoid generating errors in this case. --- question/format/xml/format.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index 1c55f348cab..ed6420191c0 100644 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -856,9 +856,10 @@ class qformat_xml extends qformat_default { $qo->dataset[$qo->datasetindex]->itemcount = $dataset['#']['itemcount'][0]['#']; $qo->dataset[$qo->datasetindex]->datasetitem = array(); $qo->dataset[$qo->datasetindex]->itemindex = 0; - $qo->dataset[$qo->datasetindex]->number_of_items = - $dataset['#']['number_of_items'][0]['#']; - $datasetitems = $dataset['#']['dataset_items'][0]['#']['dataset_item']; + $qo->dataset[$qo->datasetindex]->number_of_items = $this->getpath($dataset, + array('#', 'number_of_items', 0, '#'), 0); + $datasetitems = $this->getpath($dataset, + array('#', 'dataset_items', 0, '#', 'dataset_item'), array()); foreach ($datasetitems as $datasetitem) { $qo->dataset[$qo->datasetindex]->itemindex++; $qo->dataset[$qo->datasetindex]->datasetitem[