{{! This file is part of Moodle - http://moodle.org/ Moodle is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Moodle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Moodle. If not, see . }} {{! @template mod_lti/contentitem Provides a template for the creation of a new external tool instance via the content-item message. Classes required for JS: * none Data attributes required for JS: * none Context variables required for this template: * url The URL the iframe has to load. * postData The JSON object that contains the information to be POSTed for the ContentItemSelectionRequest. Example context (json): { "url": "/", "postData": { "id": "1", "course": "1", "title": "Sample title", "text": "This is a description" } } }}
{{> mod_lti/loader }}

{{#str}} loadinghelp, moodle {{/str}}

{{#js}} require(['jquery'], function($) { var loadingContainer = $('.contentitem-loading-container'); var iframe = $('#contentitem-page-iframe'); var timeout = setTimeout(function () { var failedContainer = $('#tool-loading-failed'); failedContainer.removeClass('hidden'); }, 20000); // Submit form. $('#contentitem-request-form').submit(); iframe.on('load', function() { loadingContainer.addClass('hidden'); iframe.removeClass('hidden'); // Adjust iframe's width to the fit the container's width. var containerWidth = $('div.contentitem-container').width(); $('#contentitem-page-iframe').width(containerWidth + 'px'); // Adjust iframe's height to 75% of the width. var containerHeight = containerWidth * 0.75; $('#contentitem-page-iframe').height(containerHeight + 'px'); }); }); {{/js}}