Skip to content

Instantly share code, notes, and snippets.

@acbart
Last active July 27, 2018 22:17
Show Gist options
  • Save acbart/23507c18723b62253734 to your computer and use it in GitHub Desktop.
Save acbart/23507c18723b62253734 to your computer and use it in GitHub Desktop.
Snippet to modify an external tool on Canvas via JS.
// Query to GET a list of external tools, filter it for your tool, and then PUT it's changes
// Need to change the <course_id>, add your filtering criteria, and
// customize your data attributes for the tool.
$.get('https://canvas.instructure.com/api/v1/courses/<course_id>/external_tools/', {}, function(result) {
$.each(data, function(i, item) {
if (item /* matches some criteria, maybe the name? */) {
$.ajax({ url: 'https://canvas.instructure.com/api/v1/courses/<course_id>/external_tools/'+item.id,
type: 'put',
data: {'course_navigation[enabled]': 'true',
'user_navigation[text]': 'Something Cool',
'user_navigation[url]': 'https://example.com/ims/lti/user_endpoint'}
})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment