src/Util/DeepLinkResponse.php
public function addFileItem($url, $title=false, $additionalParams = array())
    {
        $item = '{
  "@type" : "FileItem",
  "url" : "http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd",
  "copyAdvice" : "true",
  "expiresAt" : "2014-03-05T00:00:00Z",
  "mediaType" : "application/xml",
  "title" : "Imported from Tsugi",
  "placementAdvice" : {
    "windowTarget" : "_blank"
  }
}';

        if (empty($additionalParams['placementTarget']))
            $additionalParams['placementTarget'] = 'window';
        if (empty($additionalParams['placementWindowTarget']))
            $additionalParams['placementWindowTarget'] = '_blank';
        if (empty($additionalParams['placementWidth']))
            $additionalParams['placementWidth'] = '';
        if (empty($additionalParams['placementHeight']))
            $additionalParams['placementHeight'] = '';

        $json = json_decode($item);
        $json->url = $url;
        if ( $params['title'] ) $json->{'title'} = $params['title'];

        $datetime = (new \DateTime('+1 day'))->format(\DateTime::ATOM);
        $datetime = substr($datetime,0,19) . 'Z';
        $json->expiresAt = $datetime;

        if ($additionalParams['placementTarget'])
            $json->placementAdvice->presentationDocumentTarget = $additionalParams['placementTarget'];
        if ($additionalParams['placementWindowTarget'])
            $json->placementAdvice->windowTarget = $additionalParams['placementWindowTarget'];
        if (! empty($additionalParams['placementWidth']))
            $json->placementAdvice->displayWidth = $additionalParams['placementWidth'];
        if (! empty($additionalParams['placementHeight']))
            $json->placementAdvice->displayHeight = $additionalParams['placementHeight'];

        $json->{'@id'} = ':item'.(count($this->json->{'@graph'})+1);

        $this->json->{'@graph'}[] = $json;
    }
public function addFileItem($url, $title=false, $additionalParams = array())
    {
        $item = '{
  "@type" : "FileItem",
  "url" : "http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd",
  "copyAdvice" : "true",
  "expiresAt" : "2014-03-05T00:00:00Z",
  "mediaType" : "application/xml",
  "title" : "Imported from Tsugi",
  "placementAdvice" : {
    "windowTarget" : "_blank"
  }
}';

        if (empty($additionalParams['placementTarget']))
            $additionalParams['placementTarget'] = 'window';
        if (empty($additionalParams['placementWindowTarget']))
            $additionalParams['placementWindowTarget'] = '_blank';
        if (empty($additionalParams['placementWidth']))
            $additionalParams['placementWidth'] = '';
        if (empty($additionalParams['placementHeight']))
            $additionalParams['placementHeight'] = '';

        $json = json_decode($item);
        $json->url = $url;
        if ( $params['title'] ) $json->{'title'} = $params['title'];

        $datetime = (new \DateTime('+1 day'))->format(\DateTime::ATOM);
        $datetime = substr($datetime,0,19) . 'Z';
        $json->expiresAt = $datetime;

        if ($additionalParams['placementTarget'])
            $json->placementAdvice->presentationDocumentTarget = $additionalParams['placementTarget'];
        if ($additionalParams['placementWindowTarget'])
            $json->placementAdvice->windowTarget = $additionalParams['placementWindowTarget'];
        if (! empty($additionalParams['placementWidth']))
            $json->placementAdvice->displayWidth = $additionalParams['placementWidth'];
        if (! empty($additionalParams['placementHeight']))
            $json->placementAdvice->displayHeight = $additionalParams['placementHeight'];

        $json->{'@id'} = ':item'.(count($this->json->{'@graph'})+1);

        $this->json->{'@graph'}[] = $json;
    }
public function addFileItem ( $ url , $ title = false , $ additionalParams = array ( ) ) { $ item = '{
  "@type" : "FileItem",
  "url" : "http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd",
  "copyAdvice" : "true",
  "expiresAt" : "2014-03-05T00:00:00Z",
  "mediaType" : "application/xml",
  "title" : "Imported from Tsugi",
  "placementAdvice" : {
    "windowTarget" : "_blank"
  }
}' ; if ( empty ( $ additionalParams [ 'placementTarget' ] ) ) $ additionalParams [ 'placementTarget' ] = 'window' ; if ( empty ( $ additionalParams [ 'placementWindowTarget' ] ) ) $ additionalParams [ 'placementWindowTarget' ] = '_blank' ; if ( empty ( $ additionalParams [ 'placementWidth' ] ) ) $ additionalParams [ 'placementWidth' ] = '' ; if ( empty ( $ additionalParams [ 'placementHeight' ] ) ) $ additionalParams [ 'placementHeight' ] = '' ; $ json = json_decode ( $ item ) ; $ json -> url = $ url ; if ( $ params [ 'title' ] ) $ json -> { 'title' } = $ params [ 'title' ] ; $ datetime = ( new \ DateTime ( '+1 day' ) ) -> format ( \ DateTime :: ATOM ) ; $ datetime = substr ( $ datetime , 0 , 19 ) . 'Z' ; $ json -> expiresAt = $ datetime ; if ( $ additionalParams [ 'placementTarget' ] ) $ json -> placementAdvice -> presentationDocumentTarget = $ additionalParams [ 'placementTarget' ] ; if ( $ additionalParams [ 'placementWindowTarget' ] ) $ json -> placementAdvice -> windowTarget = $ additionalParams [ 'placementWindowTarget' ] ; if ( ! empty ( $ additionalParams [ 'placementWidth' ] ) ) $ json -> placementAdvice -> displayWidth = $ additionalParams [ 'placementWidth' ] ; if ( ! empty ( $ additionalParams [ 'placementHeight' ] ) ) $ json -> placementAdvice -> displayHeight = $ additionalParams [ 'placementHeight' ] ; $ json -> { '@id' } = ':item' . ( count ( $ this -> json -> { '@graph' } ) + 1 ) ; $ this -> json -> { '@graph' } [ ] = $ json ; }
addFileItem - Add an File Item

@param url The launch URL of the tool that is about to be placed
@param title A plain text title of the content-item.
@params additionalParams Array of configurable parameters for LTI placement (options: placementTarget, placementWidth, placementHeight)
addFileItem - Add an File Item