first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,209 @@
<?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/>.
/**
* This file contains a class definition for the Context Settings resource
*
* @package ltiservice_toolsettings
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @author Stephen Vickers
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltiservice_toolsettings\local\resources;
use ltiservice_toolsettings\local\service\toolsettings;
defined('MOODLE_INTERNAL') || die();
/**
* A resource implementing the Context-level (ToolProxyBinding) Settings.
*
* @package ltiservice_toolsettings
* @since Moodle 2.8
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contextsettings extends \mod_lti\local\ltiservice\resource_base {
/**
* Class constructor.
*
* @param \mod_lti\local\ltiservice\service_base $service Service instance
*/
public function __construct($service) {
parent::__construct($service);
$this->id = 'ToolProxyBindingSettings';
$this->template = '/{context_type}/{context_id}/bindings/{vendor_code}/{product_code}(/custom)';
$this->variables[] = 'ToolProxyBinding.custom.url';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings+json';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings.simple+json';
$this->methods[] = 'GET';
$this->methods[] = 'PUT';
}
/**
* Execute the request for this resource.
*
* @param \mod_lti\local\ltiservice\response $response Response object for this request.
*/
public function execute($response) {
$params = $this->parse_template();
$contexttype = $params['context_type'];
$contextid = $params['context_id'];
$vendorcode = $params['vendor_code'];
$productcode = $params['product_code'];
$bubble = optional_param('bubble', '', PARAM_ALPHA);
$typeid = null;
if (($vendorcode === 'tool') && is_numeric($productcode)) {
$typeid = $productcode;
}
$ok = !empty($contexttype) && !empty($contextid) &&
!empty($vendorcode) && !empty($productcode) &&
$this->check_tool($typeid, $response->get_request_data(),
array(toolsettings::SCOPE_TOOL_SETTINGS));
if (!$ok) {
$response->set_code(401);
} else {
$toolproxy = $this->get_service()->get_tool_proxy();
if (!empty($toolproxy)) {
$ok = $toolproxy->guid === $productcode;
$typeid = null;
$id = $toolproxy->id;
} else {
$ok = $vendorcode === 'tool';
$typeid = intval($productcode);
$id = -$typeid;
}
$contenttype = $response->get_accept();
$simpleformat = !empty($contenttype) && ($contenttype == $this->formats[1]);
if ($ok) {
$ok = (empty($bubble) || ((($bubble == 'distinct') || ($bubble == 'all')))) &&
(!$simpleformat || empty($bubble) || ($bubble != 'all')) &&
(empty($bubble) || ($response->get_request_method() == 'GET'));
}
if (!$ok) {
$response->set_code(404);
} else {
$systemsetting = null;
$contextsettings = lti_get_tool_settings($id, $contextid);
if (!empty($bubble)) {
$systemsetting = new systemsettings($this->get_service());
$systemsetting->params['tool_proxy_id'] = $productcode;
if ($id >= 0) {
$systemsetting->params['config_type'] = 'toolproxy';
} else {
$systemsetting->params['config_type'] = 'tool';
}
$systemsettings = lti_get_tool_settings($id);
if ($bubble == 'distinct') {
toolsettings::distinct_settings($systemsettings, $contextsettings, null);
}
} else {
$systemsettings = null;
}
if ($response->get_request_method() == 'GET') {
$json = '';
if ($simpleformat) {
$response->set_content_type($this->formats[1]);
$json .= "{";
} else {
$response->set_content_type($this->formats[0]);
$json .= "{\n \"@context\":\"http://purl.imsglobal.org/ctx/lti/v2/ToolSettings\",\n \"@graph\":[\n";
}
$settings = toolsettings::settings_to_json($systemsettings, $simpleformat, 'ToolProxy', $systemsetting);
$json .= $settings;
$isfirst = strlen($settings) <= 0;
$settings = toolsettings::settings_to_json($contextsettings, $simpleformat, 'ToolProxyBinding', $this);
if ((strlen($settings) > 0) && !$isfirst) {
$json .= ",";
}
$json .= $settings;
if ($simpleformat) {
$json .= "\n}";
} else {
$json .= "\n ]\n}";
}
$response->set_body($json);
} else { // PUT.
$settings = null;
if ($response->get_content_type() == $this->formats[0]) {
$json = json_decode($response->get_request_data());
$ok = !empty($json);
if ($ok) {
$ok = isset($json->{"@graph"}) && is_array($json->{"@graph"}) && (count($json->{"@graph"}) == 1) &&
($json->{"@graph"}[0]->{"@type"} == 'ToolProxyBinding');
}
if ($ok) {
$settings = $json->{"@graph"}[0]->custom;
unset($settings->{'@id'});
}
} else { // Simple JSON.
$json = json_decode($response->get_request_data(), true);
$ok = !empty($json);
if ($ok) {
$ok = is_array($json);
}
if ($ok) {
$settings = $json;
}
}
if ($ok) {
lti_set_tool_settings($settings, $id, $contextid);
} else {
$response->set_code(406);
}
}
}
}
}
/**
* Parse a value for custom parameter substitution variables.
*
* @param string $value String to be parsed
*
* @return string
*/
public function parse_value($value) {
global $COURSE;
if (strpos($value, '$ToolProxyBinding.custom.url') !== false) {
if ($COURSE->format == 'site') {
$this->params['context_type'] = 'Group';
} else {
$this->params['context_type'] = 'CourseSection';
}
$this->params['context_id'] = $COURSE->id;
if (!empty($this->get_service()->get_tool_proxy())) {
$this->params['vendor_code'] = $this->get_service()->get_tool_proxy()->vendorcode;
$this->params['product_code'] = $this->get_service()->get_tool_proxy()->guid;
} else {
$this->params['vendor_code'] = 'tool';
$this->params['product_code'] = $this->get_service()->get_type()->id;
}
$value = str_replace('$ToolProxyBinding.custom.url', parent::get_endpoint(), $value);
}
return $value;
}
}
@@ -0,0 +1,221 @@
<?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/>.
/**
* This file contains a class definition for the Context Settings resource
*
* @package ltiservice_toolsettings
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @author Stephen Vickers
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltiservice_toolsettings\local\resources;
use ltiservice_toolsettings\local\service\toolsettings;
defined('MOODLE_INTERNAL') || die();
/**
* A resource implementing the Context-level (ToolProxyBinding) Settings.
*
* @package ltiservice_toolsettings
* @since Moodle 2.8
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class linksettings extends \mod_lti\local\ltiservice\resource_base {
/**
* Class constructor.
*
* @param \mod_lti\local\ltiservice\service_base $service Service instance
*/
public function __construct($service) {
parent::__construct($service);
$this->id = 'LtiLinkSettings';
$this->template = '/links/{link_id}(/custom)';
$this->variables[] = 'LtiLink.custom.url';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings+json';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings.simple+json';
$this->methods[] = 'GET';
$this->methods[] = 'PUT';
}
/**
* Execute the request for this resource.
*
* @param \mod_lti\local\ltiservice\response $response Response object for this request.
*/
public function execute($response) {
global $DB, $COURSE;
$params = $this->parse_template();
$linkid = $params['link_id'];
$bubble = optional_param('bubble', '', PARAM_ALPHA);
$contenttype = $response->get_accept();
$simpleformat = !empty($contenttype) && ($contenttype == $this->formats[1]);
$ok = (empty($bubble) || ((($bubble == 'distinct') || ($bubble == 'all')))) &&
(!$simpleformat || empty($bubble) || ($bubble != 'all')) &&
(empty($bubble) || ($response->get_request_method() == self::HTTP_GET));
if (!$ok) {
$response->set_code(406);
}
$systemsetting = null;
$contextsetting = null;
$lti = null;
if ($ok) {
$ok = !empty($linkid);
if ($ok) {
$lti = $DB->get_record('lti', array('id' => $linkid), 'course,typeid', MUST_EXIST);
$ok = $this->check_tool($lti->typeid, $response->get_request_data(),
array(toolsettings::SCOPE_TOOL_SETTINGS));
}
if (!$ok) {
$response->set_code(401);
}
}
if ($ok) {
if (!empty($this->get_service()->get_tool_proxy())) {
$id = $this->get_service()->get_tool_proxy()->id;
} else {
$id = -$this->get_service()->get_type()->id;
}
if ($response->get_request_method() == 'GET') {
$linksettings = lti_get_tool_settings($id, $lti->course, $linkid);
if (!empty($bubble)) {
$contextsetting = new contextsettings($this->get_service());
if ($COURSE == 'site') {
$contextsetting->params['context_type'] = 'Group';
} else {
$contextsetting->params['context_type'] = 'CourseSection';
}
$contextsetting->params['context_id'] = $lti->course;
if ($id >= 0) {
$contextsetting->params['vendor_code'] = $this->get_service()->get_tool_proxy()->vendorcode;
} else {
$contextsetting->params['vendor_code'] = 'tool';
}
$contextsetting->params['product_code'] = abs($id);
$contextsettings = lti_get_tool_settings($id, $lti->course);
$systemsetting = new systemsettings($this->get_service());
if ($id >= 0) {
$systemsetting->params['config_type'] = 'toolproxy';
} else {
$systemsetting->params['config_type'] = 'tool';
}
$systemsetting->params['tool_proxy_id'] = abs($id);
$systemsettings = lti_get_tool_settings($id);
if ($bubble == 'distinct') {
toolsettings::distinct_settings($systemsettings, $contextsettings, $linksettings);
}
} else {
$contextsettings = null;
$systemsettings = null;
}
$json = '';
if ($simpleformat) {
$response->set_content_type($this->formats[1]);
$json .= "{";
} else {
$response->set_content_type($this->formats[0]);
$json .= "{\n \"@context\":\"http://purl.imsglobal.org/ctx/lti/v2/ToolSettings\",\n \"@graph\":[\n";
}
$settings = toolsettings::settings_to_json($systemsettings, $simpleformat, 'ToolProxy', $systemsetting);
$json .= $settings;
$isfirst = strlen($settings) <= 0;
$settings = toolsettings::settings_to_json($contextsettings, $simpleformat, 'ToolProxyBinding', $contextsetting);
if (strlen($settings) > 0) {
if (!$isfirst) {
$json .= ",";
if (!$simpleformat) {
$json .= "\n";
}
}
$isfirst = false;
}
$json .= $settings;
$settings = toolsettings::settings_to_json($linksettings, $simpleformat, 'LtiLink', $this);
if ((strlen($settings) > 0) && !$isfirst) {
$json .= ",";
if (!$simpleformat) {
$json .= "\n";
}
}
$json .= $settings;
if ($simpleformat) {
$json .= "\n}";
} else {
$json .= "\n ]\n}";
}
$response->set_body($json);
} else { // PUT.
$settings = null;
if ($response->get_content_type() == $this->formats[0]) {
$json = json_decode($response->get_request_data());
$ok = !empty($json);
if ($ok) {
$ok = isset($json->{"@graph"}) && is_array($json->{"@graph"}) && (count($json->{"@graph"}) == 1) &&
($json->{"@graph"}[0]->{"@type"} == 'LtiLink');
}
if ($ok) {
$settings = $json->{"@graph"}[0]->custom;
unset($settings->{'@id'});
}
} else { // Simple JSON.
$json = json_decode($response->get_request_data(), true);
$ok = !empty($json);
if ($ok) {
$ok = is_array($json);
}
if ($ok) {
$settings = $json;
}
}
if ($ok) {
lti_set_tool_settings($settings, $id, $lti->course, $linkid);
} else {
$response->set_code(406);
}
}
}
}
/**
* Parse a value for custom parameter substitution variables.
*
* @param string $value String to be parsed
*
* @return string
*/
public function parse_value($value) {
if (strpos($value, '$LtiLink.custom.url') !== false) {
$id = optional_param('id', 0, PARAM_INT); // Course Module ID.
if (!empty($id)) {
$cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
$this->params['link_id'] = $cm->instance;
}
$value = str_replace('$LtiLink.custom.url', parent::get_endpoint(), $value);
}
return $value;
}
}
@@ -0,0 +1,171 @@
<?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/>.
/**
* This file contains a class definition for the System Settings resource
*
* @package ltiservice_toolsettings
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @author Stephen Vickers
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltiservice_toolsettings\local\resources;
use ltiservice_toolsettings\local\service\toolsettings;
use mod_lti\local\ltiservice\resource_base;
defined('MOODLE_INTERNAL') || die();
/**
* A resource implementing the System-level (ToolProxy) Settings.
*
* @package ltiservice_toolsettings
* @since Moodle 2.8
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class systemsettings extends resource_base {
/**
* Class constructor.
*
* @param \mod_lti\local\ltiservice\service_base $service Service instance
*/
public function __construct($service) {
parent::__construct($service);
$this->id = 'ToolProxySettings';
$this->template = '/{config_type}/{tool_proxy_id}(/custom)';
$this->variables[] = 'ToolProxy.custom.url';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings+json';
$this->formats[] = 'application/vnd.ims.lti.v2.toolsettings.simple+json';
$this->methods[] = self::HTTP_GET;
$this->methods[] = self::HTTP_PUT;
}
/**
* Execute the request for this resource.
*
* @param \mod_lti\local\ltiservice\response $response Response object for this request.
*/
public function execute($response) {
$params = $this->parse_template();
$tpid = $params['tool_proxy_id'];
$configtype = $params['config_type'];
$ok = (in_array($configtype, array('toolproxy', 'tool')));
if ($ok) {
$typeid = null;
if (($configtype === 'tool') && is_numeric($tpid)) {
$typeid = $tpid;
}
$bubble = optional_param('bubble', '', PARAM_ALPHA);
$ok = !empty($tpid) && $this->check_tool($typeid, $response->get_request_data(),
array(toolsettings::SCOPE_TOOL_SETTINGS));
}
if (!$ok) {
$response->set_code(401);
} else if (!empty($this->get_service()->get_tool_proxy())) {
$ok = ($this->get_service()->get_tool_proxy()->guid === $tpid);
$id = $this->get_service()->get_tool_proxy()->id;
} else if (!empty($typeid)) {
$id = -$typeid;
} else {
$ok = false;
$response->set_code(404);
}
$contenttype = $response->get_accept();
$simpleformat = !empty($contenttype) && ($contenttype == $this->formats[1]);
if ($ok) {
$ok = (empty($bubble) || ((($bubble == 'distinct') || ($bubble == 'all')))) &&
(!$simpleformat || empty($bubble) || ($bubble != 'all')) &&
(empty($bubble) || ($response->get_request_method() == 'GET'));
if (!$ok) {
$response->set_code(406);
}
}
if ($ok) {
$systemsettings = lti_get_tool_settings($id);
if ($response->get_request_method() == 'GET') {
$json = '';
if ($simpleformat) {
$response->set_content_type($this->formats[1]);
$json .= "{";
} else {
$response->set_content_type($this->formats[0]);
$json .= "{\n \"@context\":\"http://purl.imsglobal.org/ctx/lti/v2/ToolSettings\",\n \"@graph\":[\n";
}
$json .= toolsettings::settings_to_json($systemsettings, $simpleformat,
'ToolProxy', $this);
if ($simpleformat) {
$json .= "\n}";
} else {
$json .= "\n ]\n}";
}
$response->set_body($json);
} else { // PUT.
$settings = null;
if ($response->get_content_type() == $this->formats[0]) {
$json = json_decode($response->get_request_data());
$ok = !empty($json);
if ($ok) {
$ok = isset($json->{"@graph"}) && is_array($json->{"@graph"}) && (count($json->{"@graph"}) == 1) &&
($json->{"@graph"}[0]->{"@type"} == 'ToolProxy');
}
if ($ok) {
$settings = $json->{"@graph"}[0]->custom;
unset($settings->{'@id'});
}
} else { // Simple JSON.
$json = json_decode($response->get_request_data(), true);
$ok = !empty($json);
if ($ok) {
$ok = is_array($json);
}
if ($ok) {
$settings = $json;
}
}
if ($ok) {
lti_set_tool_settings($settings, $id);
} else {
$response->set_code(406);
}
}
}
}
/**
* Parse a value for custom parameter substitution variables.
*
* @param string $value String to be parsed
*
* @return string
*/
public function parse_value($value) {
if (strpos($value, '$ToolProxy.custom.url') !== false) {
$value = str_replace('$ToolProxy.custom.url', parent::get_endpoint(), $value);
}
return $value;
}
}
@@ -0,0 +1,216 @@
<?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/>.
/**
* This file contains a class definition for the Tool Settings service
*
* @package ltiservice_toolsettings
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @author Stephen Vickers
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltiservice_toolsettings\local\service;
defined('MOODLE_INTERNAL') || die();
/**
* A service implementing Tool Settings.
*
* @package ltiservice_toolsettings
* @since Moodle 2.8
* @copyright 2014 Vital Source Technologies http://vitalsource.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class toolsettings extends \mod_lti\local\ltiservice\service_base {
/** Scope for managing tool settings */
const SCOPE_TOOL_SETTINGS = 'https://purl.imsglobal.org/spec/lti-ts/scope/toolsetting';
/**
* Class constructor.
*/
public function __construct() {
parent::__construct();
$this->id = 'toolsettings';
$this->name = 'Tool Settings';
}
/**
* Get the resources for this service.
*
* @return array
*/
public function get_resources() {
if (empty($this->resources)) {
$this->resources = array();
$this->resources[] = new \ltiservice_toolsettings\local\resources\systemsettings($this);
$this->resources[] = new \ltiservice_toolsettings\local\resources\contextsettings($this);
$this->resources[] = new \ltiservice_toolsettings\local\resources\linksettings($this);
}
return $this->resources;
}
/**
* Get the scope(s) permitted for the tool relevant to this service.
*
* @return array
*/
public function get_permitted_scopes() {
$scopes = array();
$ok = !empty($this->get_type());
if ($ok && isset($this->get_typeconfig()[$this->get_component_id()]) &&
($this->get_typeconfig()[$this->get_component_id()] == parent::SERVICE_ENABLED)) {
$scopes[] = self::SCOPE_TOOL_SETTINGS;
}
return $scopes;
}
/**
* Get the scope(s) defined this service.
*
* @return array
*/
public function get_scopes() {
return [self::SCOPE_TOOL_SETTINGS];
}
/**
* Get the distinct settings from each level by removing any duplicates from higher levels.
*
* @param array $systemsettings System level settings
* @param array $contextsettings Context level settings
* @param array $linksettings Link level settings
*/
public static function distinct_settings(&$systemsettings, &$contextsettings, $linksettings) {
if (!empty($systemsettings)) {
foreach ($systemsettings as $key => $value) {
if ((!empty($contextsettings) && array_key_exists($key, $contextsettings)) ||
(!empty($linksettings) && array_key_exists($key, $linksettings))) {
unset($systemsettings[$key]);
}
}
}
if (!empty($contextsettings)) {
foreach ($contextsettings as $key => $value) {
if (!empty($linksettings) && array_key_exists($key, $linksettings)) {
unset($contextsettings[$key]);
}
}
}
}
/**
* Get the JSON representation of the settings.
*
* @param array $settings Settings
* @param boolean $simpleformat <code>true</code> if simple JSON is to be returned
* @param string $type JSON-LD type
* @param \mod_lti\local\ltiservice\resource_base $resource Resource handling the request
*
* @return string
*/
public static function settings_to_json($settings, $simpleformat, $type, $resource) {
$json = '';
if (!empty($resource)) {
$indent = '';
if (!$simpleformat) {
$json .= " {\n \"@type\":\"{$type}\",\n";
$json .= " \"@id\":\"{$resource->get_endpoint()}\",\n";
$json .= " \"custom\":{";
$indent = ' ';
}
$isfirst = true;
if (!empty($settings)) {
foreach ($settings as $key => $value) {
if (!$isfirst) {
$json .= ',';
} else {
$isfirst = false;
}
$json .= "\n{$indent} \"{$key}\":\"{$value}\"";
}
}
if (!$simpleformat) {
$json .= "\n{$indent}}\n }";
}
}
return $json;
}
/**
* Adds form elements for membership add/edit page.
*
* @param \MoodleQuickForm $mform
*/
public function get_configuration_options(&$mform) {
$elementname = $this->get_component_id();
$options = [
get_string('notallow', $this->get_component_id()),
get_string('allow', $this->get_component_id())
];
$mform->addElement('select', $elementname, get_string($elementname, $this->get_component_id()), $options);
$mform->setType($elementname, 'int');
$mform->setDefault($elementname, 0);
$mform->addHelpButton($elementname, $elementname, $this->get_component_id());
}
/**
* Return an array of key/values to add to the launch parameters.
*
* @param string $messagetype 'basic-lti-launch-request' or 'ContentItemSelectionRequest'.
* @param string $courseid The course id.
* @param string $user The user id.
* @param string $typeid The tool lti type id.
* @param string $modlti The id of the lti activity.
*
* The type is passed to check the configuration
* and not return parameters for services not used.
*
* @return array of key/value pairs to add as launch parameters.
*/
public function get_launch_parameters($messagetype, $courseid, $user, $typeid, $modlti = null) {
global $COURSE;
$launchparameters = array();
$tool = lti_get_type_type_config($typeid);
if (isset($tool->{$this->get_component_id()})) {
if ($tool->{$this->get_component_id()} == self::SERVICE_ENABLED && $this->is_used_in_context($typeid, $courseid)) {
$launchparameters['system_setting_url'] = '$ToolProxy.custom.url';
$launchparameters['context_setting_url'] = '$ToolProxyBinding.custom.url';
if ($messagetype === 'basic-lti-launch-request') {
$launchparameters['link_setting_url'] = '$LtiLink.custom.url';
}
}
}
return $launchparameters;
}
}
@@ -0,0 +1,46 @@
<?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/>.
/**
* Privacy Subsystem implementation for ltiservice_toolsettings.
*
* @package ltiservice_toolsettings
* @copyright 2018 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace ltiservice_toolsettings\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for ltiservice_toolsettings implementing null_provider.
*
* @copyright 2018 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}