MDL-78597 mod_lti: remove tool configuration usage for course tools

This change removes the 'Tool configuration usage' control for course
tools being edited via site admin. All course tools are, at a minimum,
considered to be preconfigured tools and are visible in the course.
The visibility of course tools in the activity chooser will be
controlled via the LTI External tools course page in future.
This commit is contained in:
Jake Dallimore 2023-07-26 12:13:57 +08:00
parent 8ed8b6e9b9
commit 8825c0a0fe
No known key found for this signature in database
2 changed files with 28 additions and 17 deletions

View File

@ -180,21 +180,24 @@ class mod_lti_edit_types_form extends moodleform {
$mform->setForceLtr('lti_customparameters');
if (!empty($this->_customdata->isadmin)) {
$options = array(
LTI_COURSEVISIBLE_NO => get_string('show_in_course_no', 'lti'),
LTI_COURSEVISIBLE_PRECONFIGURED => get_string('show_in_course_preconfigured', 'lti'),
LTI_COURSEVISIBLE_ACTIVITYCHOOSER => get_string('show_in_course_activity_chooser', 'lti'),
);
if ($istool) {
// LTI2 tools can not be matched by URL, they have to be either in preconfigured tools or in activity chooser.
unset($options[LTI_COURSEVISIBLE_NO]);
$stringname = 'show_in_course_lti2';
} else {
$stringname = 'show_in_course_lti1';
// Only site-level preconfigured tools allow the control of course visibility in the site admin tool type form.
if (!$this->_customdata->iscoursetool) {
$options = array(
LTI_COURSEVISIBLE_NO => get_string('show_in_course_no', 'lti'),
LTI_COURSEVISIBLE_PRECONFIGURED => get_string('show_in_course_preconfigured', 'lti'),
LTI_COURSEVISIBLE_ACTIVITYCHOOSER => get_string('show_in_course_activity_chooser', 'lti'),
);
if ($istool) {
// LTI2 tools can not be matched by URL, they have to be either in preconfigured tools or in activity chooser.
unset($options[LTI_COURSEVISIBLE_NO]);
$stringname = 'show_in_course_lti2';
} else {
$stringname = 'show_in_course_lti1';
}
$mform->addElement('select', 'lti_coursevisible', get_string($stringname, 'lti'), $options);
$mform->addHelpButton('lti_coursevisible', $stringname, 'lti');
$mform->setDefault('lti_coursevisible', '1');
}
$mform->addElement('select', 'lti_coursevisible', get_string($stringname, 'lti'), $options);
$mform->addHelpButton('lti_coursevisible', $stringname, 'lti');
$mform->setDefault('lti_coursevisible', '1');
} else {
$mform->addElement('hidden', 'lti_coursevisible', LTI_COURSEVISIBLE_ACTIVITYCHOOSER);
}

View File

@ -127,9 +127,17 @@ if (lti_request_is_using_ssl() && !empty($type->lti_secureicon)) {
$type->oldicon = $type->lti_icon;
}
$form = new mod_lti_edit_types_form($pageurl,
(object)array('isadmin' => true, 'istool' => false, 'id' => $id, 'clientid' => $type->lti_clientid,
'coursecategories' => $type->lti_coursecategories));
$form = new mod_lti_edit_types_form(
$pageurl,
(object) [
'isadmin' => true,
'istool' => false,
'id' => $id,
'clientid' => $type->lti_clientid,
'coursecategories' => $type->lti_coursecategories,
'iscoursetool' => !empty($id) && $type->course !== get_site()->id
]
);
if ($data = $form->get_data()) {
$type = new stdClass();