Moodle Plugins directory: LTI Message Handler | Moodle.org
LTI Message Handler
LTI Message Handler
by Western Canadian Learning Network.
This Moodle LTI Source plugin allows communication between an LTI tool and a consumer site. It is meant to replicate message handling functions implemented in Canvas. Thus, if an LTI provider makes use of Canvas' functions, this plugin will work similarly.
The main purpose of this plugin is to allow iFrame resizing. The LTI iFrames in Moodle are laughably small and impossible to view course content in. With this plugin installed, an LTI tool provider may send messages to the tool consumer instructing it to resize the iFrame.
See the screenshots which show an LTI book with and without this plugin installed.
Installation:
This plugin should be installed on the tool consumer site. See "Usage" for how to make use of this plugin as a tool provider.
- Download this repository.
- Extract the ZIP to 'mod/lti/source/'.
- The folder name within the source directory should be "message_handler".
- Login to your Moodle site as an administrator and install the plugin.
or
- Login to your Moodle site as an admin and go to Administration -> Site administration -> Plugins -> Install plugins.
- Upload the ZIP file.
Usage:
Once the plugin is installed on the tool consumer site, the tool provider may communicate with it as follows.
// Send message to the tool consumer to resize the iframe. Height will be accepted as an integer or a string.
window.parent.postMessage(JSON.stringify({subject: 'lti.frameResize', height: 1000}), '*');
// Send message to the tool consumer to resize the iframe.
window.parent.postMessage(JSON.stringify({subject: 'lti.scrollToTop'}), '*');
// Send a message to the tool consumer to remove the iframe border. window.parent.postMessage(JSON.stringify({subject: 'lti.removeBorder'}), '*');
For example, if a tool provider is returning a page 'index.html' to be displayed in the iframe, they should add a JavaScript file similar to above.
Note: While you can install this plugin on your site receiving LTI content, the LTI provider must implement one of the above to actually use the functions.
Possible message subjects:
- lti.frameResize
- lti.scrollToTop
- lti.removeBorder
If you enjoyed this plugin, please vote for it to be included in Moodle core! https://tracker.moodle.org/browse/MDL-64972
Created by Colin Perepelken for Western Canadian Learning Network.
However, it sounds like you might be using Moodle's built in LTI provider functionality? I haven't tested this plugin with that, as it is intended for custom provider applications in which you can implement your own functions to send messages. If you are using Moodle's built in LTI provider, you may have to edit that core code to send the frameResize messsages.
We're planning to upgrade to Moodle 4.1. Would the current version of the plugin work on Moodle 4.x?