To Our Amazing Educators Everywhere,
Happy Teacher Appreciation Week!
Found this content helpful? Log in or sign up to leave a like!
Hello - I'm working on an LTI 1.3 tool, and it seems quite straightforward to retrieve Course membership via the NRPS endpoint included in the ID token when a user launches from a course. However, the membership does not seem to be broken down by section. Is there a way to retrieve section membership using LTI APIs without using Canvas-specific REST APIs?
Solved! Go to Solution.
@CarlReiner as @JamesSekcienski suggested you can use the variable substitutions. A NRPS call will then allows you to retrieve all the members and included with each membership are the custom variables substituted for each user.
This means you can see all the names of the sections for every user enrolled in the course. You can also get the IDs of the sections with Canvas.course.sectionIds. While they are both arrays I don't know if there's any guarantee that the ordering will be the same.
This is an snippet of a NRPS response (in this case it's the entry for me) and the same data is returned for every member of the course (just remember NRPS paging).
{
"status": "Active",
"name": "Matthew Buckett",
"picture": "https://secure.gravatar.com/avatar/2af16812634729f02aefa45e87028341?s=128&d=identicon",
"given_name": "Matthew",
"family_name": "Buckett",
"email": "matthew@somewhere.com",
"lis_person_sourcedid": "buckett",
"user_id": "39d7838d-9784-4b7a-b438-......",
"lti11_legacy_user_id": "5de1538afb8f1cab07a03c891df215.....",
"roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"message": [
{
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"locale": "en-GB",
"https://purl.imsglobal.org/spec/lti/claim/custom": {
"canvas_user_id": "1234",
"canvas_user_login_id": "buckett",
"canvas_user_sis_source_id": "buckett",
"canvas_user_sis_integration_id": "buckett",
"canvas_user_prefer_high_contrast": "$Canvas.user.prefersHighContrast",
"com_instructure_user_section_names": "[\"My Section\", \"Other Section\"]",
"com_instructure_brand_config_json_url": "$com.instructure.brandConfigJSON.url"
},
"https://purl.imsglobal.org/spec/lti/claim/lti11_legacy_user_id": "5de1538afb8f1cab07a03c891df215.....",
"https://purl.imsglobal.org/spec/lti/claim/lti1p1": {
"user_id": "5de1538afb8f1cab07a03c891df215....."
}
}
]
},
I haven't developed an LTI before, but have you tried using any of the variable substitutions? The following looks like it may be one that could provide the information you need.
Returns an array of the section names in a JSON-escaped format that the user is enrolled in, if the context of the tool launch is within a course.
Availability: when launched from a course
Launch Parameter: com_instructure_user_section_names
[\"Section 1, M-T\", \"Section 2, W-Th\", \"TA Section\"]
Hey @JamesSekcienski - That's a great thought. I've explored it, but it doesn't quite get me there. My goal is to be able to sync a Canvas course roster, including having the students divided by section, into my LTI tool. Using variable substitution, I can discover all the section names/IDs for a course, and I can figure out which sections the specific user who launched the tool belongs to. But that means I would only be able to piece together a complete section as students launch the tool; it doesn't provide access to a complete roster.
@CarlReiner as @JamesSekcienski suggested you can use the variable substitutions. A NRPS call will then allows you to retrieve all the members and included with each membership are the custom variables substituted for each user.
This means you can see all the names of the sections for every user enrolled in the course. You can also get the IDs of the sections with Canvas.course.sectionIds. While they are both arrays I don't know if there's any guarantee that the ordering will be the same.
This is an snippet of a NRPS response (in this case it's the entry for me) and the same data is returned for every member of the course (just remember NRPS paging).
{
"status": "Active",
"name": "Matthew Buckett",
"picture": "https://secure.gravatar.com/avatar/2af16812634729f02aefa45e87028341?s=128&d=identicon",
"given_name": "Matthew",
"family_name": "Buckett",
"email": "matthew@somewhere.com",
"lis_person_sourcedid": "buckett",
"user_id": "39d7838d-9784-4b7a-b438-......",
"lti11_legacy_user_id": "5de1538afb8f1cab07a03c891df215.....",
"roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"message": [
{
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"locale": "en-GB",
"https://purl.imsglobal.org/spec/lti/claim/custom": {
"canvas_user_id": "1234",
"canvas_user_login_id": "buckett",
"canvas_user_sis_source_id": "buckett",
"canvas_user_sis_integration_id": "buckett",
"canvas_user_prefer_high_contrast": "$Canvas.user.prefersHighContrast",
"com_instructure_user_section_names": "[\"My Section\", \"Other Section\"]",
"com_instructure_brand_config_json_url": "$com.instructure.brandConfigJSON.url"
},
"https://purl.imsglobal.org/spec/lti/claim/lti11_legacy_user_id": "5de1538afb8f1cab07a03c891df215.....",
"https://purl.imsglobal.org/spec/lti/claim/lti1p1": {
"user_id": "5de1538afb8f1cab07a03c891df215....."
}
}
]
},
Thanks @matthew_buckett! That JSON was very helpful because it led me to figure out how you were getting those custom Canvas variables in the NRPS response. The key was providing a resource link ID in the call to the NRPS endpoint; custom variable substitutions don't come back at all in a "bare" call even if they are configured for the developer key used to provision the JWT.
To participate in the Instructure Community, you need to sign up or log in:
Sign In