Using the Setting service

The Setting service is an unofficial extension to LTI which allows a tool provider to save and retrieve a small amount of data to/from a resource link in the tool consumer. This provides a simple mechanism for storing values without having to extend the data model in the tool provider application. For example, a publisher might save the chapter number of a text which the VLE link relates to.

Sample code

Open the setting.php file in a text editor and replace the "[RESOURCE_LINK_ID]" text with the resource link ID displayed in the earlier launch exercise. Open the page in a browser and check the result of the request. Try using the EXT_READ and EXT_DELETE actions as well.

setting.php

<?php

// Load LTI classes
require_once('LTI_Tool_Provider.php');

$db = new PDO('sqlite:lti-workshop.sqlitedb');

$consumer = new LTI_Tool_Consumer('jisc.ac.uk', $db);
$resource_link = new LTI_Resource_Link($consumer, '[RESOURCE_LINK_ID]');

$setting = 'Today is ...';
$ok = $resource_link->doSettingService(LTI_Resource_Link::EXT_WRITE, $setting);

echo "Result = {$ok}\n\n";
echo $resource_linkext->ext_response;

?>