Package: lti-consumer-xblock
PurposeThis XBlock implements the consumer side of the LTI specification enabling
integration of third-party LTI provider tools.Getting StartedInstallationFor details regarding how to deploy this or any other XBlock in the lms instance, see theinstalling-the-xblockdocumentation.Installing in Docker DevstackAssuming that yourdevstackrepo lives at~/code/devstackand thatedx-platformlives right alongside that directory, you’ll want
to checkoutxblock-lti-consumerand have it live in~/code/src/xblock-lti-consumer.
This will make it so that you can access it inside an LMS container shell
and easily make modifications for local testing.You will have to run the below instructions twice, once for the LMS and once for Studio.
Otherwise you will be using different versions of the xblock in the two containers.Runmake dev.shell.lmsormake dev.shell.studiofrom yourdevstackdirectory to enter a running container.
Once in there, you can do the following to have your devstack pointing at a local development
version ofxblock-lti-consumer:$pushd/edx/src/xblock-lti-consumer$virtualenvvenv/$sourcevenv/bin/activate$makeinstall$maketest# optional, if you want to see that everything works$deactivate$pushd# should take you back to /edx/app/edxapp/edx-platform$pipuninstall-ylti_consumer_xblock$pipinstall-e/edx/src/xblock-lti-consumerEnabling in StudioYou can enable the LTI Consumer XBlock in Studio through the
advanced settings.From the main page of a specific course, navigate toSettings->Advanced Settingsfrom the top menu.Check for theadvanced_modulespolicy key, and add"lti_consumer"to the policy value list.Click the “Save changes” button.DevelopingOne Time Setup# Clone the repositorygitclonegit@github.com:openedx/xblock-lti-consumer.gitcdxblock-lti-consumer# Set up a virtualenv using virtualenvwrapper with the same name as the repo and activate itmkvirtualenv-ppython3.8xblock-lti-consumerEvery time you develop something in this repo# Activate the virtualenvworkonxblock-lti-consumer# Grab the latest codegitcheckoutmastergitpull# Install/update the dev requirementsmakeinstall# Run the tests (to verify the status before you make any changes)maketest# Make a new branch for your changesgitcheckout-b<your_github_username>/<short_description># Using your favorite editor, edit the code to make your change.vim...# Changes to style rules should be made to the Sass files, compiled to CSS,
# and committed to the git repository.makecompile-sass# Run your new testspytest./path/to/new/tests# Run quality checksmakequality# Add a changelog entry to CHANGELOG.rst# Commit all your changesgitcommit...gitpush# Open a PR and ask for review.Package Requirementssetup.py contains a list of package dependencies which are required for this XBlock package.
This list is what is used to resolve dependencies when an upstream project is consuming
this XBlock package. requirements.txt is used to install the same dependencies when running
the tests for this package.Downloading translations from TransifexIf you want to download translations from Transifex installtransifex clientand run this command while
inside project root directory:$txpull-f--mode=reviewedFurther Development InfoSee thedeveloper guidefor implementation details and other developer concerns.TestingUnit TestingTo run all of the unit tests at once, runmake testTo run tests on individual files in development, runpython ./test.py -k=[name of test file without .py]For example, if you want to run the tests in test_permissions.py, runpython ./test.py -k=test_permissionsTo run a specific test in a file, run something likepython ./test.py -k=test_permissions.TestClass.test_functionTesting Against an LTI ProviderLTI 1.1http://lti.tools/saltire/provides a “Test Tool Provider” service that allows
you to see messages sent by an LTI consumer.We have some useful documentation on how to set this up here:http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/exercises_tools/lti_component.html#lti-authentication-informationIn Studio Advanced settings, set the value of the “LTI Passports” field to “test:test:secret” -
this will set the OAuth client key and secret used to send a message to the test LTI provider.Create an LTI Consumer problem in a course in Studio (after enabling it in “advanced_modules”
as seen above).  Make a unit, select “Advanced”, then “LTI Consumer”.Click edit and fill in the following fields:LTI ID: “test”LTI URL: “https://lti.tools/saltire/tp”Click save.  The unit should refresh and you should see “Passed” in the “Verification” field of
the message tab in the LTI Tool Provider emulator.Click the “Publish” button.View the unit in your local LMS.  If you get anImportError: No module named lti_consumer, you
shoulddocker-composerestart lms(since we previously uninstalled the lti_consumer to get the
tests for this repo running inside an LMS container).  From here, you can see the contents of the
messages that we are sending as an LTI Consumer in the “Message Parameters” part of the “Message” tab.LTI 1.3IMS Global provides a reference implementation of LTI 1.3 that can be used to test the XBlock.On LTI 1.3 the authentication mechanism used is OAuth2 using the Client Credentials grant, this means
that to configure the tool, the LMS needs to know the keyset URL or public key of the tool, and the tool
needs to know the LMS’s one.Instructions:Set up a local tunnel (usingngrokor a similar tool) to get a URL accessible from the internet.Add the following settings toedx-platform/lms/envs/private.pyandedx-platform/cms/envs/private.py:LTI_BASE=”http://localhost:18000”LTI_API_BASE=”http://<your_ngrok>.ngrok.io”Create a new course, and add thelti_consumerblock to the advanced modules list.In the course, create a new unit and add the LTI block.SetLTI VersiontoLTI 1.3.Set theTool Launch URLtohttps://lti-ri.imsglobal.org/lti/tools/In Studio, you’ll see a few parameters being displayed in the preview:Client ID: f0532860-cb34-47a9-b16c-53deb077d4de
Deployment ID: 1
# Note that these are LMS URLS
Keyset URL: http://1234.ngrok.io/api/lti_consumer/v1/public_keysets/88e45ecbd-7cce-4fa0-9537-23e9f7288ad9
Access Token URL: http://1234.ngrok.io/api/lti_consumer/v1/token/8e45ecbd-7cce-4fa0-9537-23e9f7288ad9
OIDC Callback URL: http://localhost:18000/api/lti_consumer/v1/launch/Set up a tool in the IMS Global reference implementation (https://lti-ri.imsglobal.org/lti/tools/).Click onAdd toolat the top of the page (https://lti-ri.imsglobal.org/lti/tools).Add the parameters and URLs provided by the block, and generate a private key onhttps://lti-ri.imsglobal.org/keygen/indexand paste it there (don’t close the tab, you’ll need the public key later).Go back to Studio, and edit the block adding its settings (you’ll find them by scrolling downhttps://lti-ri.imsglobal.org/lti/tools/until you find the tool you just created):Tool Launch URL: https://lti-ri.imsglobal.org/lti/tools/[tool_id]/launches
Tool Initiate Login URL: https://lti-ri.imsglobal.org/lti/tools/[tool_id]/login_initiations
Tool Public key: Public key from key page.Publish block, log into LMS and navigate to the LTI block page.ClickSend Requestand verify that the LTI launch was successful.LTI Advantage FeaturesThis XBlock supports LTI 1.3 and the following LTI Avantage services:Deep Linking (LTI-DL)Assignments and Grades services (LTI-AGS)Names and Roles Provisioning services (LTI-NRP)To enable LTI-AGS, you need to setLTI Assignment and Grades Servicein Studio to
allow tools to send back grades. There’s two grade interaction models implemented:Allow tools to submit grades only (declarative)(Default): enables LTI-AGS and
creates a single fixed LineItem that the tools can send grades too.Allow tools to manage and submit grades (programmatic): enables LTI-AGS and
enables full access to LTI-AGS endpoints. Tools will be able to create, manage and
delete multiple LineItems, and set multiple grades per student per problem.In this implementation, the tool is responsible for managing grades and linking them in the LMS.To enable LTI-DL and its capabilities, you need to set these settings in the block:Locate theDeep linkingsetting and set it toTrue (enabled).SetDeep Linking Launch URLsetting. You can retrieve it from the tool you’re integrating with.
If it’s not provided, try using the same value as in the LTI 1.3 Tool Launch URL.To enable LTI-NRPS, you setEnable LTI NRPStoTruein the block settings on Studio.LTI 1.1/1.2 Basic Outcomes Service 1.1This XBlock supportsLTI 1.1/1.2 Basic Outcomes Service 1.0. Please see theseLTI 1.1/1.2 Basic Outcomes Service 1.0 instructionsfor testing the LTI 1.1/1.2 Basic Outcomes Service 1.1 implementation.LTI 2.0 Result Service 2.0This XBlock supportsLTI 2.0 Result Service 2.0.
Please see theLTI 2.0 Result Service 2.0 instructionsfor testing the LTI 2.0 Result Service 2.0 implementation.LTI Reusable configurationThe LTI Consumer XBlock supports configuration reusability via plugins.
It is compatible with both LTI 1.1 and LTI 1.3.
All values (including the access token and keyset URL for LTI 1.3)
are shared across the XBlocks with the same external configuration ID.
This eliminates the need to have a tool deployment for each XBlock.How to SetupInstall and setup theopenedx-ltistoreplugin on the LMS and Studio.Go to LMS admin -> WAFFLE_UTILS -> Waffle flag course override
(http://localhost:18000/admin/waffle_utils/waffleflagcourseoverridemodel/).Create a waffle flag course override with these values:Waffle flag: lti_consumer.enable_external_config_filterCourse id: <your course id>Override choice: Force OnEnabled: TrueCreate a new external LTI configuration and use it in the XBlock.
This is explained in the README of theopenedx-ltistorerepository.Getting HelpIf you’re having trouble, we have discussion forums athttps://discuss.openedx.orgwhere you can connect with others in the
community.Our real-time conversations are on Slack. You can request aSlack
invitation, then join ourcommunity Slack workspace.For anything non-trivial, the best path is to open an issue in this
repository with as many details about the issue you are facing as you
can provide.https://github.com/openedx/xblock-lti-consumer/issuesFor more information about these options, see theGetting Helppage.LicenseThe code in this repository is licensed under the AGPL v3 License unless
otherwise noted.Please seeLICENSE.txtfor details.ContributingContributions are very welcome.
Please readHow To Contributefor details.This project is currently accepting all types of contributions, bug fixes,
security fixes, maintenance work, or new features.  However, please make sure
to have a discussion about your new feature idea with the maintainers prior to
beginning development to maximize the chances of your change being accepted.
You can start a conversation by creating a new issue on this repo summarizing
your idea.The Open edX Code of ConductAll community members are expected to follow theOpen edX Code of Conduct.PeopleThe assigned maintainers for this component and other project details may be
found inBackstage. Backstage pulls this data from thecatalog-info.yamlfile in this repo.Reporting Security IssuesPlease do not report security issues in public. Please emailsecurity@openedx.org.