MDL-54128 mod_lti: Add help for custom LTI tools in activity picker

This commit is contained in:
Jake Dallimore 2016-05-13 14:28:07 +08:00
parent 65cbefc403
commit f418d89957
4 changed files with 17 additions and 2 deletions

View File

@ -1289,6 +1289,14 @@ function get_module_metadata($course, $modnames, $sectionreturn = null) {
// otherwise append the link url to the module name.
$item->name = (count($items) == 1 &&
$item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link;
// If the module provides the helptext property, append it to the help text to match the look and feel
// of the default course modules.
if (isset($item->help) && isset($item->helplink)) {
$linktext = get_string('morehelp');
$item->help .= html_writer::tag('div',
$OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink'));
}
$modlist[$course->id][$modname][$item->name] = $item;
}
$return += $modlist[$course->id][$modname];

View File

@ -290,6 +290,7 @@ External tool activities differ from URL resources in a few ways:
* 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['modulename_shortcut_link'] = 'mod/lti/view/custom';
$string['modulenameplural'] = 'External tools';
$string['modulenamepluralformatted'] = 'LTI Instances';
$string['name'] = 'Name';

View File

@ -206,7 +206,8 @@ function lti_delete_instance($id) {
*
* @param stdClass $defaultitem default item that would be added to the activity chooser if this callback was not present.
* It has properties: archetype, name, title, help, icon, link
* @return array An array of aliases for this activity. Each element is an object with same list of properties as $defaultitem.
* @return array An array of aliases for this activity. Each element is an object with same list of properties as $defaultitem,
* plus an additional property, helplink.
* Properties title and link are required
**/
function lti_get_shortcuts($defaultitem) {

View File

@ -1126,7 +1126,7 @@ function lti_get_types_for_add_instance() {
*
* @param int $courseid The id of the course to retieve types for
* @param int $sectionreturn section to return to for forming the URLs
* @return array Array of lti types. Each element is object with properties: name, title, icon, help, link
* @return array Array of lti types. Each element is object with properties: name, title, icon, help, helplink, link
*/
function lti_get_configured_types($courseid, $sectionreturn = 0) {
global $OUTPUT;
@ -1138,6 +1138,11 @@ function lti_get_configured_types($courseid, $sectionreturn = 0) {
$type->modclass = MOD_CLASS_ACTIVITY;
$type->name = 'lti_type_' . $ltitype->id;
$type->title = $ltitype->name;
$trimmeddescription = trim($ltitype->description);
if ($trimmeddescription != '') {
$type->help = $trimmeddescription;
$type->helplink = get_string('modulename_shortcut_link', 'lti');
}
if (empty($ltitype->icon)) {
$type->icon = $OUTPUT->pix_icon('icon', '', 'lti', array('class' => 'icon'));
} else {