qti-sdk icon indicating copy to clipboard operation
qti-sdk copied to clipboard

Additional documentation or help creating one unmarshalling single node element

Open gewooneendeveloper opened this issue 5 years ago • 0 comments

Hi, I'm new to this project i just study the SDK code.

I'm looking for a way to unmarshal a single \DomElement to validate small pices of xml. But while trying I encounter some Exceptions.

This is what i try to accomplish:

$sdkMarshaller = new Qti211MarshallerFactory();
$cradle = new DOMDocument('1.0', 'UTF-8');
$xml    = new \DOMElement('hottextInteraction', '<p>Sponsors of the Olympic Games <hottext identifier="A">who bought</hottext>
				advertising time on United States television <hottext identifier="B">includes</hottext>
				<hottext identifier="C">at least</hottext> a dozen international firms <hottext
					identifier="D">whose</hottext> names are familiar to American consumers.
					<hottext identifier="E">No error.</hottext>
			</p>');
 $cradle->appendChild($xml);
 $xml->setAttribute('maxChoices', 1);
 $xml->setAttribute('responseIdentifier', 'RESPONSE');
 $hottextMarshaller = $sdkMarshaller->createMarshaller($cradle->firstChild);
 $hottextMarshaller->unmarshall($cradle->firstChild);

I receive the exception : The value 'RESPONSE' for the attribute 'responseIdentifier' for element 'hottextInteraction' is not a valid QTI identifier.

But the original exception message is : A HottextInteraction object must be composed of at least one BlockStatic object, none given.

I think its starts here : \qtism\data\storage\xml\marshalling\responseIdentifier:47

The QtiComponentCollection is empty, and I can't find the correct way to provide a working instance of this to the marshaller

I hope someone can point me to the right direction

Kind regards, Andreas

gewooneendeveloper avatar Jan 20 '20 12:01 gewooneendeveloper