4

我正在寻找任何代码示例,以在 NodeJS 中使用 LTI 将外部工具集成到 LMS,但似乎很难找到工作示例。我已经浏览了IMS Global提供的示例,但很难理解。任何知道如何使用 LTI 授权应用程序的人请分享您的代码。

4

3 回答 3

5

我将 omsmith 代码从 CoffeeScript 移植到普通 JavaScript 并放在 Packagist 上:

https://github.com/tsugiproject/tsugi-node-lti

https://www.npmjs.com/package/tsugi-node-lti

于 2018-02-11T21:47:40.107 回答
2

Github 搜索产生了这些示例节点 LTI 应用程序 -

schul-cloud/node-lti-provider

惠特默/lti_example

omsmith/ims-lti-示例

希望其中之一对您有用。

于 2017-10-23T21:08:24.713 回答
1

这有点晚了,但它可能会帮助其他人。

我已经创建了 Lti 1.3 优势协议的 nodejs 实现,这使得设置 lti 提供者变得超级容易。

蒂斯

这是一个简单的用法示例:

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()
于 2019-07-06T20:26:40.867 回答