/** * Marshall an numberPresented QTI element in its NumberPresented object equivalent. * * @param DOMElement A DOMElement object. * @return QtiComponent The corresponding NumberPresented object. */ protected function unmarshall(DOMElement $element) { $baseComponent = parent::unmarshall($element); $object = new NumberPresented(); $object->setSectionIdentifier($baseComponent->getSectionIdentifier()); $object->setIncludeCategories($baseComponent->getIncludeCategories()); $object->setExcludeCategories($baseComponent->getExcludeCategories()); return $object; }
protected static function getNumberPresented($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) { $numberPresented = new NumberPresented(); $numberPresented->setSectionIdentifier($sectionIdentifier); if (empty($includeCategories) === false) { $numberPresented->setIncludeCategories($includeCategories); } if (empty($excludeCategories) === false) { $numberPresented->setExcludeCategories($excludeCategories); } return $numberPresented; }
public function testMarshall() { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; $excludeCategory = 'cat2 cat3'; $component = new NumberPresented(); $component->setSectionIdentifier($sectionIdentifier); $component->setIncludeCategories(new IdentifierCollection(explode(" ", $includeCategory))); $component->setExcludeCategories(new IdentifierCollection(explode(" ", $excludeCategory))); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); $element = $marshaller->marshall($component); $this->assertInstanceOf('\\DOMElement', $element); $this->assertEquals('numberPresented', $element->nodeName); $this->assertEquals($sectionIdentifier, $element->getAttribute('sectionIdentifier')); $this->assertEquals($includeCategory, $element->getAttribute('includeCategory')); $this->assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); }