Showing results for 
Search instead for 
Did you mean: 
Community Participant

How to determine Assignment number from LTI call?

Jump to solution


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:

1 Solution

Accepted Solutions
Community Participant

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😞

def add_assignment_substitutions!(assignment)     
    if tool.public?
         hash['custom_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:

<lticm:property name="privacy_level">public</lticm:property>

That change alone did not fix my missing parameter issue. Reviewing the code more, my eye caught the following check:

     if context.is_a?(LTICourse)
           hash['custom_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:


matched with

    <lticm:options name="homework_submission">
         <lticm:property name="url"></lticm:property>

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.

View solution in original post

14 Replies
Community Coach
Community Coach

 @raodm ​, because of the technical nature of this question I'm going to share it with the Canvas Developers​ group in the community to see if they can help!

Community Champion

You did not list all of the oAuth params, so I'm going to assume you have all of them.

  • lis_outcome_service_url - this is the post back url, the API endpoint you will call to pass the grade
  • lis_result_sourcedid - this is the unique identifier of the assignment you want to grade

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.

Community Champion

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.

Community Participant

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)?

Community Participant

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:

custom_canvas_assignment_title=Test Assignment
Community Champion

 @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:













































Community Participant

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?

Community Champion

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 : )

Community Participant

 @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.