From ee50a199c751356b8984649db95fe325d875d289 Mon Sep 17 00:00:00 2001 From: bartlomiej Date: Tue, 25 Oct 2022 12:14:20 +0200 Subject: [PATCH] fix: Record container handle list when unmarshalling --- qtism/runtime/pci/json/Unmarshaller.php | 3 +++ .../runtime/pci/json/JsonUnmarshallerTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/qtism/runtime/pci/json/Unmarshaller.php b/qtism/runtime/pci/json/Unmarshaller.php index 9ee69410e..74cd46f6c 100644 --- a/qtism/runtime/pci/json/Unmarshaller.php +++ b/qtism/runtime/pci/json/Unmarshaller.php @@ -254,6 +254,9 @@ protected function unmarshallUnit(array $unit) case 'identifier': return $this->unmarshallIdentifier($unit); break; + case 'list': + return $this->unmarshallList($unit['base']); + break; default: throw new UnmarshallingException("Unknown QTI baseType '" . $keys[0] . "'"); diff --git a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php index 41740624c..1ac7e8f3d 100644 --- a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php +++ b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php @@ -353,6 +353,22 @@ public function unmarshallRecordProvider() $json = '{ "record" : [ { "name": "A" } ] }'; $returnValue[] = [$record, $json]; + $record = new RecordContainer( + [ + 'A' => new MultipleContainer( + BaseType::STRING, + [ + new QtiString('p'), + new QtiString('a'), + new QtiString('p'), + new QtiString('e'), + new QtiString('r'), + ] + ) + ]); + $json = '{ "record" : [ {"name": "A","list": {"string": ["p","a","p","e","r"]} } ] }'; + $returnValue[] = [$record, $json]; + return $returnValue; }