[BD-14] Configuring edx-platform to consume its own library content via LTI 1.3

You will need access to the Studio Django administration panel and add+change permissions on several models.

edXers: You can get this access via https://github.com/edx/app-permissions . The group you want is content_library_v2_admin.

This is a work-in-progress.

Overview

In this guide, we will configure an Open edX instance to serve itself library content via LTI 1.3. The instance will serve as both an LTI 1.3 Consumer and LTI 1.3 Provider. Specifically, a course on the instance will contain an LTI Consumer block that links to the same instance’s Content Library LTI Provider endpoints. In doing so, we have set up a very rudimentary v2-content-library-referencing system using existing platform capabilities.

With minimal differences, this same guide could be used to link together two Open edX instances, one as an LTI Consumer of the other’s LTI Provider-ed library content.

edXers: Here is one of the set of items I did this for:

Contents

Steps

Enable new feature to expose V2 content library blocks as LTI tools

This feature was recently (autumn 2021) contributed by OpenCraft. There are helpful in-code comments about it, but no official docs yet. Since the feature isn’t yet on-by-default, we must first enable it. This only needs to be done once per Open edX instance that you want to act as an LTI 1.3 provider for content libraries.

In studio.yml:

FEATURES: ... ENABLE_CONTENT_LIBRARIES_LTI_TOOL: true

edXers: We did this for our staging environment in this PR: https://github.com/edx/edx-internal/pull/5562.

Add an LTI tool key

This key pair will identify the LTI 1.3 Provider to the LTI 1.3 Consumer.

Below is the command I used to generate a private and public key:

ssh-keygen -t rsa -f my-openedx-ltitool.key -N "" ssh-keygen -y -f my-openedx-ltitool.key -e -m pem > my-openedx-ltitool.pub

Please note: I am using this key strategy in a non-production environment; it may not meet your security needs. If you’re using this guide for a production LTI tool, make sure you know what you’re doing w.r.t. key security or talk to someone who does, because I don’t.

Now, visit the Studio admin panel and navigate to the “PyLTI 1.3 Tool Config” section. For edXers, this is: https://studio-internal.stage.edx.org/admin/lti1p3_tool_config/

Add a tool key, making up a name. Paste the .key file into the Private Key field and the .pub file into the Public Key field. Save.

Create a new content library with some components

This is the library that will contain the reference-able content. In other words, it is on the “provider” side of the system.

Go to the Library Authoring MFE (edXers: https://library-authoring.stage.edx.org) click + New Library. Enter any name, organization, and library ID; just make sure “Complex” is selected as the library type.

Within the new library, go Settings > Details and enable public learning and public reading of content:

Back on the main library editing page, add a component or a few and hit Publish! (As of 2021-Oct, the visual editors for HTML, Video, and Problem are broken. You can edit blocks of those types by editing their OLX source directly, or you could use advanced components such as drag-and-drop).

Finally, click “Copy LTI URL” for the block you’d like to reference in your course. This is the “Launch URL” of the library component. Save it for the next step.

Reference the library from a course via the LTI Consumer Block

Now, we will add the LTI Consumer block that will “reference” the library content you created above.

In a course of your choosing, go to Advanced Settings. Add "lti_consumer" as an Advanced Module. Save. This will enable the LTI Consumer block for your course.

Go back to the course outline, and add a new unit (or enter an existing one).

Add a component by clicking “Advanced” and selecting “LTI Consumer”.

Edit the new block:

Display Name

(anything)

LTI Application Information

(anything)

LTI Version

LTI 1.3

Tool Launch URL

(your LTI launch URL from the library block)

Tool Initiate Login URL

https://studio.stage.edx.org/api/libraries/v2/lti/1.3/login/

Tool Public Key

(your LTI Tool public key from earlier)

Save, and you should see something like this:

Add an LTI tool configuration for your reference

In LTI lingo, a “Tool” is a resource from an LTI Provider that can be referenced on an LTI Consumer. In the LTI Provider, we must add configuration for this tool. In this guide, we will make a tool configuration specifically for the LTI Consumer block usage we added above. If one were to roll out this functionality more broadly, they could check “Use by default” and remove “Client id” so that it was used as the default configuration for LTI Consumption by this issuer.

So, back in the PyLTI 1.3 Tool Config section of the Studio admin panel (edXers: https://studio-internal.stage.edx.org/admin/lti1p3_tool_config/), add an “LTI 1.3 tool” instance with the fields:

Title

(anything)

Client id

“Client ID” shown by the LTI Consumer block.

Auth login url

“Login URL” from the LTI Consumer block

Auth token url

“Access Token URL” from the LTI Consumer block

Key set url

“Keyset URL” from the LTI Consumer block

Deployment ids

“Deployment ID” shown by the LTI Consumer block, written as a string in a JSON list. For example, if the Deployment ID from the block was 5, you would enter ["5"] for the field.

Tool key

The LTI Tool Key you created earlier. Must have the same public key as what you configured in the LTI Consumer Block.

Authorize your LTI tool configuration to expose your new library

Finally, we must link your tool configuration to your content library. This tells the LTI Provider feature that LTI content from your library may be exposed to LTI Consumers using the tool key and settings you just configured.

Go to the Django admin for the Content Libraries model (edXers: https://internal.courses.stage.edx.org/admin/content_libraries/contentlibrary), find your new library and select “Change”.

The only thing you should need to do is select the LTI tool configuration you just created and save.

Try it out!

Back in Studio, you can hit “View Live” to see your live LTI unit in courseware.

If everything is configured, right, you should see something like this:

Otherwise, you may see something like this: