LTI Integration Library 5.1.4
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
Item Class Reference

Class to represent a content-item object. More...

+ Inheritance diagram for Item:

Public Member Functions

 __construct (string $type, array|Placement|null $placementAdvices=null, ?string $id=null)
 Class constructor.
 
void setUrl (?string $url)
 Set a URL value for the content-item.
 
void setMediaType (?string $mediaType)
 Set a media type value for the content-item.
 
void setTitle (?string $title)
 Set a title value for the content-item.
 
void setText (?string $text)
 Set a link text value for the content-item.
 
void setHtml (?string $html)
 Set an HTML embed value for the content-item.
 
bool addPlacementAdvice (?Placement $placementAdvice)
 Add a placement for the content-item.
 
void setIcon (?Image $icon)
 Set an icon image for the content-item.
 
void setThumbnail (?Image $thumbnail)
 Set a thumbnail image for the content-item.
 
void setHideOnCreate (?bool $hideOnCreate)
 Set whether the content-item should be hidden from learners by default.
 

Static Public Member Functions

static string toJson (array|Item $items, LtiVersion $ltiVersion=LtiVersion::V1)
 Wrap the content items to form a complete application/vnd.ims.lti.v1.contentitems+json media type instance.
 
static array fromJson (object|array $items)
 Generate an array of Item objects from their JSON representation.
 
static Item LtiLinkItem FileItem null fromJsonItem (object $item)
 Generate an Item object from its JSON or JSON-LD representation.
 

Public Attributes

const TYPE_LINK = 'link'
 Type for link content-item.
 
const TYPE_LTI_LINK = 'ltiResourceLink'
 Type for LTI link content-item.
 
const TYPE_LTI_ASSIGNMENT = 'ltiAssignment'
 Type for LTI assignment content-item.
 
const TYPE_FILE = 'file'
 Type for file content-item.
 
const TYPE_HTML = 'html'
 Type for HTML content-item.
 
const TYPE_IMAGE = 'image'
 Type for image content-item.
 
const LTI_LINK_MEDIA_TYPE = 'application/vnd.ims.lti.v1.ltilink'
 Media type for LTI launch links.
 
const LTI_ASSIGNMENT_MEDIA_TYPE = 'application/vnd.ims.lti.v1.ltiassignment'
 Media type for LTI assignment links.
 

Protected Member Functions

object toJsonldObject ()
 Wrap the content item to form an item complying with the application/vnd.ims.lti.v1.contentitems+json media type.
 
object toJsonObject ()
 Wrap the content items to form a complete value for the https://purl.imsglobal.org/spec/lti-dl/claim/content_items claim.
 
bool fromJsonObject (object $item)
 Extract content-item details from its JSON representation.
 

Detailed Description

Class to represent a content-item object.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Constructor & Destructor Documentation

◆ __construct()

__construct ( string $type,
array|Placement|null $placementAdvices = null,
?string $id = null )

Class constructor.

Parameters
string$typeClass type of content-item
Placement[] | Placement | null$placementAdvicesArray of Placement objects (or single placement object) for item (optional)
string | null$idURL of content-item (optional)

Member Function Documentation

◆ addPlacementAdvice()

bool addPlacementAdvice ( ?Placement $placementAdvice)

Add a placement for the content-item.

Parameters
Placement | null$placementAdvicePlacement advice object
Returns
bool True if a placement was added

◆ fromJson()

static array fromJson ( object|array $items)
static

Generate an array of Item objects from their JSON representation.

Parameters
object | array$itemsA JSON object or array representing Content-Items
Returns
array Array of Item objects

◆ fromJsonItem()

static Item LtiLinkItem FileItem null fromJsonItem ( object $item)
static

Generate an Item object from its JSON or JSON-LD representation.

Parameters
object$itemA JSON or JSON-LD object representing a content-item
Returns
Item|LtiLinkItem|FileItem|null The content-item object

◆ fromJsonObject()

bool fromJsonObject ( object $item)
protected

Extract content-item details from its JSON representation.

Parameters
object$itemA JSON object representing a content-item
Returns
bool True if the item is valid

Reimplemented in FileItem, and LtiLinkItem.

◆ setHideOnCreate()

void setHideOnCreate ( ?bool $hideOnCreate)

Set whether the content-item should be hidden from learners by default.

Parameters
bool | null$hideOnCreateTrue if the item should be hidden from learners

◆ setHtml()

void setHtml ( ?string $html)

Set an HTML embed value for the content-item.

Parameters
string | null$htmlHTML text value

◆ setIcon()

void setIcon ( ?Image $icon)

Set an icon image for the content-item.

Parameters
Image | null$iconIcon image object

◆ setMediaType()

void setMediaType ( ?string $mediaType)

Set a media type value for the content-item.

Parameters
string | null$mediaTypeMedia type value

◆ setText()

void setText ( ?string $text)

Set a link text value for the content-item.

Parameters
string | null$textLink text value

◆ setThumbnail()

void setThumbnail ( ?Image $thumbnail)

Set a thumbnail image for the content-item.

Parameters
Image | null$thumbnailThumbnail image object

◆ setTitle()

void setTitle ( ?string $title)

Set a title value for the content-item.

Parameters
string | null$titleTitle value

◆ setUrl()

void setUrl ( ?string $url)

Set a URL value for the content-item.

Parameters
string | null$urlURL value

◆ toJson()

static string toJson ( array|Item $items,
LtiVersion $ltiVersion = LtiVersion::V1 )
static

Wrap the content items to form a complete application/vnd.ims.lti.v1.contentitems+json media type instance.

Parameters
Item[] | Item$itemsAn array of content items or a single item
LtiVersion$ltiVersionLTI version in use
Returns
string

◆ toJsonldObject()

object toJsonldObject ( )
protected

Wrap the content item to form an item complying with the application/vnd.ims.lti.v1.contentitems+json media type.

Returns
object JSON object

Reimplemented in FileItem, and LtiLinkItem.

◆ toJsonObject()

object toJsonObject ( )
protected

Wrap the content items to form a complete value for the https://purl.imsglobal.org/spec/lti-dl/claim/content_items claim.

Returns
object JSON object

Reimplemented in FileItem, and LtiLinkItem.