From the LTI 1.1.1 specification,
resource_link_description=…
A plain text[1] description of the link’s destination, suitable for display alongside the link. Typically no more than a few lines long. This parameter is optional.
[1] Plain text means that the Tool Provider will treat the parameter value as text/plain and not text/html. If the TC includes characters such as less-than or greater-than in plain text fields, those characters are to be escaped and displayed. In particular, the TC should not embed HTML tags in plain text fields with the expectation that the HTML will be handed directly to the browser. For example, if a plaintext field contains the string “Building <strong> Interoperability”, the TP should escape the data so the user sees the less-than, greater-than, and text between them literally rather than switching the word “Interoperability” to be in bold font.
The Consumer site supports HTML assignment descriptions. So we need to convert the HTML to plain text for the resource_link_description. Poking around StackOverflow, I kept reading about HtmlAgilityPack. It turns out to be pretty easy to use.
First, I installed HtmlAgilityPack using NuGet. Then I wrote an extension method called ToPlainText for the HtmlDocument type based on the HtmlAgilityPack Html2Text sample. And finally, I modified BuildBaseLtiRequestData to add the resource_link_description.
// The description is entirely optional, but if you do include it, it // must be converted to plain text. if (!string.IsNullOrWhiteSpace(assignment.Description)) { var doc = new HtmlDocument(); doc.LoadHtml(assignment.Description); parameters.AdditionalParameters.Add("resource_link_description", doc.ToPlainText()); }
The source code is checked in to CodePlex.