Using the API to associate External Tools with Assignments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm able to use the API to create Assignments as well as create External Tools, but am not quite sure how to link the 2 up with the API. For my particular use case, 5 different external tools will be associated with 5 different assignments. The urls to the external tools are identical but they have a custom field to differentiate them.
According to the docs, I need to use:
assignment[external_tool_tag_attributes]
Hash of attributes if submission_types is ["external_tool"] Example:
external_tool_tag_attributes: { %r/ url to the external tool url: "http://instructure.com", %r/ create a new tab for the module, defaults to false. new_tab: false}
when I create my assignment.
I then have 2 questions...
1) Since there are different possible hashing methods, how does Canvas know which one I'm using?
I must be missing the boat on this one.
2) Since my external tools differ only in the custom field (differentiating for the purpose of grade passback),
how would Canvas know which particular Tool goes with which Assignment? Perhaps there's a smarter approach to this?
Thanks so much for your thoughts!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, I figured out how to achieve what I wanted to achieve and am outlining the steps below hoping that it might help someone else out.
First, to add an external URL to the assignment object, pass:
assignment[external_tool_tag_attributes][url] = 'https://my_favorite_url.com'
to your list of parameters. Your assignment will then contain the external tool URL.
The tricky part was then how to create custom assignments: I needed the external URL to differ by a custom field to help in specifying a specific assignment to help with grade pass back. My solution was to create files which had names like: https://my_favorite_site.com/assignments/1.php which were created at the time of the assignment creation.
Then, in that file I had something like:
$the_get_variable_I_want = basename(__FILE__, '.php');
require_once(DOCUMENT_ROOT . 'the_place_where_I_do_my_LTI_stuff.php');
Then, my LTI file will be passed $the_get_variable_I_want. So, I'll have one external tool url for each assignment and then grades can be passed back accordingly. Finally, for those of you who need multiple custom variables, the "1" above could represent a record in your database, saved at the time of assignment creation by assignment id, and then used to look up any number of variables that you actually need. Or, as another alternative, your file could be something like 1-2-3.php and then you can pull out the 1, 2, 3 and use them accordingly.
I hope that at least one of you will find this helpful.