public function includeAssessmentSectionRefs($validate = false)
    {
        if (($root = $this->getDocumentComponent()) !== null) {
            
            $baseUri = str_replace('\\', '/', $this->getDomDocument()->documentElement->baseURI);
            $pathinfo = pathinfo($baseUri);
            $basePath = $pathinfo['dirname'];
            
            $count = count($root->getComponentsByClassName('assessmentSectionRef'));
            while ($count > 0) {
                $iterator = new QtiComponentIterator($root, array('assessmentSectionRef'));
                foreach ($iterator as $assessmentSectionRef) {
                    $parent = $iterator->parent();
                    $href = $assessmentSectionRef->getHref();
                    
                    if (Url::isRelative($href) === true) {
                        $href = Url::rtrim($basePath) . '/' . Url::ltrim($href);
                        
                        $doc = new XmlDocument();
                        $doc->load($href, $validate);
                        $sectionRoot = $doc->getDocumentComponent();
                        
                        foreach ($sectionRoot->getComponentsByClassName(array('assessmentSectionRef', 'assessmentItemRef')) as $sectionPart) {
                            $newBasePath = Url::ltrim(str_replace($basePath, '', $href));
                            $pathinfo = pathinfo($newBasePath);
                            $newHref = $pathinfo['dirname'] . '/' . Url::ltrim($sectionPart->getHref());
                            $sectionPart->setHref($newHref);
                        }
                        
                        if ($parent instanceof TestPart) {
                            $collection = $parent->getAssessmentSections();
                        } else {
                            $collection = $parent->getSectionParts();
                        }
                        
                        $collection->replace($assessmentSectionRef, $sectionRoot);
                    }
                }
                
                $count = count($root->getComponentsByClassName('assessmentSectionRef'));
            }
        } else {
            $msg = "Cannot resolve assessmentSectionRefs before loading any file.";
            throw new LogicException($msg);
        }
    }
public function includeAssessmentSectionRefs($validate = false)
    {
        if (($root = $this->getDocumentComponent()) !== null) {
            
            $baseUri = str_replace('\\', '/', $this->getDomDocument()->documentElement->baseURI);
            $pathinfo = pathinfo($baseUri);
            $basePath = $pathinfo['dirname'];
            
            $count = count($root->getComponentsByClassName('assessmentSectionRef'));
            while ($count > 0) {
                $iterator = new QtiComponentIterator($root, array('assessmentSectionRef'));
                foreach ($iterator as $assessmentSectionRef) {
                    $parent = $iterator->parent();
                    $href = $assessmentSectionRef->getHref();
                    
                    if (Url::isRelative($href) === true) {
                        $href = Url::rtrim($basePath) . '/' . Url::ltrim($href);
                        
                        $doc = new XmlDocument();
                        $doc->load($href, $validate);
                        $sectionRoot = $doc->getDocumentComponent();
                        
                        foreach ($sectionRoot->getComponentsByClassName(array('assessmentSectionRef', 'assessmentItemRef')) as $sectionPart) {
                            $newBasePath = Url::ltrim(str_replace($basePath, '', $href));
                            $pathinfo = pathinfo($newBasePath);
                            $newHref = $pathinfo['dirname'] . '/' . Url::ltrim($sectionPart->getHref());
                            $sectionPart->setHref($newHref);
                        }
                        
                        if ($parent instanceof TestPart) {
                            $collection = $parent->getAssessmentSections();
                        } else {
                            $collection = $parent->getSectionParts();
                        }
                        
                        $collection->replace($assessmentSectionRef, $sectionRoot);
                    }
                }
                
                $count = count($root->getComponentsByClassName('assessmentSectionRef'));
            }
        } else {
            $msg = "Cannot resolve assessmentSectionRefs before loading any file.";
            throw new LogicException($msg);
        }
    }
public function includeAssessmentSectionRefs ( $ validate = false ) { if ( ( $ root = $ this -> getDocumentComponent ( ) ) !== null ) { $ baseUri = str_replace ( '\\' , '/' , $ this -> getDomDocument ( ) -> documentElement -> baseURI ) ; $ pathinfo = pathinfo ( $ baseUri ) ; $ basePath = $ pathinfo [ 'dirname' ] ; $ count = count ( $ root -> getComponentsByClassName ( 'assessmentSectionRef' ) ) ; while ( $ count > 0 ) { $ iterator = new QtiComponentIterator ( $ root , array ( 'assessmentSectionRef' ) ) ; foreach ( $ iterator as $ assessmentSectionRef ) { $ parent = $ iterator -> parent ( ) ; $ href = $ assessmentSectionRef -> getHref ( ) ; if ( Url :: isRelative ( $ href ) === true ) { $ href = Url :: rtrim ( $ basePath ) . '/' . Url :: ltrim ( $ href ) ; $ doc = new XmlDocument ( ) ; $ doc -> load ( $ href , $ validate ) ; $ sectionRoot = $ doc -> getDocumentComponent ( ) ; foreach ( $ sectionRoot -> getComponentsByClassName ( array ( 'assessmentSectionRef' , 'assessmentItemRef' ) ) as $ sectionPart ) { $ newBasePath = Url :: ltrim ( str_replace ( $ basePath , '' , $ href ) ) ; $ pathinfo = pathinfo ( $ newBasePath ) ; $ newHref = $ pathinfo [ 'dirname' ] . '/' . Url :: ltrim ( $ sectionPart -> getHref ( ) ) ; $ sectionPart -> setHref ( $ newHref ) ; } if ( $ parent instanceof TestPart ) { $ collection = $ parent -> getAssessmentSections ( ) ; } else { $ collection = $ parent -> getSectionParts ( ) ; } $ collection -> replace ( $ assessmentSectionRef , $ sectionRoot ) ; } } $ count = count ( $ root -> getComponentsByClassName ( 'assessmentSectionRef' ) ) ; } } else { $ msg = "Cannot resolve assessmentSectionRefs before loading any file." ; throw new LogicException ( $ msg ) ; } }
Include assessmentSectionRefs component in the current document.

This method includes the assessmentSectionRefs components in the current document. The references
to assessmentSections are resolved. assessmentSectionRefs will be replaced with their assessmentSection
content.

@param boolean $validate (optional) Whether or not validate the content of included assessmentSectionRefs.
@throws \LogicException If the method is called prior the load or loadFromString method was called.
@throws \qtism\data\storage\xml\XmlStorageException If an error occured while parsing or validating files to be included.
Include assessmentSectionRefs component in the current document .