MDL-69542 enrol_lti: add tool endpoint page to admin settings

This commit is contained in:
Jake Dallimore
2022-02-11 10:35:51 +08:00
parent 0f6239a054
commit 1f3d37390d
7 changed files with 712 additions and 2 deletions
+2
View File
@@ -0,0 +1,2 @@
define ("enrol_lti/tool_endpoints",["exports","core/toast","core/ajax","core/notification","core/modal_factory","core/modal_events","core/str","core/prefetch","core/copy_to_clipboard"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;c=i(c);d=i(d);e=i(e);f=i(f);function i(a){return a&&a.__esModule?a:{default:a}}function j(a,b){return o(a)||n(a,b)||l(a,b)||k()}function k(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(a,b){if(!a)return;if("string"==typeof a)return m(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return m(a,b)}function m(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function n(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function o(a){if(Array.isArray(a))return a}var p={GENERATE_REGISTRATION_URL_BUTTON:"[id^=\"lti_generate_registration_url\"]",REGISTRATION_URL_TABLE:"[id^=\"lti_registration_url_table_\"]",URL_VALUE:"[id^=\"lti_tool_endpoint_url_\"]",URL_INFO:"[id^=\"lti_tool_endpoint_info_\"]",URL_COPY_TO_CLIPBOARD:"[data-action=\"copytoclipboard\"]",URL_DELETE:"[data-action=\"delete\"]"},q=function(){(0,g.get_strings)([{key:"registrationurldeleted",component:"enrol_lti"}]).then(function(a){document.querySelector(p.REGISTRATION_URL_TABLE).classList.add("hidden");var c=document.querySelector(p.GENERATE_REGISTRATION_URL_BUTTON);c.setAttribute("aria-disabled","false");c.removeAttribute("aria-label");c.classList.remove("disabled");c.title="";document.querySelector(p.URL_VALUE).value="";document.querySelector(p.URL_INFO).innerHTML="";c.focus();(0,b.add)(a)}).catch(d.default.exception)},r=function(a){Promise.all([(0,g.get_strings)([{key:"registrationurlgeneratesuccess",component:"enrol_lti"},{key:"registrationurlcannotgenerate",component:"enrol_lti"}]),c.default.call([{methodname:"enrol_lti_get_lti_advantage_registration_url",args:{createifmissing:!0}}])[0]]).then(function(c){var d=j(c,2),e=j(d[0],2),f=e[0],g=e[1],h=d[1];document.querySelector(p.URL_VALUE).value=h.url;document.querySelector(p.URL_INFO).innerHTML=h.expirystring;document.querySelector(p.REGISTRATION_URL_TABLE).classList.remove("hidden");a.setAttribute("aria-disabled","true");a.classList.add("disabled");a.title=g;a.setAttribute("aria-label",g);(0,b.add)(f)}).catch(d.default.exception)},s=function(){return e.default.create({type:e.default.types.SAVE_CANCEL,large:!1,title:(0,g.get_string)("registrationurldeletetitle","enrol_lti"),body:(0,g.get_string)("registrationurldeletebody","enrol_lti")}).then(function(a){a.setSaveButtonText((0,g.get_string)("registrationurldeleteconfirm","enrol_lti"));a.getRoot().on(f.default.save,function(){var a=c.default.call([{methodname:"enrol_lti_delete_lti_advantage_registration_url",args:[]}]);a[0].then(function(a){if(!0===a.status){q()}}).catch(d.default.exception)});a.getRoot().on(f.default.hidden,function(){a.destroy()});return a.show()}).catch(d.default.exception)},t=function(a){var b=a.target.closest(p.GENERATE_REGISTRATION_URL_BUTTON);if(null===b){return}a.preventDefault();if("true"==a.target.getAttribute("aria-disabled")){return}r(a.target)},u=function(a){var b=a.target.closest(p.URL_VALUE);if(null===b){return}a.preventDefault();b.select()},v=function(a){var b=a.target.closest(p.URL_DELETE);if(null===b){return}a.preventDefault();s()};a.init=function init(){(0,h.prefetchStrings)("enrol_lti",["registrationurldeletetitle","registrationurldeletebody","registrationurldeleteconfirm","registrationurlgenerate","registrationurldeleted","registrationurlgeneratesuccess","registrationurlcannotgenerate"]);document.addEventListener("focusin",u);document.addEventListener("click",v);document.addEventListener("click",t)}});
//# sourceMappingURL=tool_endpoints.min.js.map
File diff suppressed because one or more lines are too long
+212
View File
@@ -0,0 +1,212 @@
// 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 <http://www.gnu.org/licenses/>.
/**
* Module supporting the dynamic and manual registration tabs in the tool registration admin setting.
*
* @module enrol_lti/tool_endpoints
* @copyright 2021 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {add as toastNotice} from 'core/toast';
import Ajax from 'core/ajax';
import Notification from 'core/notification';
import ModalFactory from 'core/modal_factory';
import ModalEvents from 'core/modal_events';
import {get_string as getString} from 'core/str';
import {get_strings as getStrings} from 'core/str';
import {prefetchStrings} from 'core/prefetch';
import 'core/copy_to_clipboard';
/**
* DOM Selectors.
* @type {{GENERATE_REGISTRATION_URL_BUTTON: string, URL_COPY_TO_CLIPBOARD: string, URL_VALUE: string,
* REGISTRATION_URL_TABLE: string, URL_DELETE: string, URL_INFO: string}}
*/
const SELECTORS = {
GENERATE_REGISTRATION_URL_BUTTON: '[id^="lti_generate_registration_url"]',
REGISTRATION_URL_TABLE: '[id^="lti_registration_url_table_"]',
URL_VALUE: '[id^="lti_tool_endpoint_url_"]',
URL_INFO: '[id^="lti_tool_endpoint_info_"]',
URL_COPY_TO_CLIPBOARD: '[data-action="copytoclipboard"]',
URL_DELETE: '[data-action="delete"]'
};
/**
* Remove the registration URL from the DOM, restoring the button used to create a URL in the process.
*/
const removeRegistrationURL = () => {
getStrings([
{key: 'registrationurldeleted', component: 'enrol_lti'}
])
.then((deletedStr) => {
document.querySelector(SELECTORS.REGISTRATION_URL_TABLE).classList.add('hidden');
let createURLButton = document.querySelector(SELECTORS.GENERATE_REGISTRATION_URL_BUTTON);
createURLButton.setAttribute('aria-disabled', 'false');
createURLButton.removeAttribute('aria-label');
createURLButton.classList.remove('disabled');
createURLButton.title = '';
document.querySelector(SELECTORS.URL_VALUE).value = '';
document.querySelector(SELECTORS.URL_INFO).innerHTML = '';
createURLButton.focus();
// Let the user know the URL was deleted.
toastNotice(deletedStr);
return;
})
.catch(Notification.exception);
};
/**
* Create and display the registration URL component in the DOM.
*
* @param {HTMLElement} generateButton the button responsible for generating the URL, which will be disabled once a URL is created.
*/
const createAndDisplayRegistrationURL = (generateButton) => {
let requests = [
{methodname: 'enrol_lti_get_lti_advantage_registration_url', args: {'createifmissing': true}},
];
Promise.all([
getStrings([
{key: 'registrationurlgeneratesuccess', component: 'enrol_lti'},
{key: 'registrationurlcannotgenerate', component: 'enrol_lti'}
]),
Ajax.call(requests)[0]
])
.then(([[generateSuccessStr, cannotGenerateStr], urlObject]) => {
document.querySelector(SELECTORS.URL_VALUE).value = urlObject.url;
document.querySelector(SELECTORS.URL_INFO).innerHTML = urlObject.expirystring;
document.querySelector(SELECTORS.REGISTRATION_URL_TABLE).classList.remove('hidden');
generateButton.setAttribute('aria-disabled', 'true');
generateButton.classList.add('disabled');
generateButton.title = cannotGenerateStr;
generateButton.setAttribute('aria-label', cannotGenerateStr);
toastNotice(generateSuccessStr);
return;
})
.catch(Notification.exception);
};
/**
* Display a delete confirmation modal.
*
* @returns {Promise}
*/
const showDeleteModal = () => {
return ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
large: false,
title: getString('registrationurldeletetitle', 'enrol_lti'),
body: getString('registrationurldeletebody', 'enrol_lti')
})
.then(modal => {
modal.setSaveButtonText(getString('registrationurldeleteconfirm', 'enrol_lti'));
modal.getRoot().on(ModalEvents.save, () => {
let requests = [
{methodname: 'enrol_lti_delete_lti_advantage_registration_url', args: []},
];
let promises = Ajax.call(requests);
promises[0].then((result) => {
if (result.status === true) {
removeRegistrationURL();
}
return;
}).catch(Notification.exception);
});
modal.getRoot().on(ModalEvents.hidden, function() {
modal.destroy();
});
return modal.show();
})
.catch(Notification.exception);
};
/**
* Click handler which generates a registration URL and updates the DOM.
*
* @param {Event} event a click event.
*/
const generateRegistrationURLHandler = (event) => {
const triggerElement = event.target.closest(SELECTORS.GENERATE_REGISTRATION_URL_BUTTON);
if (triggerElement === null) {
return;
}
event.preventDefault();
if (event.target.getAttribute('aria-disabled') == "true") {
return;
}
createAndDisplayRegistrationURL(event.target);
};
/**
* Focus handler for the registration URL field, enabling auto select of text on click.
*
* @param {Event} event a click event.
*/
const focusURLHandler = (event) => {
const triggerElement = event.target.closest(SELECTORS.URL_VALUE);
if (triggerElement === null) {
return;
}
event.preventDefault();
triggerElement.select();
};
/**
* Click handler which generates a user confirmation modal during URL deletion.
*
* @param {Event} event a click event.
*/
const deleteClickHandler = (event) => {
const triggerElement = event.target.closest(SELECTORS.URL_DELETE);
if (triggerElement === null) {
return;
}
event.preventDefault();
showDeleteModal();
};
/**
* Initialise the tool registration page, attaching handlers, prefetching strings, etc.
*/
export const init = () => {
prefetchStrings('enrol_lti', [
'registrationurldeletetitle',
'registrationurldeletebody',
'registrationurldeleteconfirm',
'registrationurlgenerate',
'registrationurldeleted',
'registrationurlgeneratesuccess',
'registrationurlcannotgenerate'
]);
// Event capturing supporting the select on focus behaviour (with text selection permitted on subsequent clicks).
document.addEventListener('focusin', focusURLHandler);
// And delegation for deleting the URL.
document.addEventListener('click', deleteClickHandler);
// And delegation for creating a new registration URL.
document.addEventListener('click', generateRegistrationURLHandler);
};
@@ -0,0 +1,161 @@
<?php
// 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 <http://www.gnu.org/licenses/>.
namespace enrol_lti\local\ltiadvantage\admin;
use enrol_lti\local\ltiadvantage\repository\application_registration_repository;
use enrol_lti\local\ltiadvantage\repository\context_repository;
use enrol_lti\local\ltiadvantage\repository\deployment_repository;
use enrol_lti\local\ltiadvantage\repository\resource_link_repository;
use enrol_lti\local\ltiadvantage\repository\user_repository;
use enrol_lti\local\ltiadvantage\service\application_registration_service;
/**
* The admin_setting_toolendpoints class, for rendering a table of tool endpoints.
*
* This setting is useful for LTI 1.3 only.
*
* @package enrol_lti
* @copyright 2021 Jake Dallimore <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_toolendpoints extends \admin_setting {
/**
* Calls parent::__construct with specific arguments
*/
public function __construct() {
$this->nosave = true;
parent::__construct('enrol_lti_tool_endpoints', get_string('toolendpoints', 'enrol_lti'), '', '');
}
/**
* Always returns true, does nothing.
*
* @return bool true.
*/
public function get_setting() {
return true;
}
/**
* Always returns true, does nothing.
*
* @return bool true.
*/
public function get_defaultsetting() {
return true;
}
/**
* Always returns '', does not write anything.
*
* @param string|array $data the data
* @return string Always returns ''.
*/
public function write_setting($data) {
return '';
}
/**
* Checks if $query is one of the available external services
*
* @param string $query The string to search for
* @return bool Returns true if found, false if not
*/
public function is_related($query) {
if (parent::is_related($query)) {
return true;
}
// Let the search match any of the horizontal table headings.
$strings = [
get_string('toolurl', 'enrol_lti'),
get_string('loginurl', 'enrol_lti'),
get_string('jwksurl', 'enrol_lti'),
get_string('deeplinkingurl', 'enrol_lti')
];
foreach ($strings as $str) {
if (stripos($str, $query) !== false) {
return true;
}
}
return false;
}
/**
* Builds the HTML to display the table.
*
* @param string $data Unused
* @param string $query
* @return string
*/
public function output_html($data, $query='') {
global $PAGE, $CFG;
$appregservice = new application_registration_service(
new application_registration_repository(),
new deployment_repository(),
new resource_link_repository(),
new context_repository(),
new user_repository()
);
$regurl = $appregservice->get_registration_url();
$expiryinfo = $regurl ? get_string('registrationurlexpiry', 'enrol_lti',
date('H:i, M dS, Y', $regurl->get_expiry_time())) : null;
$endpoints = [
'dynamic_registration_info' => get_string(
'registrationurlinfomessage',
'enrol_lti',
get_docs_url('Publish_as_LTI_tool')
),
'dynamic_registration_url' => [
'name' => get_string('registrationurl', 'enrol_lti'),
'url' => $regurl,
'expiryinfo' => $expiryinfo,
'id' => uniqid()
],
'manual_registration_info' => get_string('endpointltiversionnotice', 'enrol_lti'),
'manual_registration_urls' => [
[
'name' => get_string('toolurl', 'enrol_lti'),
'url' => $CFG->wwwroot . '/enrol/lti/launch.php',
'id' => uniqid()
],
[
'name' => get_string('loginurl', 'enrol_lti'),
'url' => $CFG->wwwroot . '/enrol/lti/login.php',
'id' => uniqid()
],
[
'name' => get_string('jwksurl', 'enrol_lti'),
'url' => $CFG->wwwroot . '/enrol/lti/jwks.php',
'id' => uniqid()
],
[
'name' => get_string('deeplinkingurl', 'enrol_lti'),
'url' => $CFG->wwwroot . '/enrol/lti/launch_deeplink.php',
'id' => uniqid()
],
],
];
$renderer = $PAGE->get_renderer('enrol_lti');
$return = $renderer->render_admin_setting_tool_endpoints($endpoints);
return highlight($query, $return);
}
}
+130 -1
View File
@@ -26,8 +26,10 @@ namespace enrol_lti\output;
defined('MOODLE_INTERNAL') || die();
use core\output\notification;
use enrol_lti\local\ltiadvantage\repository\deployment_repository;
use Packback\Lti1p3\LtiMessageLaunch;
use plugin_renderer_base;
use renderable;
/**
* Renderer class for LTI enrolment
@@ -47,4 +49,131 @@ class renderer extends plugin_renderer_base {
$data = $registration->export_for_template($this);
return parent::render_from_template("enrol_lti/proxy_registration", $data);
}
/**
* Render the content item selection (deep linking 2.0) view
*
* This view is a form containing a list of courses and modules which, once selected and submitted, will result in
* a list of LTI Resource Link Content Items being sent back to the platform, allowing resource link creation to
* take place.
*
* @param LtiMessageLaunch $launch the launch data.
* @param array $resources array of published resources available to the current user.
* @return string html
*/
public function render_published_resource_selection_view(LtiMessageLaunch $launch, array $resources): string {
global $CFG;
$context = [
'action' => $CFG->wwwroot . '/enrol/lti/configure.php',
'launchid' => $launch->getLaunchId(),
'hascontent' => !empty($resources),
'sesskey' => sesskey(),
'courses' => []
];
foreach ($resources as $resource) {
$context['courses'][$resource->get_courseid()]['fullname'] = $resource->get_coursefullname();
if (!$resource->is_course()) {
$context['courses'][$resource->get_courseid()]['modules'][] = [
'name' => $resource->get_name(),
'id' => $resource->get_id(),
'lineitem' => $resource->supports_grades()
];
if (empty($context['courses'][$resource->get_courseid()]['shared_course'])) {
$context['courses'][$resource->get_courseid()]['shared_course'] = false;
}
} else {
$context['courses'][$resource->get_courseid()]['shared_course'] = $resource->is_course();
$context['courses'][$resource->get_courseid()]['id'] = $resource->get_id();
$context['courses'][$resource->get_courseid()]['lineitem'] = $resource->supports_grades();
}
}
$context['courses'] = array_values($context['courses']); // Reset keys for use in the template.
return parent::render_from_template('enrol_lti/local/ltiadvantage/content_select', $context);
}
/**
* Render the table of tool endpoints as part of admin_setting_toolendpoints.
*
* @param array $endpoints the endpoints array (see admin_setting_toolendpoints for details).
* @return string the html.
*/
public function render_admin_setting_tool_endpoints(array $endpoints): string {
$return = parent::render_from_template('enrol_lti/local/ltiadvantage/tool_endpoints', $endpoints);
return $return;
}
/**
* Render the table applications which have been registered as LTI Advantage platforms.
*
* @param array $registrations The list of registrations to render.
* @return string the html.
*/
public function render_admin_setting_registered_platforms(array $registrations): string {
$registrationscontext = [
'registrations' => [],
'addurl' => (new \moodle_url('/enrol/lti/register_platform.php', ['action' => 'add']))->out(false),
];
$registrationscontext['hasregs'] = count($registrations) > 0;
$deploymentrepository = new deployment_repository();
foreach ($registrations as $reg) {
$countdeployments = $deploymentrepository->count_by_registration($reg->get_id());
$registrationscontext['registrations'][] = [
'name' => $reg->get_name(),
'issuer' => $reg->get_platformid(),
'clientid' => $reg->get_clientid(),
'hasdeployments' => $countdeployments > 0,
'countdeployments' => $countdeployments,
'editurl' => (new \moodle_url('/enrol/lti/register_platform.php',
['action' => 'edit', 'regid' => $reg->get_id()]))->out(false),
'deleteurl' => (new \moodle_url('/enrol/lti/register_platform.php',
['action' => 'delete', 'regid' => $reg->get_id()]))->out(false),
'deploymentsurl' => (new \moodle_url('/enrol/lti/app_tool_deployments.php',
['registrationid' => $reg->get_id()]))->out(false)
];
}
// Notice to let users know this is LTI Advantage ONLY.
$versionnotice = new notification(
get_string('registeredplatformsltiversionnotice', 'enrol_lti'),
notification::NOTIFY_INFO
);
$versionnotice->set_show_closebutton(false);
$return = parent::render($versionnotice);
$return .= parent::render_from_template('enrol_lti/local/ltiadvantage/registered_platforms',
$registrationscontext);
return $return;
}
/**
* Render the table of registered tool deployments for a given application registration.
*
* @param int $registrationid the application registration id.
* @param array $deployments the list of deployments.
* @return string the html.
*/
public function render_registered_tool_deployments(int $registrationid, array $deployments): string {
$deploymentscontext = [
'deployments' => [],
'hasdeployments' => !empty($deployments),
'addurl' => (new \moodle_url('/enrol/lti/manage_deployment.php',
['action' => 'add', 'registrationid' => $registrationid]))->out(false),
'backurl' => (new \moodle_url('/admin/settings.php',
['section' => 'enrolsettingslti_registrations']))->out(false),
];
foreach ($deployments as $deployment) {
$deploymentscontext['deployments'][] = [
'name' => $deployment->get_deploymentname(),
'deploymentid' => $deployment->get_deploymentid(),
'deleteurl' => (new \moodle_url(
'/enrol/lti/manage_deployment.php',
['action' => 'delete', 'id' => $deployment->get_id(), 'registrationid' => $registrationid]
))->out(false),
];
}
return parent::render_from_template('enrol_lti/local/ltiadvantage/registered_deployments',
$deploymentscontext);
}
}
+42 -1
View File
@@ -22,10 +22,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use enrol_lti\local\ltiadvantage\admin\admin_setting_toolendpoints;
use enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms;
defined('MOODLE_INTERNAL') || die;
// The 'Publish as LTI tool' node is a category.
$ADMIN->add('enrolments', new admin_category('enrolltifolder', new lang_string('pluginname', 'enrol_lti'),
$this->is_enabled() === false));
$settings = new admin_settingpage($section, "User default values", 'moodle/site:config', $this->is_enabled() === false);
// Add all the user default values settings to the first page.
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('enrol_lti_settings', '', get_string('pluginname_desc', 'enrol_lti')));
if (!is_enabled_auth('lti')) {
@@ -72,3 +79,37 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('enrol_lti/institution', get_string('institution'), '', ''));
}
$ADMIN->add('enrolltifolder', $settings);
// Now, create a tool registrations settings page.
$settings = new admin_settingpage('enrolsettingslti_registrations', "Tool registration", 'moodle/site:config',
$this->is_enabled() === false);
$settings->add(new admin_setting_heading('enrol_lti_tool_endpoints_heading',
get_string('registrationendpoints', 'enrol_lti'), ''));
$settings->add(new admin_setting_toolendpoints());
$settings->add(new admin_setting_heading('enrol_lti_tool_registrations_heading',
get_string('registeredplatforms', 'enrol_lti'), ''));
$settings->add(new admin_setting_registeredplatforms());
$ADMIN->add('enrolltifolder', $settings);
// This adds a settings page to the 'publish as LTI tool' folder, hidden.
// On this page, we'll override the active node to force a match on enrolsettingslti_registrations settings page.
$ADMIN->add('enrolltifolder', new admin_externalpage('enrolsettingslti_registrations_edit',
get_string('registerplatformadd', 'enrol_lti'), "$CFG->wwwroot/$CFG->admin/enrol/lti/register_platform.php",
'moodle/site:config', true));
// And do the same for the deployments list.
$ADMIN->add('enrolltifolder', new admin_externalpage('enrolsettingslti_deployments_list',
get_string('deployments', 'enrol_lti'), "$CFG->wwwroot/$CFG->admin/enrol/lti/app_tool_deployments.php",
'moodle/site:config', true));
// And deployments add/edit.
$ADMIN->add('enrolltifolder', new admin_externalpage('enrolsettingslti_deployment_manage',
get_string('deployments', 'enrol_lti'), "$CFG->wwwroot/$CFG->admin/enrol/lti/manage_deployment.php",
'moodle/site:config', true));
// Tell core we're finished.
$settings = null;
@@ -0,0 +1,164 @@
{{!
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 <http://www.gnu.org/licenses/>.
}}
{{!
@template enrol_lti/tool_endpoints
Template which displays a list of tool endpoint URLs, allowing the values to be copied to the clipboard via js.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* dynamic_registration_url
* manual_registration_url
Example context (json):
{
"dynamic_registration_url": {
"id": "ab34dgdfa",
"name": "Dynamic registration URL",
"url": "https://example.com/enrol/lti/register.php?tok=asdb123b12babsdb"
},
"manual_registration_urls": [
{
"id": "asdb1234m",
"name": "Authentication Request URL",
"url": "https://example.com/enrol/lti/login.php"
},
{
"id": "123GHn123",
"name": "JWKS URL",
"url": "https://example.com/enrol/lti/jwks.php"
}
]
}
}}
<ul class="nav nav-tabs mb-3" id="registration-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="dynamic-registration-tab" data-toggle="tab" href="#dynamic" role="tab" aria-controls="dynamic" aria-selected="true">
{{#str}}registrationdynamic, enrol_lti{{/str}}
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="manual-registration-tab" data-toggle="tab" href="#manual" role="tab" aria-controls="manual" aria-selected="false">
{{#str}}registrationmanual, enrol_lti{{/str}}
</a>
</li>
</ul>
<div class="tab-content" id="registration-tab-content">
<div class="tab-pane fade show active" id="dynamic" role="tabpanel" aria-labelledby="dynamic-registration-tab">
<div class="alert alert-info alert-block">
{{{dynamic_registration_info}}}
</div>
{{#dynamic_registration_url}}
<div id="lti_registration_endpoint" aria-live="polite">
<div id="lti_registration_url_table_{{id}}" class="{{^url}}hidden{{/url}}">
<label class="bold" for="lti_tool_endpoint_url_{{id}}">Registration URL</label>
<hr>
<div class="input-group col-md-6 ml-0 pl-0">
<input class="form-control" type="text" value="{{url}}" aria-label="{{url}}" id="lti_tool_endpoint_url_{{id}}" readonly>
<div class="input-group-append">
<a class="btn btn-secondary"
href="#"
role="button"
aria-label="{{#str}} copytoclipboard, enrol_lti {{/str}}"
data-action="copytoclipboard"
data-clipboard-success-message="{{#str}}copiedtoclipboard, enrol_lti, {{name}}{{/str}}"
data-clipboard-target="#lti_tool_endpoint_url_{{id}}"
id="{{id}}"
title="{{#str}}copytoclipboard, enrol_lti{{/str}}">
<span class="pix">{{#pix}} t/clipboard, core {{/pix}}</span>
</a>
</div>
<div class="input-group-append">
<a class="btn btn-secondary"
href="#"
role="button"
aria-label="{{#str}} delete, core {{/str}}"
data-action="delete"
data-clipboard-success-message="{{#str}}delete, core, {{name}}{{/str}}"
id="registration_delete_{{id}}"
title="{{#str}}delete, core{{/str}}">
<span class="pix">{{#pix}} t/delete, core {{/pix}}</span>
</a>
</div>
</div>
<br>
<span class="font-italic" id="lti_tool_endpoint_info_{{id}}">
{{#expiryinfo}}
{{.}}
{{/expiryinfo}}
</span>
<hr>
</div>
</div>
<button id="lti_generate_registration_url_{{id}}" class="btn btn-secondary {{#url}}disabled{{/url}}" {{#url}}aria-disabled="true" title="{{#str}}registrationurlcannotgenerate, enrol_lti{{/str}}" aria-label="{{#str}}registrationurlcannotgenerate, enrol_lti{{/str}}"{{/url}}>
{{#str}}registrationurlgenerate, enrol_lti{{/str}}
</button>
{{/dynamic_registration_url}}
</div>
<div class="tab-pane fade" id="manual" role="tabpanel" aria-labelledby="manual-registration-tab">
<div class="alert alert-info alert-block">
{{manual_registration_info}}
</div>
<div id="lti_tool_endpoints">
<table class="admintable generaltable">
<thead>
<tr>
<th>{{#str}}name, core{{/str}}</th>
<th>{{#str}}url, core{{/str}}</th>
</tr>
</thead>
<tbody>
{{#manual_registration_urls}}
<tr>
<th id="lti_tool_endpoint_name_{{id}}"><label for="lti_tool_endpoint_url_{{id}}">{{name}}</label></th>
<td>
<div class="input-group col-md-6 ml-0 pl-0">
<input class="form-control" type="text" value="{{url}}" aria-label="{{url}}" id="lti_tool_endpoint_url_{{id}}" readonly>
<div class="input-group-append">
<a class="btn btn-secondary"
href="#"
role="button"
aria-label="{{#str}} copytoclipboard, enrol_lti {{/str}}"
data-action="copytoclipboard"
data-clipboard-success-message="{{#str}}copiedtoclipboard, enrol_lti, {{name}}{{/str}}"
data-clipboard-target="#lti_tool_endpoint_url_{{id}}"
id="{{id}}"
title="{{#str}}copytoclipboard, enrol_lti{{/str}}">
<span class="pix">{{#pix}} t/clipboard, core {{/pix}}</span>
</a>
</div>
</div>
</td>
</tr>
{{/manual_registration_urls}}
</tbody>
</table>
</div>
</div>
</div>
{{#js}}
require(['enrol_lti/tool_endpoints'], function(ToolEndpoints) {
ToolEndpoints.init();
});
{{/js}}