LTI launch from Rich Text Editor

226 views
Skip to first unread message

Jared Chapman

unread,
Sep 2, 2015, 7:49:29 AM9/2/15
to Canvas LMS Users
I am trying to embed an LTI into a Page.


However the resulting iFrame would not load properly because it did not get any POST variables


However, after reading it and experimenting for 6 hours or so, I could not get it to work. I have poured over the examples but can't see what I am doing wrong.

My TP will load in the modal window from the rich text editor, however, when I click submit, it only goes to the "Retrieving Content..." page and stalls.

Would someone mind looking over my code to see if you can spot my error?


LTI creation XML

<?xml version="1.0" encoding="UTF-8"?>
<blti:title>Greenhouse</blti:title>
<blti:description>Embed Delphinium Components</blti:description>
<blti:launch_url>https://delphinium.uvu.edu/live/greenhouse</blti:launch_url>
<blti:extensions platform="canvas.instructure.com">
<lticm:options name="editor_button">
<lticm:property name="message_type">ContentItemSelectionRequest</lticm:property>
<lticm:property name="url">https://delphinium.uvu.edu/live/greenhouse</lticm:property>
</lticm:options>
<lticm:property name="icon_url">https://delphinium.uvu.edu/octobercms/themes/demo/assets/images/favicon.png</lticm:property>
<lticm:property name="selection_height">800</lticm:property>
<lticm:property name="selection_width">600</lticm:property>
</blti:extensions>
</cartridge_basiclti_link>


PHP

$this['return_url'] = $_POST["content_item_return_url"];


HTML

<form action="{{return_url}}" method="post" encType="application/x-www-form-urlencoded">
    <input type="hidden" name="lti_message_type" value="ContentItemSelection" />
    <input type="hidden" name="lti_version" value="LTI-1p0" />
    <input type="hidden" name="content_items" value="{&quot;@context&quot;: &quot;http://purl.imsglobal.org/ctx/lti/v1/ContentItem&quot;, &quot;@graph&quot;: [{&quot;@type&quot;: &quot;ContentItem&quot;,&quot;@id&quot;: &quot;https://delphinium.uvu.edu/live/greenhouse-render&quot;,&quot;url&quot;: &quot;https://delphinium.uvu.edu/live/greenhouse-render&quot;,&quot;title&quot;: &quot;Greenhouse&quot;,&quot;text&quot;: &quot;Embed Greenhouse components&quot;,&quot;mediaType&quot;: &quot;application/vnd.ims.lti.v1.ltilink&quot;,&quot;placementAdvice&quot;: {&quot;displayWidth&quot; : 800,&quot;presentationDocumentTarget&quot; : &quot;iframe&quot;,&quot;displayHeight&quot; : 600}}]}" />
    <input type="submit" value="Submit me!"/>
</form>

Nathan Mills

unread,
Sep 2, 2015, 2:12:37 PM9/2/15
to Canvas LMS Users
Looking at your the "@type" in your content_items JSON, I think you have the wrong type.  For an LTI Launch the type should be: "LtiLinkItem", it looks like you have it set to "ContentItem.  Give that a try and see if it solves the problem.

Jared Chapman

unread,
Sep 2, 2015, 4:12:42 PM9/2/15
to Canvas LMS Users
Better! Now it puts in the iframe, but loads canvas inside and gives the error "could not find valid settings for this" or something like that. Any thought?

Nathan Mills

unread,
Sep 2, 2015, 4:24:11 PM9/2/15
to Canvas LMS Users
You probably need to set the domain on the tool configuration. The way Canvas looks up the settings needed to do the launch for embeded launches is by using url matching to look up the tool. So your xm config should look something like this:

                <lticm:property name="domain">example.com</lticm:property>
<lticm:options name="editor_button">
<lticm:property name="message_type">ContentItemSelectionRequest</lticm:property>
<lticm:property name="url">https://delphinium.uvu.edu/live/greenhouse</lticm:property>
</lticm:options>
<lticm:property name="icon_url">https://delphinium.uvu.edu/octobercms/themes/demo/assets/images/favicon.png</lticm:property>
<lticm:property name="selection_height">800</lticm:property>
<lticm:property name="selection_width">600</lticm:property>
</blti:extensions>
</cartridge_basiclti_link>

Jared Chapman

unread,
Sep 2, 2015, 4:35:17 PM9/2/15
to Canvas LMS Users
Yes! Yes! Yes! Fist pump in the air!

Thanks so much! It works! Very exciting!

Jared Chapman

unread,
Sep 3, 2015, 2:54:31 PM9/3/15
to Canvas LMS Users
Here is another quick question. I am trying to post custom data to the TP in the iframe, according to these instructions: http://www.imsglobal.org/lti/ltiv1p2pd/ltiCIMv1p0pd.html

But they don't come through. I added this to my form: &quot;custom&quot; : { &quot;domain&quot; : &quot;here&quot; } and changed the mediaType to application/vnd.ims.lti.v1.launch+json

Do you see anything wrong?

<form action="{{return_url}}" method="post" encType="application/x-www-form-urlencoded">
    <input type="hidden" name="lti_message_type" value="ContentItemSelection" />
    <input type="hidden" name="lti_version" value="LTI-1p0" />
    <input type="hidden" name="content_items" value="{&quot;@context&quot;: &quot;http://purl.imsglobal.org/ctx/lti/v1/ContentItem&quot;, &quot;@graph&quot;: [{&quot;@type&quot;: &quot;LtiLinkItem&quot;,&quot;@id&quot;: &quot;https://delphinium.uvu.edu/live/greenhouse-render&quot;,&quot;url&quot;: &quot;https://delphinium.uvu.edu/live/greenhouse-render&quot;,&quot;title&quot;: &quot;Greenhouse&quot;,&quot;text&quot;: &quot;Embed Greenhouse components&quot;,&quot;mediaType&quot;: &quot;application/vnd.ims.lti.v1.launch+json&quot;,&quot;placementAdvice&quot;: {&quot;displayWidth&quot; : 800,&quot;presentationDocumentTarget&quot; : &quot;iframe&quot;,&quot;displayHeight&quot; : 600, &quot;custom&quot; : { &quot;domain&quot; : &quot;here&quot; }}}]}" />

Nathan Mills

unread,
Sep 3, 2015, 3:06:04 PM9/3/15
to Canvas LMS Users
Unfortunately that is something we don't support yet, but is something we want to add.  Until we have support for it the workaround we suggest is to add the custom data as query parameters on the launch url itself.  

Jared Chapman

unread,
Sep 3, 2015, 3:11:29 PM9/3/15
to Canvas LMS Users
Oh, well that is good to know, thanks!

Jared Chapman

unread,
Sep 3, 2015, 3:15:58 PM9/3/15
to Canvas LMS Users
Any idea why [custom_canvas_api_domain] => uvu.instructure.com is not coming through either the TP configuration launch post data or iframe post data? More important, a way I can get that value?

Nathan Mills

unread,
Sep 3, 2015, 3:24:28 PM9/3/15
to Canvas LMS Users
The first thing to check would be that you have the custom variable substation setup in your tools config.  If you don't have it configured you can add it to your xml config like so:
<blti:custom>
<lticm:property name="sub_canvas_api_domain">$Canvas.api.domain</lticm:property>
</blti:custom>

The other thing that could be happening is if you have multiple tools configured with the same domain, then when the tool launches it could be grabbing the config from a different tool with the same domain. The reason this can happen is that for custom url launches we make a best effort at launch to look up the tool config via url matching to all the tools configured in the course/account.

Jared Chapman

unread,
Sep 3, 2015, 3:58:19 PM9/3/15
to Canvas LMS Users
Worked, thank you!

Jared Chapman

unread,
Sep 3, 2015, 4:02:39 PM9/3/15
to Canvas LMS Users
The user id that the POST is sending is weird something like  [user_id] => deae96a887dc4c166cb19ee865ebeb543b3d9160  I typically expect something like 456839 so the LTI does no seem to be able to figure out who is logged in. Am I missing something?

Jared Chapman

unread,
Sep 3, 2015, 4:13:50 PM9/3/15
to Canvas LMS Users
It also does not return 

[custom_canvas_course_id] => ************
[custom_canvas_user_id] => ************
[custom_canvas_user_login_id] => ************
[launch_presentation_height] => 400
[launch_presentation_width] => 800
[lis_course_offering_sourcedid] => MGMT-3000-X04-X05-Fall 2015-XLIST
[lis_person_contact_email_primary] => ************
[lis_person_sourcedid] => ************
[user_image] => ************


Can this be added the same way I added the domain? If so, is there a resource for getting those variables (i.e., $Canvas.api.domain)

Jared Chapman

unread,
Sep 3, 2015, 4:19:43 PM9/3/15
to Canvas LMS Users
I think I found them all here https://github.com/csev/tsugi/blob/master/lti/tool_config.xml, I'll let you know if I still have trouble. Thanks again for all your help.
Reply all
Reply to author
Forward
0 new messages