Exemplo n.º 1
0
 /**
  * Marshall an numberCorrect QTI element in its NumberCorrect object equivalent.
  *
  * @param \DOMElement $element A DOMElement object.
  * @return \qtism\data\QtiComponent The corresponding NumberCorrect object.
  */
 protected function unmarshall(DOMElement $element)
 {
     $baseComponent = parent::unmarshall($element);
     // Please PHP core development team, give us real method overloading !!! :'(
     $object = new NumberCorrect();
     $object->setSectionIdentifier($baseComponent->getSectionIdentifier());
     $object->setIncludeCategories($baseComponent->getIncludeCategories());
     $object->setExcludeCategories($baseComponent->getExcludeCategories());
     return $object;
 }
 public function testMarshall()
 {
     $sectionIdentifier = 'mySection1';
     $includeCategory = 'cat1';
     $excludeCategory = 'cat2 cat3';
     $component = new NumberCorrect();
     $component->setSectionIdentifier($sectionIdentifier);
     $component->setIncludeCategories(new IdentifierCollection(explode(" ", $includeCategory)));
     $component->setExcludeCategories(new IdentifierCollection(explode(" ", $excludeCategory)));
     $marshaller = $this->getMarshallerFactory()->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $this->assertInstanceOf('\\DOMElement', $element);
     $this->assertEquals('numberCorrect', $element->nodeName);
     $this->assertEquals($sectionIdentifier, $element->getAttribute('sectionIdentifier'));
     $this->assertEquals($includeCategory, $element->getAttribute('includeCategory'));
     $this->assertEquals($excludeCategory, $element->getAttribute('excludeCategory'));
 }
 protected static function getNumberCorrect($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null)
 {
     $numberCorrect = new NumberCorrect();
     $numberCorrect->setSectionIdentifier($sectionIdentifier);
     if (empty($includeCategories) === false) {
         $numberCorrect->setIncludeCategories($includeCategories);
     }
     if (empty($excludeCategories) === false) {
         $numberCorrect->setExcludeCategories($excludeCategories);
     }
     return $numberCorrect;
 }