mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 14:02:32 +02:00
MDL-54632 mod_lti: separate show as preconfigured and in activitychooser
This commit is contained in:
parent
ca7b16fa70
commit
bff0a28894
@ -102,14 +102,26 @@ class mod_lti_edit_types_form extends moodleform{
|
||||
$mform->setType('lti_customparameters', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_customparameters', 'custom', 'lti');
|
||||
|
||||
if (!$istool && !empty($this->_customdata->isadmin)) {
|
||||
$mform->addElement('advcheckbox', 'lti_coursevisible', ' ', ' ' . get_string('show_in_course', 'lti'));
|
||||
$mform->addHelpButton('lti_coursevisible', 'show_in_course', 'lti');
|
||||
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';
|
||||
}
|
||||
$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', '1');
|
||||
$mform->addElement('hidden', 'lti_coursevisible', LTI_COURSEVISIBLE_PRECONFIGURED);
|
||||
}
|
||||
$mform->setType('lti_coursevisible', PARAM_BOOL);
|
||||
$mform->setType('lti_coursevisible', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'typeid');
|
||||
$mform->setType('typeid', PARAM_INT);
|
||||
|
@ -433,10 +433,15 @@ $string['share_roster_admin_help'] = 'Specify whether the tool can access the li
|
||||
$string['share_roster_help'] = 'Specify whether the tool can access the list of users enrolled in this course.
|
||||
|
||||
Note that this setting may be overridden in the tool configuration.';
|
||||
$string['show_in_course'] = 'Show tool in activity chooser';
|
||||
$string['show_in_course_help'] = 'If ticked, this tool will be shown in the activity chooser for a teacher to select to add to a course. It will also be shown in the preconfigured tool dropdown menu when adding an external tool to a course.
|
||||
$string['show_in_course_activity_chooser'] = 'Show in activity chooser and as preconfigured tool';
|
||||
$string['show_in_course_lti1'] = 'Show when creating activities';
|
||||
$string['show_in_course_lti1_help'] = 'This tool can be shown in the activity chooser for a teacher to select to add to a course. It also can be shown in the preconfigured tool dropdown menu when adding an external tool to a course.
|
||||
|
||||
If left unticked, the tool configuration may be used if the correct launch URL is entered when adding an external tool to a course.';
|
||||
Alternatively, the tool configuration may not show up in the forms but only used if the correct launch URL is entered when adding an external tool to a course.';
|
||||
$string['show_in_course_lti2'] = 'Show when creating activities';
|
||||
$string['show_in_course_lti2_help'] = 'This tool can be shown in the activity chooser for a teacher to select to add to a course or in the preconfigured tool dropdown menu when adding an external tool to a course.';
|
||||
$string['show_in_course_no'] = 'Do not show, use for launch URL matching only';
|
||||
$string['show_in_course_preconfigured'] = 'Show as preconfigured tool when adding External tool';
|
||||
$string['size'] = 'Size parameters';
|
||||
$string['submission'] = 'Submission';
|
||||
$string['submissions'] = 'Submissions';
|
||||
|
@ -79,6 +79,10 @@ define('LTI_SETTING_NEVER', 0);
|
||||
define('LTI_SETTING_ALWAYS', 1);
|
||||
define('LTI_SETTING_DELEGATE', 2);
|
||||
|
||||
define('LTI_COURSEVISIBLE_NO', 0);
|
||||
define('LTI_COURSEVISIBLE_PRECONFIGURED', 1);
|
||||
define('LTI_COURSEVISIBLE_ACTIVITYCHOOSER', 2);
|
||||
|
||||
/**
|
||||
* Return the launch data required for opening the external tool.
|
||||
*
|
||||
@ -1088,19 +1092,26 @@ function lti_filter_tool_types(array $tools, $state) {
|
||||
* Returns all lti types visible in this course
|
||||
*
|
||||
* @param int $courseid The id of the course to retieve types for
|
||||
* @param array $coursevisible options for 'coursevisible' field,
|
||||
* default [LTI_COURSEVISIBLE_PRECONFIGURED, LTI_COURSEVISIBLE_ACTIVITYCHOOSER]
|
||||
* @return stdClass[] All the lti types visible in the given course
|
||||
*/
|
||||
function lti_get_lti_types_by_course($courseid) {
|
||||
function lti_get_lti_types_by_course($courseid, $coursevisible = null) {
|
||||
global $DB, $SITE;
|
||||
|
||||
if ($coursevisible === null) {
|
||||
$coursevisible = [LTI_COURSEVISIBLE_PRECONFIGURED, LTI_COURSEVISIBLE_ACTIVITYCHOOSER];
|
||||
}
|
||||
|
||||
list($coursevisiblesql, $coursevisparams) = $DB->get_in_or_equal($coursevisible, SQL_PARAMS_NAMED, 'coursevisible');
|
||||
$query = "SELECT *
|
||||
FROM {lti_types}
|
||||
WHERE coursevisible = 1
|
||||
WHERE coursevisible $coursevisiblesql
|
||||
AND (course = :siteid OR course = :courseid)
|
||||
AND state = :active";
|
||||
|
||||
return $DB->get_records_sql($query,
|
||||
array('siteid' => $SITE->id, 'courseid' => $courseid, 'active' => LTI_TOOL_STATE_CONFIGURED));
|
||||
array('siteid' => $SITE->id, 'courseid' => $courseid, 'active' => LTI_TOOL_STATE_CONFIGURED) + $coursevisparams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1132,7 +1143,7 @@ function lti_get_types_for_add_instance() {
|
||||
function lti_get_configured_types($courseid, $sectionreturn = 0) {
|
||||
global $OUTPUT;
|
||||
$types = array();
|
||||
$admintypes = lti_get_lti_types_by_course($courseid);
|
||||
$admintypes = lti_get_lti_types_by_course($courseid, [LTI_COURSEVISIBLE_ACTIVITYCHOOSER]);
|
||||
|
||||
foreach ($admintypes as $ltitype) {
|
||||
$type = new stdClass();
|
||||
|
@ -20,6 +20,7 @@ Feature: Add tools
|
||||
And I follow "Add preconfigured tool"
|
||||
And I set the following fields to these values:
|
||||
| Tool name | Teaching Tool 1 |
|
||||
| Show when creating activities | Show in activity chooser and as preconfigured tool |
|
||||
And I set the field "Tool base URL/cartridge URL" to local url "/mod/lti/tests/fixtures/tool_provider.html"
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
|
Loading…
x
Reference in New Issue
Block a user