首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为Moodle创建LTI提供程序

为Moodle创建LTI提供程序
EN

Stack Overflow用户
提问于 2016-11-09 18:51:11
回答 1查看 1.1K关注 0票数 2

我正在尝试为Moodle创建一个LTI提供程序。我需要从Moodle获得的东西-课程名称、学生和教师,以及启用单点登录(获取会话、令牌、cookie...)

我做了一个研究,发现Moodle3支持LTI,这基本上是为什么要通过REST API与Moodle通信,但没有看到可选端点的v2引用,也没有代码示例(寻找nodejs,但其他所有语言都会受欢迎)

有谁有使用它的经验吗?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-07-07 04:31:04

这有点(很多)晚了,但它可能会对其他人有所帮助。

我已经创建了Lti 1.3 advantage协议的nodejs实现,它使设置lti提供程序变得非常容易。

Ltijs

下面是一个简单的用法示例:

代码语言:javascript
复制
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()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40505181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档