Class to represent a platform context.
More...
|
static Context | fromRecordId (int $id, DataConnector $dataConnector) |
| Load the context from the database.
|
|
static Context | fromPlatform (Platform $platform, string $ltiContextId) |
| Class constructor from platform.
|
|
static void | registerApiHook (string $hookName, string $familyCode, string $className) |
| Register the availability of an API hook.
|
|
|
string | $ltiContextId = null |
| Context ID as supplied in the last connection request.
|
|
string | $title = null |
| Context title.
|
|
string | $type = null |
| Context type.
|
|
array | $groupSets = null |
| User group sets (null if the platform does not support the groups enhancement)
|
|
array | $groups = null |
| User groups (null if the platform does not support the groups enhancement)
|
|
HttpMessage | $lastServiceRequest = null |
| HttpMessage object for last service request.
|
|
int | $created = null |
| Timestamp for when the object was created.
|
|
int | $updated = null |
| Timestamp for when the object was last updated.
|
|
|
static string | $USER_ID_HOOK = "UserId" |
| User Id hook name.
|
|
static string | $CONTEXT_ID_HOOK = "ContextId" |
| Context Id hook name.
|
|
static string | $GROUPS_SERVICE_HOOK = "Groups" |
| Course Groups service hook name.
|
|
static string | $MEMBERSHIPS_SERVICE_HOOK = "Memberships" |
| Memberships service hook name.
|
|
static string | $OUTCOMES_SERVICE_HOOK = "Outcomes" |
| Outcomes service hook name.
|
|
static string | $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings" |
| Tool Settings service hook name.
|
|
static string | $ACCESS_TOKEN_SERVICE_HOOK = "AccessToken" |
| Access Token service hook name.
|
|
Class to represent a platform context.
- Author
- Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
- Copyright
- SPV Software Products
- Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3
◆ createLineItem()
bool createLineItem |
( |
LineItem | $lineItem | ) |
|
Create a new line-item.
- Parameters
-
LineItem | $lineItem | Line-item object |
- Returns
- bool True if successful
◆ delete()
Delete the context from the database.
- Returns
- bool True if the context was successfully deleted.
◆ fromPlatform()
Class constructor from platform.
- Parameters
-
Platform | $platform | Platform instance |
string | $ltiContextId | LTI Context ID value |
- Returns
- Context
References Context\getPlatform().
◆ fromRecordId()
static Context fromRecordId |
( |
int | $id, |
|
|
DataConnector | $dataConnector ) |
|
static |
Load the context from the database.
- Parameters
-
int | $id | Record ID of context |
DataConnector | $dataConnector | Database connection object |
- Returns
- Context Context object
◆ getDataConnector()
DataConnector string getDataConnector |
( |
| ) |
|
Get the data connector.
- Returns
- DataConnector|string Data connector object or string
◆ getGroups()
◆ getId()
Get context ID.
- Returns
- string|null ID for this context.
◆ getKey()
Get consumer key.
- Returns
- string Consumer key value for this context.
◆ getLineItems()
LineItem[] bool getLineItems |
( |
?string | $resourceId = null, |
|
|
?string | $tag = null, |
|
|
?int | $limit = null ) |
Get line-items.
- Parameters
-
string | null | $resourceId | Tool resource ID |
string | null | $tag | Tag |
int | null | $limit | Limit of line-items to be returned in each request, null for service default |
- Returns
- LineItem[]|bool Array of LineItem objects or false on error
◆ getMemberships()
array bool getMemberships |
( |
bool | $withGroups = false | ) |
|
Get Memberships.
- Parameters
-
bool | $withGroups | True is group information is to be requested as well |
- Returns
- array|bool The array of UserResult objects if successful, otherwise false
◆ getPlatform()
◆ getRecordId()
int string null getRecordId |
( |
| ) |
|
Get the context record ID.
- Returns
- int|string|null Context record ID value
◆ getSetting()
string getSetting |
( |
string | $name, |
|
|
string | $default = '' ) |
◆ getSettings()
◆ getToolSettings()
array bool getToolSettings |
( |
?ToolSettingsMode | $mode = null, |
|
|
bool | $simple = true ) |
Get Tool Settings.
- Parameters
-
ToolSettingsMode | null | $mode | Mode for request (optional, default is current level only) |
bool | $simple | True if all the simple media type is to be used (optional, default is true) |
- Returns
- array|bool The array of settings if successful, otherwise false
◆ hasGroupService()
Check if a Course Group service is available.
- Returns
- bool True if this context supports a Course Group service
◆ hasLineItemService()
bool hasLineItemService |
( |
| ) |
|
◆ hasMembershipsService()
bool hasMembershipsService |
( |
| ) |
|
Check if a Membership service is available.
- Returns
- bool True if this context supports a Memberships service
◆ hasResultService()
bool hasResultService |
( |
| ) |
|
Check if the Result service is available.
- Returns
- bool True if this context supports the Result service
◆ hasScoreService()
Check if the Score service is available.
- Returns
- bool True if this context supports the Score service
◆ hasToolSettingsService()
bool hasToolSettingsService |
( |
| ) |
|
Check if the Tool Settings service is available.
- Returns
- bool True if this context supports the Tool Settings service
◆ initialise()
Initialise the context.
Synonym for initialize().
◆ save()
Save the context to the database.
- Returns
- bool True if the context was successfully saved.
◆ saveSettings()
Save setting values.
- Returns
- bool True if the settings were successfully saved
◆ setPlatformId()
void setPlatformId |
( |
?int | $platformId | ) |
|
Set platform ID.
- Parameters
-
int | null | $platformId | Platform ID for this context. |
◆ setRecordId()
void setRecordId |
( |
int|string|null | $id | ) |
|
Sets the context record ID.
- Parameters
-
int | string | null | $id | Context record ID value |
◆ setSetting()
void setSetting |
( |
string | $name, |
|
|
string|array|null | $value = null ) |
Set a setting value.
- Parameters
-
string | $name | Name of setting |
string | array | null | $value | Value to set, use an empty value to delete a setting (optional, default is null) |
◆ setSettings()
void setSettings |
( |
array | $settings | ) |
|
Set an array of all setting values.
- Parameters
-
array | $settings | Associative array of setting values |
◆ setToolSettings()
bool setToolSettings |
( |
array | $settings = [] | ) |
|
Set Tool Settings.
- Parameters
-
array | $settings | An associative array of settings (optional, default is none) |
- Returns
- bool True if action was successful, otherwise false
◆ $groups
User groups (null if the platform does not support the groups enhancement)
A group is represented by an associative array with the following elements:
- title
- tag
- hidden
- set (ID of group set, array of IDs if the group belongs to more than one set, omitted if the group is not part of a set) The array key value is the group ID.
◆ $groupSets
User group sets (null if the platform does not support the groups enhancement)
A group set is represented by an associative array with the following elements:
- title
- tag
- hidden
- groups (array of group IDs)
- num_members
- num_staff
- num_learners The array key value is the group set ID.