/**
  * Unmarshall a DOMElement object corresponding to a QTI sectionPart element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A SectionPart object.
  * @throws UnmarshallingException
  */
 protected function unmarshall(DOMElement $element)
 {
     if (($identifier = static::getDOMElementAttributeAs($element, 'identifier')) !== null) {
         $object = new SectionPart($identifier);
         if (($required = static::getDOMElementAttributeAs($element, 'required', 'boolean')) !== null) {
             $object->setRequired($required);
         }
         if (($fixed = static::getDOMElementAttributeAs($element, 'fixed', 'boolean')) !== null) {
             $object->setFixed($fixed);
         }
         $preConditionElts = self::getChildElementsByTagName($element, 'preCondition');
         if (count($preConditionElts) > 0) {
             $preConditions = new PreConditionCollection();
             for ($i = 0; $i < count($preConditionElts); $i++) {
                 $marshaller = $this->getMarshallerFactory()->createMarshaller($preConditionElts[$i]);
                 $preConditions[] = $marshaller->unmarshall($preConditionElts[$i]);
             }
             $object->setPreConditions($preConditions);
         }
         $branchRuleElts = self::getChildElementsByTagName($element, 'branchRule');
         if (count($branchRuleElts) > 0) {
             $branchRules = new BranchRuleCollection();
             for ($i = 0; $i < count($branchRuleElts); $i++) {
                 $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRuleElts[$i]);
                 $branchRules[] = $marshaller->unmarshall($branchRuleElts[$i]);
             }
             $object->setBranchRules($branchRules);
         }
         $itemSessionControlElts = self::getChildElementsByTagName($element, 'itemSessionControl');
         if (count($itemSessionControlElts) == 1) {
             $marshaller = $this->getMarshallerFactory()->createMarshaller($itemSessionControlElts[0]);
             $object->setItemSessionControl($marshaller->unmarshall($itemSessionControlElts[0]));
         }
         $timeLimitsElts = self::getChildElementsByTagName($element, 'timeLimits');
         if (count($timeLimitsElts) == 1) {
             $marshaller = $this->getMarshallerFactory()->createMarshaller($timeLimitsElts[0]);
             $object->setTimeLimits($marshaller->unmarshall($timeLimitsElts[0]));
         }
         return $object;
     } else {
         $msg = "The mandatory attribute 'identifier' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
 public function getComponents()
 {
     $comp = array_merge(parent::getComponents()->getArrayCopy(), $this->getTemplateDefaults()->getArrayCopy(), $this->getVariableMappings()->getArrayCopy(), $this->getWeights()->getArrayCopy());
     return new QtiComponentCollection($comp);
 }
Example #3
0
 /**
  * @see \qtism\data\SectionPart::getComponents()
  */
 public function getComponents()
 {
     $comp = array_merge(parent::getComponents()->getArrayCopy(), $this->getRubricBlocks()->getArrayCopy(), $this->getSectionParts()->getArrayCopy());
     if ($this->getSelection() !== null) {
         $comp[] = $this->getSelection();
     }
     if ($this->getOrdering() !== null) {
         $comp[] = $this->getOrdering();
     }
     return new QtiComponentCollection($comp);
 }
 /**
  * Create a new instance of AssessmentSectionRef.
  * 
  * @param string $identifier A QTI Identifier.
  * @param string $href A URI.
  * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier.
  */
 public function __construct($identifier, $href)
 {
     parent::__construct($identifier);
     $this->setHref($href);
 }