/**
  * @see \qtism\data\storage\xml\marshalling\Marshaller::unmarshall()
  */
 protected function unmarshall(DOMElement $element)
 {
     $object = new ItemSessionControl();
     if (($value = static::getDOMElementAttributeAs($element, 'maxAttempts', 'integer')) !== null) {
         $object->setMaxAttempts($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'showFeedback', 'boolean')) !== null) {
         $object->setShowFeedback($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'allowReview', 'boolean')) !== null) {
         $object->setAllowReview($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'showSolution', 'boolean')) !== null) {
         $object->setShowSolution($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'allowComment', 'boolean')) !== null) {
         $object->setAllowComment($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'allowSkipping', 'boolean')) !== null) {
         $object->setAllowSkipping($value);
     }
     if (($value = static::getDOMElementAttributeAs($element, 'validateResponses', 'boolean')) !== null) {
         $object->setValidateResponses($value);
     }
     return $object;
 }
 public function testMarshallNotRecursive()
 {
     $identifier = 'myAssessmentSection';
     $title = 'A non Recursive Assessment Section';
     $visible = true;
     $keepTogether = false;
     // preConditions
     $preConditions = new PreConditionCollection();
     $preConditions[] = new PreCondition(new BaseValue(BaseType::BOOLEAN, true));
     // branchRules
     $branchRules = new BranchRuleCollection();
     $branchRules[] = new BranchRule(new BaseValue(BaseType::BOOLEAN, false), 'EXIT_TEST');
     // itemSessionControl
     $itemSessionControl = new ItemSessionControl();
     $itemSessionControl->setAllowReview(true);
     // sectionParts
     $sectionParts = new SectionPartCollection();
     $sectionParts[] = new AssessmentItemRef('Q01', './questions/Q01.xml');
     $sectionParts[] = new AssessmentItemRef('Q02', './questions/Q02.xml');
     $sectionParts[] = new AssessmentSectionRef('S01', './sections/S01.xml');
     $component = new AssessmentSection($identifier, $title, $visible);
     $component->setKeepTogether($keepTogether);
     $component->setPreConditions($preConditions);
     $component->setBranchRules($branchRules);
     $component->setItemSessionControl($itemSessionControl);
     $component->setSectionParts($sectionParts);
     $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $this->assertInstanceOf('\\DOMElement', $element);
     $this->assertEquals($identifier, $element->getAttribute('identifier'));
     $this->assertEquals($title, $element->getAttribute('title'));
     $this->assertEquals('true', $element->getAttribute('visible'));
     $this->assertEquals('false', $element->getAttribute('keepTogether'));
     $this->assertEquals(1, $element->getElementsByTagName('preCondition')->length);
     $this->assertEquals(1, $element->getElementsByTagName('preCondition')->item(0)->getElementsByTagName('baseValue')->length);
     $this->assertEquals(1, $element->getElementsByTagName('branchRule')->length);
     $this->assertEquals(1, $element->getElementsByTagName('branchRule')->item(0)->getElementsByTagName('baseValue')->length);
     $this->assertEquals(1, $element->getElementsByTagName('itemSessionControl')->length);
     $this->assertEquals('true', $element->getElementsByTagName('itemSessionControl')->item(0)->getAttribute('allowReview'));
     $this->assertEquals(2, $element->getElementsByTagName('assessmentItemRef')->length);
     $this->assertEquals('Q02', $element->getElementsByTagName('assessmentItemRef')->item(1)->getAttribute('identifier'));
     $this->assertEquals(1, $element->getElementsByTagName('assessmentSectionRef')->length);
     $this->assertEquals('S01', $element->getElementsByTagName('assessmentSectionRef')->item(0)->getAttribute('identifier'));
 }