Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

(no description)

File Size: 467 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Context:: (25 methods):
  __construct()
  initialize()
  initialise()
  save()
  delete()
  getConsumer()
  setConsumerId()
  getKey()
  getId()
  getRecordId()
  setRecordId()
  getDataConnector()
  getSetting()
  setSetting()
  getSettings()
  setSettings()
  saveSettings()
  hasToolSettingsService()
  getToolSettings()
  setToolSettings()
  hasMembershipService()
  getMembership()
  fromRecordId()
  fromConsumer()
  load()


Class: Context  - X-Ref

Class to represent a tool consumer context

__construct()   X-Ref
Class constructor.


initialize()   X-Ref
Initialise the context.


initialise()   X-Ref
Initialise the context.

Pseudonym for initialize().

save()   X-Ref
Save the context to the database.

return: boolean True if the context was successfully saved.

delete()   X-Ref
Delete the context from the database.

return: boolean True if the context was successfully deleted.

getConsumer()   X-Ref
Get tool consumer.

return: ToolConsumer Tool consumer object for this context.

setConsumerId($consumerId)   X-Ref
Set tool consumer ID.

param: int $consumerId  Tool Consumer ID for this resource link.

getKey()   X-Ref
Get tool consumer key.

return: string Consumer key value for this context.

getId()   X-Ref
Get context ID.

return: string ID for this context.

getRecordId()   X-Ref
Get the context record ID.

return: int Context record ID value

setRecordId($id)   X-Ref
Sets the context record ID.

return: int $id  Context record ID value

getDataConnector()   X-Ref
Get the data connector.

return: mixed Data connector object or string

getSetting($name, $default = '')   X-Ref
Get a setting value.

param: string $name    Name of setting
param: string $default Value to return if the setting does not exist (optional, default is an empty string)
return: string Setting value

setSetting($name, $value = null)   X-Ref
Set a setting value.

param: string $name  Name of setting
param: string $value Value to set, use an empty value to delete a setting (optional, default is null)

getSettings()   X-Ref
Get an array of all setting values.

return: array Associative array of setting values

setSettings($settings)   X-Ref
Set an array of all setting values.

param: array $settings Associative array of setting values

saveSettings()   X-Ref
Save setting values.

return: boolean True if the settings were successfully saved

hasToolSettingsService()   X-Ref
Check if the Tool Settings service is supported.

return: boolean True if this context supports the Tool Settings service

getToolSettings($mode = Service\ToolSettings::MODE_CURRENT_LEVEL, $simple = true)   X-Ref
Get Tool Settings.

param: int      $mode       Mode for request (optional, default is current level only)
param: boolean  $simple     True if all the simple media type is to be used (optional, default is true)
return: mixed The array of settings if successful, otherwise false

setToolSettings($settings = array()   X-Ref
Perform a Tool Settings service request.

param: array    $settings   An associative array of settings (optional, default is none)
return: boolean True if action was successful, otherwise false

hasMembershipService()   X-Ref
Check if the Membership service is supported.

return: boolean True if this context supports the Membership service

getMembership()   X-Ref
Get Memberships.

return: mixed The array of User objects if successful, otherwise false

fromRecordId($id, $dataConnector)   X-Ref
Load the context from the database.

param: int             $id               Record ID of context
param: DataConnector   $dataConnector    Database connection object
return: Context    Context object

fromConsumer($consumer, $ltiContextId)   X-Ref
Class constructor from consumer.

param: ToolConsumer $consumer Consumer instance
param: string $ltiContextId LTI Context ID value
return: Context

load($id = null)   X-Ref
Load the context from the database.

param: int $id     Record ID of context (optional, default is null)
return: boolean True if context was successfully loaded