Turn Your LTI 1.0 Consumer into an LTI 1.1 Consumer in 30 Minutes (or Less!)

If you have taken a peak at the source code in CodePlex lately, you may have noticed a new library project called LtiLibrary. I’m slowly pulling the LTI specific code out of Consumer (and eventually Provider) to make it easier to explain the code, and to make it easier to reuse.

Today I worked on the OutcomesController. This is the ApiController that implements the consumer side of the LTI 1.1 Basic Outcomes Service which is used to receive scores (grades, outcomes) from the provider.

I chose to implement the controller as an ApiController because MVC handles all the serialization and deserialization for me once I add the schema (which you can download from the IMS website as part of the LTI 1.1 specification) and tell MVC to use the XmlFormatter,

image

When the controller was part of the Consumer project, I mixed Consumer-specific code such as accessing the consumer database, with LTI code such as handling each outcome request. Since the outcome should eventually be saved in the database, I decided to implement the service as an abstract class in LtiLibrary called OutcomesControllerBase.

OutcomesServiceBase implements the only endpoint (a POST to api/outcomes). The consumer then implements a concrete OutcomesController which inherits from OutcomesServiceBase and implements 4 events handlers:

  • OnReplaceResult – Raised when the provider wants to save or update a result
  • OnReadResult – Raised when the provider wants to read a result
  • OnDeleteResult – Raised when the provider wants to delete a result
  • OnGetConsumerSecrets – Raised when the base class is authenticating the request

Each handler is quite short and only has to deal with implementation specific details such as saving the score in the database. For example,

image

To recap…if you want to add support for Basic Outcomes to your .NET consumer, follow these steps:

  1. Add the LtiLibrary project to your solution and reference LtiLibrary in your project.
  2. Create an OutcomesController that inherits from OutcomesControllerBase and implement the 4 handlers.
  3. Enable XmlSerialization in WebApiConfig.

That will turn your LTI 1.0 consumer into an LTI 1.1 consumer.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.