mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-78916 mod_lti: deprecate and remove unused strings and files
These strings and files supported the old way of creating course-level tools, which has now been fully replaced.
This commit is contained in:
parent
f41a0dcacf
commit
4464e46336
@ -1,95 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* AJAX service used when adding an External Tool.
|
||||
*
|
||||
* It is used to provide immediate feedback
|
||||
* of which tool provider is to be used based on the Launch URL.
|
||||
*
|
||||
* @package mod_lti
|
||||
* @subpackage xml
|
||||
* @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Chris Scribner
|
||||
*/
|
||||
define('AJAX_SCRIPT', true);
|
||||
|
||||
require_once(__DIR__ . "/../../config.php");
|
||||
require_once($CFG->dirroot . '/mod/lti/locallib.php');
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
require_login($courseid, false);
|
||||
|
||||
$action = required_param('action', PARAM_TEXT);
|
||||
|
||||
$response = new stdClass();
|
||||
|
||||
switch ($action) {
|
||||
case 'find_tool_config':
|
||||
$toolurl = required_param('toolurl', PARAM_RAW);
|
||||
$toolid = optional_param('toolid', 0, PARAM_INT);
|
||||
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
require_capability('mod/lti:addinstance', $context);
|
||||
|
||||
if (!empty($toolurl) && lti_is_cartridge($toolurl)) {
|
||||
$response->cartridge = true;
|
||||
} else {
|
||||
if (empty($toolid) && !empty($toolurl)) {
|
||||
$tool = lti_get_tool_by_url_match($toolurl, $courseid);
|
||||
|
||||
if (!empty($tool)) {
|
||||
$toolid = $tool->id;
|
||||
|
||||
$response->toolid = $tool->id;
|
||||
$response->toolname = s($tool->name);
|
||||
$response->tooldomain = s($tool->tooldomain);
|
||||
}
|
||||
} else {
|
||||
$response->toolid = $toolid;
|
||||
}
|
||||
|
||||
if (!empty($toolid)) {
|
||||
// Look up privacy settings.
|
||||
$query = '
|
||||
SELECT name, value
|
||||
FROM {lti_types_config}
|
||||
WHERE
|
||||
typeid = :typeid
|
||||
AND name IN (\'sendname\', \'sendemailaddr\', \'acceptgrades\')
|
||||
';
|
||||
|
||||
$privacyconfigs = $DB->get_records_sql($query, array('typeid' => $toolid));
|
||||
$success = count($privacyconfigs) > 0;
|
||||
foreach ($privacyconfigs as $config) {
|
||||
$configname = $config->name;
|
||||
$response->$configname = $config->value;
|
||||
}
|
||||
if (!$success) {
|
||||
$response->error = s(get_string('tool_config_not_found', 'mod_lti'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
echo json_encode($response);
|
||||
|
||||
die;
|
@ -1,133 +0,0 @@
|
||||
<?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 page allows instructors to configure course level tool providers.
|
||||
*
|
||||
* @package mod_lti
|
||||
* @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Chris Scribner
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/edit_form.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
|
||||
require_login($courseid, false);
|
||||
$url = new moodle_url('/mod/lti/instructor_edit_tool_type.php');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('edittype', 'mod_lti'));
|
||||
|
||||
$action = optional_param('action', null, PARAM_TEXT);
|
||||
$typeid = optional_param('typeid', null, PARAM_INT);
|
||||
|
||||
require_sesskey();
|
||||
|
||||
require_capability('mod/lti:addcoursetool', context_course::instance($courseid));
|
||||
|
||||
if (!empty($typeid)) {
|
||||
$type = lti_get_type($typeid);
|
||||
if ($type->course != $courseid) {
|
||||
throw new Exception('You do not have permissions to edit this tool type.');
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete action is called via ajax.
|
||||
if ($action == 'delete') {
|
||||
lti_delete_type($typeid);
|
||||
die;
|
||||
}
|
||||
|
||||
// Add a timeout for closing for behat so it can check for errors before switching back to the main window.
|
||||
$timeout = 0;
|
||||
if (defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING) {
|
||||
$timeout = 2000;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($action == 'edit') {
|
||||
$type = lti_get_type_type_config($typeid);
|
||||
} else {
|
||||
$type = new stdClass();
|
||||
$type->lti_clientid = null;
|
||||
}
|
||||
|
||||
$form = new mod_lti_edit_types_form($url, (object)array('id' => $typeid, 'clientid' => $type->lti_clientid));
|
||||
|
||||
// If the user just opened an add or edit form.
|
||||
if ($action == 'add' || $action == 'edit') {
|
||||
if ($action == 'edit') {
|
||||
$form->set_data($type);
|
||||
}
|
||||
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
|
||||
$form->display();
|
||||
} else {
|
||||
$script = '';
|
||||
$closewindow = <<<EOF
|
||||
setTimeout(function() {
|
||||
window.close();
|
||||
}, $timeout);
|
||||
EOF;
|
||||
|
||||
if ($data = $form->get_data()) {
|
||||
$type = new stdClass();
|
||||
|
||||
if (!empty($typeid)) {
|
||||
$type->id = $typeid;
|
||||
|
||||
lti_load_type_if_cartridge($data);
|
||||
|
||||
lti_update_type($type, $data);
|
||||
|
||||
$fromdb = lti_get_type($typeid);
|
||||
$json = json_encode($fromdb);
|
||||
|
||||
// Output script to update the calling window.
|
||||
$script = <<<EOF
|
||||
window.opener.M.mod_lti.editor.updateToolType({$json});
|
||||
EOF;
|
||||
} else {
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->course = $COURSE->id;
|
||||
|
||||
lti_load_type_if_cartridge($data);
|
||||
|
||||
$id = lti_add_type($type, $data);
|
||||
|
||||
$fromdb = lti_get_type($id);
|
||||
$json = json_encode($fromdb);
|
||||
|
||||
// Output script to update the calling window.
|
||||
$script = <<<EOF
|
||||
window.opener.M.mod_lti.editor.addToolType({$json});
|
||||
EOF;
|
||||
}
|
||||
echo html_writer::script($script . $closewindow);
|
||||
} else if ($form->is_cancelled()) {
|
||||
echo html_writer::script($closewindow);
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
|
||||
$form->display();
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
@ -1 +1,17 @@
|
||||
lti:addmanualinstance,mod_lti
|
||||
edittype,mod_lti
|
||||
deletetype,mod_lti
|
||||
cannot_delete,mod_lti
|
||||
cannot_edit,mod_lti
|
||||
global_tool_types,mod_lti
|
||||
course_tool_types,mod_lti
|
||||
using_tool_cartridge,mod_lti
|
||||
using_tool_configuration,mod_lti
|
||||
domain_mismatch,mod_lti
|
||||
custom_config,mod_lti
|
||||
tool_config_not_found,mod_lti
|
||||
tooltypeadded,mod_lti
|
||||
tooltypedeleted,mod_lti
|
||||
tooltypenotdeleted,mod_lti
|
||||
tooltypeupdated,mod_lti
|
||||
forced_help,mod_lti
|
||||
|
@ -93,8 +93,6 @@ $string['basicltisettings'] = 'Basic Learning Tool Interoperability (LTI) settin
|
||||
$string['cachedef_keyset'] = 'Caches the keyset information of tools';
|
||||
$string['cancel'] = 'Cancel';
|
||||
$string['cancelled'] = 'Cancelled';
|
||||
$string['cannot_delete'] = 'You may not delete this tool configuration.';
|
||||
$string['cannot_edit'] = 'You may not edit this tool configuration.';
|
||||
$string['capabilities'] = 'Capabilities';
|
||||
$string['capabilitiesrequired'] = 'This tool requires access to the following data in order to activate:';
|
||||
$string['capabilities_help'] = 'Select those capabilities which you wish to offer to the tool provider. More than one capability can be selected.';
|
||||
@ -117,7 +115,6 @@ $string['contentitem_deeplinking_help'] = 'If ticked, the option \'Select conten
|
||||
$string['contentitem_multiple_description'] = 'The following items will be added to your course:';
|
||||
$string['contentitem_multiple_graded'] = 'Graded activity (Maximum grade: {$a})';
|
||||
$string['contentselected'] = 'Content selected';
|
||||
$string['course_tool_types'] = 'Course tools';
|
||||
$string['courseactivitiesorresources'] = 'Course activities or resources';
|
||||
$string['courseexternaltooladd'] = 'Add new LTI External tool';
|
||||
$string['courseexternaltooladdsuccess'] = '{$a} added.';
|
||||
@ -136,7 +133,6 @@ $string['coursetooldeleted'] = '{$a} removed';
|
||||
$string['createdon'] = 'Created on';
|
||||
$string['curllibrarymissing'] = 'PHP cURL extension required for the External tool.';
|
||||
$string['custom'] = 'Custom parameters';
|
||||
$string['custom_config'] = 'Using custom tool configuration.';
|
||||
$string['custom_help'] = 'Custom parameters are settings used by the tool provider. For example, a custom parameter may be used to display
|
||||
a specific resource from the provider. Each parameter should be entered on a separate line using a format of "name=value"; for example, "chapter=3".
|
||||
|
||||
@ -164,12 +160,10 @@ $string['delete_confirmation'] = 'Are you sure you want to delete this preconfig
|
||||
$string['deletecoursetool'] = 'Delete {$a}';
|
||||
$string['deletecoursetoolconfirm'] = 'This will delete {$a} from the available LTI tools in your course.';
|
||||
$string['deletecoursetoolwithusageconfirm'] = '{$a} is currently being used in at least one activity in your course. If you delete this tool, the activities that use it will no longer work.<br><br>Are you sure you want to delete {$a}?';
|
||||
$string['deletetype'] = 'Delete preconfigured tool';
|
||||
$string['display_description'] = 'Display activity description when students access the tool';
|
||||
$string['display_description_help'] = 'Content from this tool is displayed embedded in a page in the course. This setting determines if the activity description is shown in that page.';
|
||||
$string['display_name'] = 'Display activity name when students access the tool';
|
||||
$string['display_name_help'] = 'Content from this tool is displayed embedded in a page in the course. This setting determines if the activity name is shown in that page.';
|
||||
$string['domain_mismatch'] = 'Tool URL\'s domain does not match tool configuration.';
|
||||
$string['donot'] = 'Do not send';
|
||||
$string['donotaccept'] = 'Do not accept';
|
||||
$string['donotallow'] = 'Do not allow';
|
||||
@ -189,7 +183,6 @@ $string['editmanualinstancedeprecationwarning'] = 'Manually configured External
|
||||
To make any changes to the tool, or to create new activities with it, the tool needs to be added to your course in Course > More > LTI External tools. Then, you will be able to create new activities, selecting the tool directly in the Activity chooser.
|
||||
<br><br>
|
||||
You can read more about adding LTI External tools in the documentation <a href="{$a}" target="_blank">External tool</a>.';
|
||||
$string['edittype'] = 'Edit preconfigured tool';
|
||||
$string['embed'] = 'Embed';
|
||||
$string['embed_no_blocks'] = 'Embed, without blocks';
|
||||
$string['enableemailnotification'] = 'Send notification emails';
|
||||
@ -230,7 +223,6 @@ $string['fixexistingconf'] = 'Use an existing configuration for the misconfigure
|
||||
$string['fixnew'] = 'New configuration';
|
||||
$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';
|
||||
$string['fixold'] = 'Use existing';
|
||||
$string['forced_help'] = 'This setting has been forced in a course or site level tool configuration. You may not change it from this interface.';
|
||||
$string['force_ssl'] = 'Force SSL';
|
||||
$string['force_ssl_help'] = 'Selecting this option forces all launches to this tool provider to use SSL.
|
||||
|
||||
@ -238,7 +230,6 @@ In addition, all web service requests from the tool provider will use SSL.
|
||||
|
||||
If using this option, confirm that this Moodle site and the tool provider support SSL.';
|
||||
$string['generaltool'] = 'General tool';
|
||||
$string['global_tool_types'] = 'Preconfigured tools';
|
||||
$string['grading'] = 'Grade routing';
|
||||
$string['icon_url'] = 'Icon URL';
|
||||
$string['icon_url_help'] = 'The icon URL allows the icon that shows up in the course listing for this activity to be modified. Instead of using the default
|
||||
@ -539,7 +530,6 @@ $string['subplugintype_ltiservice_plural'] = 'LTI services';
|
||||
$string['subplugintype_ltisource'] = 'LTI source';
|
||||
$string['subplugintype_ltisource_plural'] = 'LTI sources';
|
||||
$string['toggle_debug_data'] = 'Toggle debug data';
|
||||
$string['tool_config_not_found'] = 'Tool configuration not found for this URL.';
|
||||
$string['tool_settings'] = 'Tool settings';
|
||||
$string['tooldescription'] = 'Tool description';
|
||||
$string['tooldescription_help'] = 'The description of the tool that will be displayed to teachers in the activity list.
|
||||
@ -574,10 +564,6 @@ $string['toolregistration'] = 'External tool registration';
|
||||
$string['toolsetup'] = 'External tool configuration';
|
||||
$string['tooltypenotfounderror'] = "The LTI tool used in this activity has been deleted. If you need help, contact your teacher or site administrator.";
|
||||
$string['tooltypes'] = 'Tools';
|
||||
$string['tooltypeadded'] = 'Preconfigured tool added';
|
||||
$string['tooltypedeleted'] = 'Preconfigured tool deleted';
|
||||
$string['tooltypenotdeleted'] = 'Could not delete preconfigured tool';
|
||||
$string['tooltypeupdated'] = 'Preconfigured tool updated';
|
||||
$string['toolurl'] = 'Tool URL';
|
||||
$string['toolurlplaceholder'] = 'Tool URL...';
|
||||
$string['toolurl_help'] = 'The tool URL is used to match tool URLs to the correct tool configuration. Prefixing the URL with http(s) is optional.
|
||||
@ -617,10 +603,24 @@ $string['update'] = 'Update';
|
||||
$string['usage'] = 'Usage';
|
||||
$string['useraccountinformation'] = 'User account information';
|
||||
$string['userpersonalinformation'] = 'User personal information';
|
||||
$string['using_tool_cartridge'] = 'Using tool cartridge';
|
||||
$string['using_tool_configuration'] = 'Using tool configuration: ';
|
||||
$string['validurl'] = 'A valid URL must start with http(s)://';
|
||||
$string['viewsubmissions'] = 'View submissions and grading screen';
|
||||
|
||||
// Deprecated since Moodle 4.3.
|
||||
$string['lti:addmanualinstance'] = 'Add a manually-configured tool';
|
||||
$string['edittype'] = 'Edit preconfigured tool';
|
||||
$string['deletetype'] = 'Delete preconfigured tool';
|
||||
$string['cannot_delete'] = 'You may not delete this tool configuration.';
|
||||
$string['cannot_edit'] = 'You may not edit this tool configuration.';
|
||||
$string['global_tool_types'] = 'Preconfigured tools';
|
||||
$string['course_tool_types'] = 'Course tools';
|
||||
$string['using_tool_cartridge'] = 'Using tool cartridge';
|
||||
$string['using_tool_configuration'] = 'Using tool configuration: ';
|
||||
$string['domain_mismatch'] = 'Tool URL\'s domain does not match tool configuration.';
|
||||
$string['custom_config'] = 'Using custom tool configuration.';
|
||||
$string['tool_config_not_found'] = 'Tool configuration not found for this URL.';
|
||||
$string['tooltypeadded'] = 'Preconfigured tool added';
|
||||
$string['tooltypedeleted'] = 'Preconfigured tool deleted';
|
||||
$string['tooltypenotdeleted'] = 'Could not delete preconfigured tool';
|
||||
$string['tooltypeupdated'] = 'Preconfigured tool updated';
|
||||
$string['forced_help'] = 'This setting has been forced in a course or site level tool configuration. You may not change it from this interface.';
|
||||
|
@ -1,580 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Javascript extensions for the External Tool activity editor.
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
(function(){
|
||||
var Y;
|
||||
|
||||
M.mod_lti = M.mod_lti || {};
|
||||
|
||||
M.mod_lti.LTI_SETTING_NEVER = 0;
|
||||
M.mod_lti.LTI_SETTING_ALWAYS = 1;
|
||||
M.mod_lti.LTI_SETTING_DELEGATE = 2;
|
||||
|
||||
M.mod_lti.editor = {
|
||||
init: function(yui3, settings){
|
||||
if(yui3){
|
||||
Y = yui3;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.settings = Y.JSON.parse(settings);
|
||||
|
||||
this.urlCache = {};
|
||||
this.toolTypeCache = {};
|
||||
|
||||
var updateToolMatches = function(){
|
||||
self.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
self.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
};
|
||||
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
if (typeSelector) {
|
||||
this.addOptGroups();
|
||||
|
||||
typeSelector.on('change', function(e){
|
||||
// Reset configuration fields when another preconfigured tool is selected.
|
||||
self.resetToolFields();
|
||||
|
||||
updateToolMatches();
|
||||
|
||||
self.toggleEditButtons();
|
||||
|
||||
if (self.getSelectedToolTypeOption().getAttribute('toolproxy')){
|
||||
var allowname = Y.one('#id_instructorchoicesendname');
|
||||
allowname.set('checked', !self.getSelectedToolTypeOption().getAttribute('noname'));
|
||||
|
||||
var allowemail = Y.one('#id_instructorchoicesendemailaddr');
|
||||
allowemail.set('checked', !self.getSelectedToolTypeOption().getAttribute('noemail'));
|
||||
|
||||
var allowgrades = Y.one('#id_instructorchoiceacceptgrades');
|
||||
allowgrades.set('checked', !self.getSelectedToolTypeOption().getAttribute('nogrades'));
|
||||
self.toggleGradeSection();
|
||||
}
|
||||
});
|
||||
|
||||
this.createTypeEditorButtons();
|
||||
|
||||
this.toggleEditButtons();
|
||||
}
|
||||
|
||||
var contentItemButton = Y.one('[name="selectcontent"]');
|
||||
if (contentItemButton) {
|
||||
var contentItemUrl = contentItemButton.getAttribute('data-contentitemurl');
|
||||
// Handle configure from link button click.
|
||||
contentItemButton.on('click', function() {
|
||||
var contentItemId = self.getContentItemId();
|
||||
if (contentItemId) {
|
||||
// Get activity name and description values.
|
||||
var title = Y.one('#id_name').get('value').trim();
|
||||
var text = Y.one('#id_introeditor').get('value').trim();
|
||||
|
||||
// Set data to be POSTed.
|
||||
var postData = {
|
||||
id: contentItemId,
|
||||
course: self.settings.courseId,
|
||||
title: title,
|
||||
text: text
|
||||
};
|
||||
|
||||
window.console.log(postData);
|
||||
|
||||
require(['mod_lti/contentitem'], function(contentitem) {
|
||||
contentitem.init(contentItemUrl, postData, function(returnData) {
|
||||
if (!returnData.multiple) {
|
||||
M.mod_lti.editor.toggleGradeSection();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var textAreas = new Y.NodeList([
|
||||
Y.one('#id_toolurl'),
|
||||
Y.one('#id_securetoolurl'),
|
||||
Y.one('#id_resourcekey'),
|
||||
Y.one('#id_password')
|
||||
]);
|
||||
|
||||
var debounce;
|
||||
textAreas.on('keyup', function(e){
|
||||
clearTimeout(debounce);
|
||||
|
||||
// If no more changes within 2 seconds, look up the matching tool URL
|
||||
debounce = setTimeout(function(){
|
||||
updateToolMatches();
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
var allowgrades = Y.one('#id_instructorchoiceacceptgrades');
|
||||
allowgrades.on('change', this.toggleGradeSection, this);
|
||||
|
||||
if (typeSelector) {
|
||||
updateToolMatches();
|
||||
}
|
||||
},
|
||||
|
||||
toggleGradeSection: function(e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
var allowgrades = Y.one('#id_instructorchoiceacceptgrades');
|
||||
var gradefieldset = Y.one('#id_modstandardgrade');
|
||||
if (!allowgrades.get('checked')) {
|
||||
gradefieldset.hide();
|
||||
} else {
|
||||
gradefieldset.show();
|
||||
}
|
||||
},
|
||||
|
||||
clearToolCache: function(){
|
||||
this.urlCache = {};
|
||||
this.toolTypeCache = {};
|
||||
},
|
||||
|
||||
updateAutomaticToolMatch: function(field){
|
||||
if (!field) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
var toolurl = field;
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var id = field.get('id') + '_lti_automatch_tool';
|
||||
var automatchToolDisplay = Y.one('#' + id);
|
||||
|
||||
if(!automatchToolDisplay){
|
||||
automatchToolDisplay = Y.Node.create('<span />')
|
||||
.set('id', id)
|
||||
.setStyle('padding-left', '1em');
|
||||
|
||||
toolurl.insert(automatchToolDisplay, 'after');
|
||||
}
|
||||
|
||||
var url = toolurl.get('value');
|
||||
|
||||
// Hide the display if the url box is empty
|
||||
if(!url){
|
||||
automatchToolDisplay.setStyle('display', 'none');
|
||||
} else {
|
||||
automatchToolDisplay.set('innerHTML', '');
|
||||
automatchToolDisplay.setStyle('display', '');
|
||||
}
|
||||
|
||||
var selectedToolType = parseInt(typeSelector.get('value'));
|
||||
var selectedOption = typeSelector.one('option[value="' + selectedToolType + '"]');
|
||||
|
||||
// A specific tool type is selected (not "auto")
|
||||
// We still need to check with the server to get privacy settings
|
||||
if(selectedToolType > 0){
|
||||
// If the entered domain matches the domain of the tool configuration...
|
||||
var domainRegex = /(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i;
|
||||
var match = domainRegex.exec(url);
|
||||
if(match && match[1] && match[1].toLowerCase() === selectedOption.getAttribute('domain').toLowerCase()){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.util.get_string('using_tool_configuration', 'lti') + selectedOption.get('text'));
|
||||
} else {
|
||||
// The entered URL does not match the domain of the tool configuration
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.warning_icon_url + '" />' + M.util.get_string('domain_mismatch', 'lti'));
|
||||
}
|
||||
}
|
||||
|
||||
var key = Y.one('#id_resourcekey');
|
||||
var secret = Y.one('#id_password');
|
||||
|
||||
// Indicate the tool is manually configured
|
||||
// We still check the Launch URL with the server as course/site tools may override privacy settings
|
||||
if(key.get('value') !== '' && secret.get('value') !== ''){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.util.get_string('custom_config', 'lti'));
|
||||
}
|
||||
|
||||
var continuation = function(toolInfo, inputfield){
|
||||
if (inputfield === undefined || (inputfield.get('id') != 'id_securetoolurl' || inputfield.get('value'))) {
|
||||
self.updatePrivacySettings(toolInfo);
|
||||
}
|
||||
if(toolInfo.toolname){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.util.get_string('using_tool_configuration', 'lti') + toolInfo.toolname);
|
||||
} else if(!selectedToolType) {
|
||||
// Inform them custom configuration is in use
|
||||
if(key.get('value') === '' || secret.get('value') === ''){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.warning_icon_url + '" />' + M.util.get_string('tool_config_not_found', 'lti'));
|
||||
}
|
||||
}
|
||||
if (toolInfo.cartridge) {
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url +
|
||||
'" />' + M.util.get_string('using_tool_cartridge', 'lti'));
|
||||
}
|
||||
};
|
||||
|
||||
// Cache urls which have already been checked to increase performance
|
||||
// Don't use URL cache if tool type manually selected
|
||||
if(selectedToolType && self.toolTypeCache[selectedToolType]){
|
||||
return continuation(self.toolTypeCache[selectedToolType]);
|
||||
} else if(self.urlCache[url] && !selectedToolType){
|
||||
return continuation(self.urlCache[url]);
|
||||
} else if(!selectedToolType && !url) {
|
||||
// No tool type or url set
|
||||
return continuation({}, field);
|
||||
} else {
|
||||
self.findToolByUrl(url, selectedToolType, function(toolInfo){
|
||||
if(toolInfo){
|
||||
// Cache the result based on whether the URL or tool type was used to look up the tool
|
||||
if(!selectedToolType){
|
||||
self.urlCache[url] = toolInfo;
|
||||
} else {
|
||||
self.toolTypeCache[selectedToolType] = toolInfo;
|
||||
}
|
||||
|
||||
Y.one('#id_urlmatchedtypeid').set('value', toolInfo.toolid);
|
||||
|
||||
continuation(toolInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates display of privacy settings to show course / site tool configuration settings.
|
||||
*/
|
||||
updatePrivacySettings: function(toolInfo){
|
||||
if(!toolInfo || !toolInfo.toolid){
|
||||
toolInfo = {
|
||||
sendname: M.mod_lti.LTI_SETTING_DELEGATE,
|
||||
sendemailaddr: M.mod_lti.LTI_SETTING_DELEGATE,
|
||||
acceptgrades: M.mod_lti.LTI_SETTING_DELEGATE
|
||||
}
|
||||
}
|
||||
|
||||
var setting, control;
|
||||
|
||||
var privacyControls = {
|
||||
sendname: Y.one('#id_instructorchoicesendname'),
|
||||
sendemailaddr: Y.one('#id_instructorchoicesendemailaddr'),
|
||||
acceptgrades: Y.one('#id_instructorchoiceacceptgrades')
|
||||
};
|
||||
|
||||
// Store a copy of user entered privacy settings as we may overwrite them
|
||||
if(!this.userPrivacySettings){
|
||||
this.userPrivacySettings = {};
|
||||
}
|
||||
|
||||
for(setting in privacyControls){
|
||||
if(privacyControls.hasOwnProperty(setting)){
|
||||
control = privacyControls[setting];
|
||||
|
||||
// Only store the value if it hasn't been forced by the editor
|
||||
if(!control.get('disabled')){
|
||||
this.userPrivacySettings[setting] = control.get('checked');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update UI based on course / site tool configuration
|
||||
for(setting in privacyControls){
|
||||
if(privacyControls.hasOwnProperty(setting)){
|
||||
var settingValue = toolInfo[setting];
|
||||
control = privacyControls[setting];
|
||||
|
||||
if(settingValue == M.mod_lti.LTI_SETTING_NEVER){
|
||||
control.set('disabled', true);
|
||||
control.set('checked', false);
|
||||
control.set('title', M.util.get_string('forced_help', 'lti'));
|
||||
} else if(settingValue == M.mod_lti.LTI_SETTING_ALWAYS){
|
||||
control.set('disabled', true);
|
||||
control.set('checked', true);
|
||||
control.set('title', M.util.get_string('forced_help', 'lti'));
|
||||
} else if(settingValue == M.mod_lti.LTI_SETTING_DELEGATE){
|
||||
control.set('disabled', false);
|
||||
|
||||
// Get the value out of the stored copy
|
||||
control.set('checked', this.userPrivacySettings[setting]);
|
||||
control.set('title', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.toggleGradeSection();
|
||||
},
|
||||
|
||||
getSelectedToolTypeOption: function(){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
return typeSelector.one('option[value="' + typeSelector.get('value') + '"]');
|
||||
},
|
||||
|
||||
/**
|
||||
* Separate tool listing into option groups. Server-side select control
|
||||
* doesn't seem to support this.
|
||||
*/
|
||||
addOptGroups: function(){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
if(typeSelector.one('option[courseTool=1]')){
|
||||
// One ore more course tools exist
|
||||
|
||||
var globalGroup = Y.Node.create('<optgroup />')
|
||||
.set('id', 'global_tool_group')
|
||||
.set('label', M.util.get_string('global_tool_types', 'lti'));
|
||||
|
||||
var courseGroup = Y.Node.create('<optgroup />')
|
||||
.set('id', 'course_tool_group')
|
||||
.set('label', M.util.get_string('course_tool_types', 'lti'));
|
||||
|
||||
var globalOptions = typeSelector.all('option[globalTool=1]').remove().each(function(node){
|
||||
globalGroup.append(node);
|
||||
});
|
||||
|
||||
var courseOptions = typeSelector.all('option[courseTool=1]').remove().each(function(node){
|
||||
courseGroup.append(node);
|
||||
});
|
||||
|
||||
if(globalOptions.size() > 0){
|
||||
typeSelector.append(globalGroup);
|
||||
}
|
||||
|
||||
if(courseOptions.size() > 0){
|
||||
typeSelector.append(courseGroup);
|
||||
}
|
||||
|
||||
// Fixes what is presumably a bug in YUI, in which the selected option is not properly set after reorganising the
|
||||
// options into optgroups.
|
||||
var selectedOption = typeSelector.one('[selected]');
|
||||
if (selectedOption) {
|
||||
selectedOption.set('selected', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds buttons for creating, editing, and deleting tool types.
|
||||
* Javascript is a requirement to edit course level tools at this point.
|
||||
*/
|
||||
createTypeEditorButtons: function(){
|
||||
var self = this;
|
||||
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var createIcon = function(id, tooltip, iconUrl){
|
||||
return Y.Node.create('<a />')
|
||||
.set('id', id)
|
||||
.set('title', tooltip)
|
||||
.setStyle('margin-left', '.5em')
|
||||
.set('href', 'javascript:void(0);')
|
||||
.append(Y.Node.create('<img src="' + iconUrl + '" />'));
|
||||
}
|
||||
|
||||
var addIcon = createIcon('lti_add_tool_type', M.util.get_string('addtype', 'lti'), this.settings.add_icon_url);
|
||||
var editIcon = createIcon('lti_edit_tool_type', M.util.get_string('edittype', 'lti'), this.settings.edit_icon_url);
|
||||
var deleteIcon = createIcon('lti_delete_tool_type', M.util.get_string('deletetype', 'lti'), this.settings.delete_icon_url);
|
||||
|
||||
editIcon.on('click', function(e){
|
||||
var toolTypeId = typeSelector.get('value');
|
||||
|
||||
if(self.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
window.open(self.settings.instructor_tool_type_edit_url + '&action=edit&typeid=' + toolTypeId, 'edit_tool');
|
||||
} else {
|
||||
alert(M.util.get_string('cannot_edit', 'lti'));
|
||||
}
|
||||
});
|
||||
|
||||
addIcon.on('click', function(e){
|
||||
window.open(self.settings.instructor_tool_type_edit_url + '&action=add', 'add_tool');
|
||||
});
|
||||
|
||||
deleteIcon.on('click', function(e){
|
||||
var toolTypeId = typeSelector.get('value');
|
||||
|
||||
if(self.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
if(confirm(M.util.get_string('delete_confirmation', 'lti'))){
|
||||
self.deleteTool(toolTypeId);
|
||||
}
|
||||
} else {
|
||||
alert(M.util.get_string('cannot_delete', 'lti'));
|
||||
}
|
||||
});
|
||||
|
||||
typeSelector.insert(addIcon, 'after');
|
||||
addIcon.insert(editIcon, 'after');
|
||||
editIcon.insert(deleteIcon, 'after');
|
||||
},
|
||||
|
||||
toggleEditButtons: function(){
|
||||
var lti_edit_tool_type = Y.one('#lti_edit_tool_type');
|
||||
var lti_delete_tool_type = Y.one('#lti_delete_tool_type');
|
||||
|
||||
// Make the edit / delete icons look enabled / disabled.
|
||||
// Does not work in older browsers, but alerts will catch those cases.
|
||||
if(this.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
lti_edit_tool_type.setStyle('opacity', '1');
|
||||
lti_delete_tool_type.setStyle('opacity', '1');
|
||||
} else {
|
||||
lti_edit_tool_type.setStyle('opacity', '.2');
|
||||
lti_delete_tool_type.setStyle('opacity', '.2');
|
||||
}
|
||||
},
|
||||
|
||||
addToolType: function(toolType){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
var course_tool_group = Y.one('#course_tool_group');
|
||||
|
||||
var option = Y.Node.create('<option />')
|
||||
.set('text', toolType.name)
|
||||
.set('value', toolType.id)
|
||||
.set('selected', 'selected')
|
||||
.setAttribute('editable', '1')
|
||||
.setAttribute('courseTool', '1')
|
||||
.setAttribute('domain', toolType.tooldomain);
|
||||
|
||||
if(course_tool_group){
|
||||
course_tool_group.append(option);
|
||||
} else {
|
||||
typeSelector.append(option);
|
||||
}
|
||||
|
||||
// Adding the new tool may affect which tool gets matched automatically
|
||||
this.clearToolCache();
|
||||
this.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
this.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
this.toggleEditButtons();
|
||||
|
||||
require(["core/notification"], function (notification) {
|
||||
notification.addNotification({
|
||||
message: M.util.get_string('tooltypeadded', 'lti'),
|
||||
type: "success"
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
updateToolType: function(toolType){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var option = typeSelector.one('option[value="' + toolType.id + '"]');
|
||||
option.set('text', toolType.name)
|
||||
.set('domain', toolType.tooldomain);
|
||||
|
||||
// Editing the tool may affect which tool gets matched automatically
|
||||
this.clearToolCache();
|
||||
this.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
this.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
|
||||
require(["core/notification"], function (notification) {
|
||||
notification.addNotification({
|
||||
message: M.util.get_string('tooltypeupdated', 'lti'),
|
||||
type: "success"
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
deleteTool: function(toolTypeId){
|
||||
var self = this;
|
||||
|
||||
Y.io(self.settings.instructor_tool_type_edit_url + '&action=delete&typeid=' + toolTypeId, {
|
||||
on: {
|
||||
success: function(){
|
||||
self.getSelectedToolTypeOption().remove();
|
||||
|
||||
// Editing the tool may affect which tool gets matched automatically
|
||||
self.clearToolCache();
|
||||
self.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
self.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
|
||||
require(["core/notification"], function (notification) {
|
||||
notification.addNotification({
|
||||
message: M.util.get_string('tooltypedeleted', 'lti'),
|
||||
type: "success"
|
||||
});
|
||||
});
|
||||
},
|
||||
failure: function(){
|
||||
require(["core/notification"], function (notification) {
|
||||
notification.addNotification({
|
||||
message: M.util.get_string('tooltypenotdeleted', 'lti'),
|
||||
type: "problem"
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
findToolByUrl: function(url, toolId, callback){
|
||||
var self = this;
|
||||
|
||||
Y.io(self.settings.ajax_url, {
|
||||
data: {action: 'find_tool_config',
|
||||
course: self.settings.courseId,
|
||||
toolurl: url,
|
||||
toolid: toolId || 0
|
||||
},
|
||||
|
||||
on: {
|
||||
success: function(transactionid, xhr){
|
||||
var response = xhr.response;
|
||||
|
||||
var toolInfo = Y.JSON.parse(response);
|
||||
|
||||
callback(toolInfo);
|
||||
},
|
||||
failure: function(){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the tool type ID of the selected tool that supports Content-Item selection.
|
||||
*
|
||||
* @returns {number|boolean} The ID of the tool type if it supports Content-Item selection. False, otherwise.
|
||||
*/
|
||||
getContentItemId: function() {
|
||||
try {
|
||||
var selected = this.getSelectedToolTypeOption();
|
||||
if (selected.getAttribute('data-contentitem')) {
|
||||
return selected.getAttribute('data-id');
|
||||
}
|
||||
return false;
|
||||
} catch (err) {
|
||||
// Tool selector not available - check for hidden fields instead.
|
||||
var content = Y.one('input[name="contentitem"]');
|
||||
if (!content || !content.get('value')) {
|
||||
return false;
|
||||
}
|
||||
return Y.one('input[name="typeid"]').get('value');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the values of fields related to the LTI tool settings.
|
||||
*/
|
||||
resetToolFields: function() {
|
||||
// Reset values for all text fields.
|
||||
var fields = Y.all('#id_toolurl, #id_securetoolurl, #id_instructorcustomparameters, #id_icon, #id_secureicon');
|
||||
fields.set('value', null);
|
||||
|
||||
// Reset value for launch container select box.
|
||||
Y.one('#id_launchcontainer').set('value', 1);
|
||||
}
|
||||
};
|
||||
})();
|
@ -82,8 +82,7 @@ if (!empty($errormsg)) {
|
||||
$links = new stdClass();
|
||||
|
||||
if (has_capability('mod/lti:addcoursetool', $contextcourse)) {
|
||||
$coursetooleditor = new moodle_url('/mod/lti/instructor_edit_tool_type.php',
|
||||
array('course' => $courseid, 'action' => 'add', 'sesskey' => sesskey()));
|
||||
$coursetooleditor = new moodle_url('mod/lti/coursetools.php', ['id' => $courseid]);
|
||||
$links->course_tool_editor = $coursetooleditor->out(false);
|
||||
|
||||
echo get_string('lti_launch_error_unsigned_help', 'lti', $links);
|
||||
|
@ -54,12 +54,6 @@
|
||||
padding-right: 1em;
|
||||
} /* Prevent setting titles from wrapping */
|
||||
|
||||
/* Styles for instructor_edit_tool_type.php */
|
||||
#page-mod-lti-instructor_edit_tool_type .mform .fitem .fitemtitle {
|
||||
min-width: 18em;
|
||||
padding-right: 1em;
|
||||
} /* Prevent setting titles from wrapping */
|
||||
|
||||
/* Styling for tool_configure page */
|
||||
#registration-choice-container .buffer-text {
|
||||
margin: 20px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user