MDL-78597 mod_lti: make new course tools show in activity chooser

This will only impact newly created course tools, not existing tools.
Existing tools will be listed in the LTI External tools page and
teachers will be able to add them to the activity chooser from there.
This commit is contained in:
Jake Dallimore 2023-07-25 18:12:00 +08:00
parent 6f4555d31d
commit 8ed8b6e9b9
No known key found for this signature in database
3 changed files with 32 additions and 16 deletions

View File

@ -196,7 +196,7 @@ class mod_lti_edit_types_form extends moodleform {
$mform->addHelpButton('lti_coursevisible', $stringname, 'lti');
$mform->setDefault('lti_coursevisible', '1');
} else {
$mform->addElement('hidden', 'lti_coursevisible', LTI_COURSEVISIBLE_PRECONFIGURED);
$mform->addElement('hidden', 'lti_coursevisible', LTI_COURSEVISIBLE_ACTIVITYCHOOSER);
}
$mform->setType('lti_coursevisible', PARAM_INT);

View File

@ -2,7 +2,7 @@
Feature: Add tools
In order to provide activities for learners
As a teacher
I need to be able to add external tools to a course
I need to be able to add instances of external tools to a course
Background:
Given the following "users" exist:
@ -14,30 +14,45 @@ Feature: Add tools
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I navigate to "Plugins > Activity modules > External tool > Manage tools" in site administration
And I follow "Manage preconfigured tools"
And I follow "Add preconfigured tool"
And I set the following fields to these values:
| Tool name | Teaching Tool 1 |
| Tool configuration usage | Show in activity chooser and as a preconfigured tool |
And I set the field "Tool URL" to local url "/mod/lti/tests/fixtures/tool_provider.php"
And I press "Save changes"
And I log out
# A site tool configured to show as a preconfigured tool and in the activity chooser.
And the following "mod_lti > tool types" exist:
| name | baseurl | coursevisible | state |
| Teaching Tool 1 | /mod/lti/tests/fixtures/tool_provider.php | 2 | 1 |
# A course tool in course 1.
And the following "mod_lti > course tools" exist:
| name | baseurl | course |
| Course tool 1 | /mod/lti/tests/fixtures/tool_provider.php | C1 |
@javascript
Scenario: Add a tool via the activity picker
Scenario: Add a site tool via the activity picker
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Teaching Tool 1" to section "1"
When I add a "Teaching Tool 1" to section "1"
# For tool that does not support Content-Item message type, the Select content button must be disabled.
And I set the field "Activity name" to "Test tool activity 1"
And I expand all fieldsets
And I set the field "Launch container" to "Embed"
And the "Select content" "button" should be disabled
And I press "Save and return to course"
When I open "Test tool activity 1" actions menu
And I open "Test tool activity 1" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Preconfigured tool" matches value "Teaching Tool 1"
And the "Select content" "button" should be disabled
And the "Tool URL" "field" should be disabled
@javascript
Scenario: Add a course tool via the activity picker
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I add a "Course tool 1" to section "1"
# For tool that does not support Content-Item message type, the Select content button must be disabled.
And I set the field "Activity name" to "Test tool activity 2"
And I expand all fieldsets
And I set the field "Launch container" to "Embed"
And the "Select content" "button" should be disabled
And I press "Save and return to course"
And I open "Test tool activity 2" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Preconfigured tool" matches value "Course tool 1"
And the "Select content" "button" should be disabled
And the "Tool URL" "field" should be disabled

View File

@ -118,7 +118,8 @@ class mod_lti_generator extends testing_module_generator {
if (!isset($type['course']) || $type['course'] == $SITE->id) {
throw new coding_exception('Must specify a non-site course when creating a course tool type.');
}
$type['coursevisible'] = LTI_COURSEVISIBLE_PRECONFIGURED; // The default for course tools.
$type['coursevisible'] = LTI_COURSEVISIBLE_ACTIVITYCHOOSER; // The default for course tools.
$type['state'] = LTI_TOOL_STATE_CONFIGURED; // The default for course tools.
lti_add_type((object) $type, (object) $config);
}
}