29 function __construct($type, $placementAdvice = null, $id = null)
32 $this->{
'@type'} = $type;
33 if (is_object($placementAdvice) && (count(get_object_vars($placementAdvice)) > 0)) {
34 $this->placementAdvice = $placementAdvice;
66 if (!empty($mediaType)) {
67 $this->mediaType = $mediaType;
69 unset($this->mediaType);
83 $this->title = $title;
84 }
else if (isset($this->title)) {
100 }
else if (isset($this->text)) {
125 $obj = new \stdClass();
126 $obj->{
'@context'} =
'http://purl.imsglobal.org/ctx/lti/v1/ContentItem';
127 if (!is_array($items)) {
128 $obj->{
'@graph'} = array();
129 $obj->{
'@graph'}[] = $items;
131 $obj->{
'@graph'} = $items;
134 return json_encode($obj);
static toJson($items)
Wrap the content items to form a complete application/vnd.ims.lti.v1.contentitems+json media type ins...
const LTI_LINK_MEDIA_TYPE
Media type for LTI launch links.
setUrl($url)
Set a URL value for the content-item.
Class to represent a content-item object.
setTitle($title)
Set a title value for the content-item.
setMediaType($mediaType)
Set a media type value for the content-item.
__construct($type, $placementAdvice=null, $id=null)
Class constructor.
setText($text)
Set a link text value for the content-item.