1

I'm trying to create a LTI provider for Moodle. The things that I need from Moodle - course name, students and teachers, as well as enabling a single sign on (getting the session, token, cookie...)

I did a research and saw that Moodle 3 supports LTI v2, which is basically a why to communicate through REST API with Moodle, but didn't see an API ref for the optional endpoints, or code samples (looking for nodejs, but every other language will be welcome)

Does anyone has experience with it? Thanks!

Yonatan
  • 1,192
  • 2
  • 12
  • 30

1 Answers1

0

this is a little (a lot) late but it might help someone else.

I have create a nodejs implementation of the Lti 1.3 advantage protocol that makes it super easy to setup a lti provider.

Ltijs

Here's a quick example of usage:

const path = require('path')

// Require Provider 
const Lti = require('ltijs').Provider

// Configure provider
const lti = new Lti('EXAMPLEKEY', 
            { url: 'mongodb://localhost/database', 
              connection:{ user:'user',
                          pass: 'pass'} 
            }, 
            { staticPath: path.join(__dirname, '/views/') })


let setup = async () => {
  // Configure main routes
  lti.appUrl('/')
  lti.loginUrl('/login')

  // Deploy and open connection to the database
  await lti.deploy()

  // Register platform
  let plat = await lti.registerPlatform(
    'http://platform/url', 
    'Platform Name', 'ClientIdThePlatformCreatedForYourApp', 
    'http://platform/AuthorizationUrl', 
    'http://platform/AccessTokenUrl', 
    { method: 'JWK_SET', key: 'http://platform/keyset' }
  )

  // Set connection callback
  lti.onConnect((connection, request, response) => {
    // Call redirect function
    lti.redirect(response, '/main')
  })

  // Set route accounting for issuer context
  lti.app.get('/:iss/main', (req, res) => {
    // Id token
    console.log(res.locals.token)
    res.send('It\'s alive!')
  })
}
setup()