Skip to content

Commit

Permalink
MDL-36224: Improving lti_get_types
Browse files Browse the repository at this point in the history
If there are no LTI source plugins that
need to be added to the activity chooser
menu, then fallback to the default
activity chooser display.
  • Loading branch information
polothy authored and Damyon Wiese committed Nov 8, 2013
1 parent 4d7a2c9 commit 8cf7670
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mod/lti/lang/en/lti.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
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'] = 'Global tool types';
$string['grading'] = 'Grade Routing';
$string['icon_url'] = 'Icon URL';
Expand Down Expand Up @@ -267,7 +268,7 @@
* External tools support reading, updating, and deleting grades associated with the activity instance
* External tool configurations create a trust relationship between your site and the tool provider, allowing secure communication between them';
$string['modulename_link'] = 'mod/lti/view';
$string['modulenameplural'] = 'basicltis';
$string['modulenameplural'] = 'External Tools';
$string['modulenamepluralformatted'] = 'LTI Instances';
$string['never'] = 'Never';
$string['new_window'] = 'New window';
Expand Down
42 changes: 35 additions & 7 deletions mod/lti/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,46 @@ function lti_delete_instance($id) {
}

function lti_get_types() {
$type = new stdClass();
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = 'lti';
$type->typestr = get_string('modulename', 'mod_lti');

$types = array($type);
global $OUTPUT;

$subtypes = array();
foreach (get_plugin_list('ltisource') as $name => $dir) {
if ($moretypes = component_callback("ltisource_$name", 'get_types')) {
$types = array_merge($types, $moretypes);
$subtypes = array_merge($subtypes, $moretypes);
}
}
if (empty($subtypes)) {
return MOD_SUBTYPE_NO_CHILDREN;
}

$types = array();

$type = new stdClass();
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = 'lti_group_start';
$type->typestr = '--'.get_string('modulenameplural', 'mod_lti');
$types[] = $type;

$link = get_string('modulename_link', 'mod_lti');
$linktext = get_string('morehelp');
$help = get_string('modulename_help', 'mod_lti');
$help .= html_writer::tag('div', $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));

$type = new stdClass();
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = 'lti';
$type->typestr = get_string('generaltool', 'mod_lti');
$type->help = $help;
$types[] = $type;

$types = array_merge($types, $subtypes);

$type = new stdClass();
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = 'lti_group_end';
$type->typestr = '--';
$types[] = $type;

return $types;
}

Expand Down
2 changes: 1 addition & 1 deletion mod/lti/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function definition() {
if ($type = optional_param('type', false, PARAM_ALPHA)) {
component_callback("ltisource_$type", 'add_instance_hook');
}

$this->typeid = 0;

$mform =& $this->_form;
Expand Down

0 comments on commit 8cf7670

Please sign in to comment.