public function resolveTemplateLocation($validate = false)
    {
        if (($root = $this->getDocumentComponent()) !== null) {
            
            if ($root instanceof AssessmentItem && ($responseProcessing = $root->getResponseProcessing()) !== null && ($templateLocation = $responseProcessing->getTemplateLocation()) !== '') {
                
                if (Url::isRelative($templateLocation) === true) {
                    
                    $baseUri = str_replace('\\', '/', $this->getDomDocument()->documentElement->baseURI);
                    $pathinfo = pathinfo($baseUri);
                    $basePath = $pathinfo['dirname'];
                    $templateLocation = Url::rtrim($basePath) . '/' . Url::ltrim($templateLocation);
                    
                    $doc = new XmlDocument();
                    $doc->load($templateLocation, $validate);
                    
                    $newResponseProcessing = $doc->getDocumentComponent();
                    
                    if ($newResponseProcessing instanceof ResponseProcessing) {
                        $root->setResponseProcessing($newResponseProcessing);
                    } else {
                        $msg = "The template at location '${templateLocation}' is not a document containing a QTI responseProcessing element.";
                        throw new XmlStorageException($msg, XmlStorageException::RESOLUTION);
                    }
                }
            }
        } else {
            $msg = "Cannot resolve template location before loading any file.";
            throw new LogicException($msg);
        }
    }
public function resolveTemplateLocation($validate = false)
    {
        if (($root = $this->getDocumentComponent()) !== null) {
            
            if ($root instanceof AssessmentItem && ($responseProcessing = $root->getResponseProcessing()) !== null && ($templateLocation = $responseProcessing->getTemplateLocation()) !== '') {
                
                if (Url::isRelative($templateLocation) === true) {
                    
                    $baseUri = str_replace('\\', '/', $this->getDomDocument()->documentElement->baseURI);
                    $pathinfo = pathinfo($baseUri);
                    $basePath = $pathinfo['dirname'];
                    $templateLocation = Url::rtrim($basePath) . '/' . Url::ltrim($templateLocation);
                    
                    $doc = new XmlDocument();
                    $doc->load($templateLocation, $validate);
                    
                    $newResponseProcessing = $doc->getDocumentComponent();
                    
                    if ($newResponseProcessing instanceof ResponseProcessing) {
                        $root->setResponseProcessing($newResponseProcessing);
                    } else {
                        $msg = "The template at location '${templateLocation}' is not a document containing a QTI responseProcessing element.";
                        throw new XmlStorageException($msg, XmlStorageException::RESOLUTION);
                    }
                }
            }
        } else {
            $msg = "Cannot resolve template location before loading any file.";
            throw new LogicException($msg);
        }
    }
public function resolveTemplateLocation ( $ validate = false ) { if ( ( $ root = $ this -> getDocumentComponent ( ) ) !== null ) { if ( $ root instanceof AssessmentItem && ( $ responseProcessing = $ root -> getResponseProcessing ( ) ) !== null && ( $ templateLocation = $ responseProcessing -> getTemplateLocation ( ) ) !== '' ) { if ( Url :: isRelative ( $ templateLocation ) === true ) { $ baseUri = str_replace ( '\\' , '/' , $ this -> getDomDocument ( ) -> documentElement -> baseURI ) ; $ pathinfo = pathinfo ( $ baseUri ) ; $ basePath = $ pathinfo [ 'dirname' ] ; $ templateLocation = Url :: rtrim ( $ basePath ) . '/' . Url :: ltrim ( $ templateLocation ) ; $ doc = new XmlDocument ( ) ; $ doc -> load ( $ templateLocation , $ validate ) ; $ newResponseProcessing = $ doc -> getDocumentComponent ( ) ; if ( $ newResponseProcessing instanceof ResponseProcessing ) { $ root -> setResponseProcessing ( $ newResponseProcessing ) ; } else { $ msg = "The template at location '${templateLocation}' is not a document containing a QTI responseProcessing element." ; throw new XmlStorageException ( $ msg , XmlStorageException :: RESOLUTION ) ; } } } } else { $ msg = "Cannot resolve template location before loading any file." ; throw new LogicException ( $ msg ) ; } }
Resolve responseProcessing elements with template location.

If the root element of the currently loaded QTI file is an assessmentItem element,
this method will try to resolve responseProcessing fragments referenced by responseProcessing
elements having a templateLocation attribute.

@param boolean $validate Whether or not validate files being included. Default is false.
@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.
Resolve responseProcessing elements with template location .