LTI

LTI provider that interfaces with the bot. This is a simple setup using Flask, because the PyLTI library already implements Flask decorators.

This module runs a flask server on 0.0.0.0:5000 (which maps to any host, port 5000). It accepts LTI requests using the key and secret in the settings file.

Adding the bot to your LMS

To add this tool to your LMS, you need to run it on your own server, say example.com. Currently it is started by running ./bot.py runclient, which starts an OTR bot and the LTI server. The server can then be reached at example.com:5000.

In your LMS, enter example.com:5000 as the launch URL for this LTI application. The “Consumer key” and “Shared secret” are in the settings file for your environment. In our settings.development_sample settings, find PYLTI_CONFIG. You can see that we added one consumer under “consumers”, which has __consumer_key__ as his consumer key, and __lti_secret__ as his secret. It is recommended to change these defaults.

Now it’s time to add your bot to the plugins/apps in your LMS. In canvas, follow these steps to add the bot to a course:

  • In your course, click Settings and then go to the Apps tab.
  • Click Add App
  • Choose “Manual entry”
  • The only fields that are currently relevant in Canvas are “Consumer key”, “Shared secret” and “Launch URL”. Follow your previously defined settings for the key and secret. The launch URL in our example is example.com:5000. Add a useful name in the “Name” field and keep the other fields empty.
  • Click the Submit button to save the app. Note that Canvas does not typically check any of the fields. To test the application, add the bot to an assignment.

And to add the bot to an assignment:

  • Go to Courses -> Assignments
  • Click + Assignment to add a new assignment and add a new assignment.
  • Click the + next to your new assignment to add a sub-assignment.
  • Click “More options” to be able to add LTI components.
  • Write whatever you want in the screens, an Assignment name is required for the assignment to be saved. Be sure to add “Points” to the assignment if you want to be able to see grades.
  • Under “Submission Type” choose “External Tool” Insert example.com:5000 as the URL for the external tool.
  • Save the assignment. You will now see an example of the course page you just made, with the OTR bot screen that is provided through LTI.
  • Note that the OTR bot only supplies a grade if the assignment is viewed by a student: in the teacher environment, no grade will be passed back to Canvas.
otrbot.lti.lti.app = <Flask 'otrbot.lti.lti'>

The flask decorator (unfortunately does not follow conventions).

otrbot.lti.lti.mock_ltid(_app=None, _request='any', error=None, role='any', *lti_args, **lti_kwargs)

For debug purposes, replace the normal lti decorator with this one, that returns ‘mock-lti’ as nickname and does not verify or authenticate

otrbot.lti.lti.BOT = None

It is important to initialise the bot variable before calling ‘run()’. It should point to an instance of the OtrBot class.

otrbot.lti.lti.get_locale()

Try to set the locale to something sensible

otrbot.lti.lti.error_page(exception=None)

Render error page

Parameters:exception – optional exception
Returns:the error.plim template rendered
otrbot.lti.lti.hello_world(lti=<function lti>)

Indicate the flask app is working. Provided for debugging purposes.

Parameters:lti – the lti object from pylti
Returns:simple page that indicates the request was processed by the lti provider
otrbot.lti.lti.index(*args, **kwargs)

initial access page to the lti provider. This page provides authorization for the user. Contains a button to enter a JID

Parameters:lti – the lti object from pylti
Returns:index page for lti provider
otrbot.lti.lti.enter_jid(*args, **kwargs)

Insert a JID for the bot to add to its roster. The form validates the JID using SleekXMPP’s JID constructor. After that, it tries to add the JID to the bot. If that fails (unlikely), the error page is shown.

Parameters:lti – the lti object from pylti
Returns:Either the form to enter the jid or a redirect to the jid_entered page.
otrbot.lti.lti.jid_entered(*args, **kwargs)

A page that confirms that the jid was added to the bot. Contains a button that directs the user tot he “ask_for_secret” page.

Parameters:lti – the lti object from pylti
Returns:The page confirming the jid was added.
otrbot.lti.lti.ask_for_secret(*args, **kwargs)

Show a form to submit a shared secret. When the secret is submitted, it is utf-8 encoded and added to the bot. The bot then checks if the secret is strong enough. If so, it saves it, else, the user is informed about this through Jabber, and asked to enter a new secret through LTI.

If this function is called when a strong secret is already set, the page is skipped and the next page is loaded, where the user is notified that his secret is added.

Parameters:lti – the lti object from pylti
Returns:Either a page showing the secret form or a page saying that the secret was entered.
otrbot.lti.lti.enter_bot_secret(*args, **kwargs)

Form to enter the secret that the bot shares after SMP is successful

otrbot.lti.lti.run_lti()

For if you want to run the flask development server directly