NOTE: This post is obsolete. LtiLibrary is now on GitHub, along with several samples.
IMS LTI™ is a technology which helps one educational system interoperate with another. For example, a Learning Management System (LMS) can launch an educational tool with enough context that the tool knows if the user a student or teacher, which institution they belong to, and even which course section they are enrolled in.
In this post, I show how to use my .NET LtiLibrary to make a simple LTI request to launch the IMS LTI™ test tool.
Get LtiLibrary from CodePlex
LtiLibrary is a project within LTI Samples on CodePlex. LTI Samples has two complete sample web sites: a Consumer and a Provider. But for this example, you only need the LtiLibrary project.
You will notice that LtiLibrary depends on EntityFramework, HtmlAgilityPack, and OAuth.net. The easiest way to get EntityFramework and HtmlAgilityPack is with nuget. You will have to download and unzip OAuth.net the old fashioned way.
Make sure you can build the LtiLibrary project before you continue.
Hook Up LtiLibrary to Your Web Site
First add a reference to the LtiLibrary project to your ASP.NET MVC web site project, then add a new Action called Launch to one of your controllers:
public ActionResult Launch() { var request = new LtiLibrary.Consumer.LtiOutboundRequest { ConsumerKey = "12345", ConsumerSecret = "secret", ContextId = "1", ResourceLinkId = "1", Url = "http://www.imsglobal.org/developers/LTI/test/v1p1/tool.php" }; return View(request.GetLtiRequestModel()); }
Now add the corresponding View (e.g. Launch.cshtml) to post the LTI launch request:
@model LtiLibrary.Consumer.LtiOutboundRequestViewModel <form id="form" action="@Model.Action" method="post"> @foreach (var name in Model.Fields.AllKeys) { <input type="hidden" name="@name" value="@Model.Fields[name]" /> } <input type="hidden" name="oauth_signature" value="@Model.Signature" /> </form> @section Scripts { <script> $(function () { $("#form").submit(); }); </script> }
And finally, add a link or button that invokes the Action:
Launch
When you click on the link or button, you should see IMS LTI™ test tool appear and display details of your request:
What’s Next?
Check out the sample Consumer in LTI Samples to see a more robust use of LtiLibrary. If you are a publisher, the sample Provider shows how to use LtiLibrary to handle LTI launch requests and even send grades back to the consumer.
Hi, Andy. It doesn’t work for me. It seems that namespace Consumer was removed from LtiLibrary.’
Hello Kate,
I have not looked at this post in quite a while. The old LtiLibrary (version 1.4 and below) is out of date. The new LtiLibrary is on GitHub and is split in two: LtiLibrary.Core and LtiLibrary.AspNet. Please take a look at the samples (especially SimpleLti) to see how to add LTI consumer functionality to your application.