Skip to content

Commit

Permalink
Merge pull request #339 from oat-sa/fix/TR-3424/unmarshall-list-insid…
Browse files Browse the repository at this point in the history
…e-record-container

fix: Record container handle list when unmarshalling
  • Loading branch information
bartlomiejmarszal authored Nov 2, 2022
2 parents 0d7c8a3 + ee50a19 commit 9378bc2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qtism/runtime/pci/json/Unmarshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] . "'");
Expand Down
16 changes: 16 additions & 0 deletions test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9378bc2

Please sign in to comment.