I am trying to figure out how to determine the assignment number (that is, :id value in API call further on) from a Canvas LTI call (associated with assignment submission) so that I can get more information about the assignment (via GET /api/v1/courses/:course_id/assignments/:id ). I do get a bunch of POST parameters passed to my tool from Canvas shown below. Is there a Canvas API can that convert one of the id's (say resource_link_id for example) to an assignment number?
Here are some of the POST parameters for example:
Solved! Go to Solution.
I resolved my issue. My immediate problem is solved! However, I am still unsure about the relationship between <blti:launch_url> and <lticm:property name="url">. Do they need to be the same or can they be different? If they are different it does not work as expected. Is that a Canvas bug or a feature?
In any event, here is more information on how I went about troubleshooting my issue -- hopefully it is of some use to others who may experience similar issues.
You've gotta love open source code base. As always, digging through the source code (at canvas-lms/tool_launch.rb at stable · instructure/canvas-lms · GitHub ) gave me good hints for troubleshooting. As I guessed earlier, the issue was with my XML configuration file. Here is the first clue I got from the source code (copy-paste from tool_lauch.rb😞
hash['custom_canvas_assignment_id'] = '$Canvas.assignment.id'
hash['custom_canvas_assignment_title'] = '$Canvas.assignment.title'
hash['custom_canvas_assignment_points_possible'] = '$Canvas.assignment.pointsPossible' end
I had my privacy level set to name instead of public. Changed that in my XML as in:
That change alone did not fix my missing parameter issue. Reviewing the code more, my eye caught the following check:
hash['custom_canvas_course_id'] = '$Canvas.course.id'
hash['lis_course_offering_sourcedid'] = '$CourseSection.sourcedId'
That got me thinking if there is some dependency on tool and options URLs etc. So I changed by URL to be consistent throughout my XML configuration, that is, I ensured that:
Once I did those two changes, Viola! The magic/mystery parameters custom_canvas_assignment_id custom_canvas_course_id etc. (that were mentioned by @RobDitto and @garth in this conversation) showed up consistently and correctly in both Instructor and Test Student views.
You did not list all of the oAuth params, so I'm going to assume you have all of them.
The grade you post back is coming from your app, and must be a decimal, i.e. an 80% should be passed back as 0.8
When Canvas launches your LTI assignment, Canvas will pass a group of lis_* parameters in the oAuth header.
You need to store those on your end, then when you post the grade back, use those parameters to post the grade to the proper assignment/user. That's where the two variables I listed come into play. lis_result_sourceid represents the unique coures/user/assignment/submission, ensuring the grade is properly assigned in the gradebook.
Let me know if this get's you over the hump.
For an External Tool assignment, the name of the LTI form POST parameter will be custom_canvas_assignment_id. Its value will be that assignment's ID at the end of its URL in Canvas, as well as the :id in your GET API call.
Unfortunately, Canvas does not seem to include the lis_result_sourcedid oAuth configuration parameter in the call for me. Could this be an issue with the way I have my configuration XML file setup for my tool (associated with assignment submission)?
Unfortunately, I don't seem to be getting the custom_canvas_assignment_id as part of the POST request parameter from Canvas. Here are the only 3 custom_* parameters that I do get:
@RobDitto , you are correct, I goofed, sorry, the parameters are coming from the Form data. I should know better than to speak from memory : )
@raodm , let's make sure we are talking about the same thing. When I create a new assignment in Canvas, for "Submission Type" I select "External Tool" and point it at my LTI app. When the student clicks on the assignment, Canvas loads the assignment from my server. Is this the type of assignment you are talking about?
One thing to keep in mind, the parameter that Rob is talking about: custom_canvas_assignment_id, is specific to Canvas
The lis_result_sourcedid is compatible with all LTI compatible platforms. At least that is my understanding.
So if you plan to use your LTI on another LMS platform, you will want to use the lis_* parameters.
Here is a full list of parameters that I receive from the Form data when Canvas loads my LTI assignment:
OK, this is interesting -- I switched to "Student View" in Canvas, and with the "Student View" I do get lis_result_sourcedid as shown below (I would have to guess what those numbers correspond to next):
So, why don't I get that parameter as the "Instructor" of the same course?
That sounds right. As a teacher, you do not have an assignment submission for grading. You need to be a student in order to submit work. Hopefully you are over the hump : )
@garth Yes, I have exactly the LTI setup you described.
However, neither in the "Student View" or as "Instructor" I get the "custom_canvas_assignment_id" parameter (and a few more) you have listed above. However, I would like to get them.