为 Moodle 创建 LTI 提供程序 [英] Creating a LTI provider for Moodle
问题描述
我正在尝试为 Moodle 创建 LTI 提供程序.我需要从 Moodle 获得的东西 - 课程名称、学生和教师,以及启用单点登录(获取会话、令牌、cookie...)
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...)
我做了一项研究,发现 Moodle 3 支持 LTI v2,这基本上是为什么要通过 REST API 与 Moodle 进行通信,但没有看到可选端点的 API 引用,或代码示例(寻找 nodejs,但其他任何语言都会受到欢迎)
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!
推荐答案
这有点(很多)晚了,但可能对其他人有帮助.
this is a little (a lot) late but it might help someone else.
我已经创建了 Lti 1.3 优势协议的 nodejs 实现,这使得设置 lti 提供程序变得非常容易.
I have create a nodejs implementation of the Lti 1.3 advantage protocol that makes it super easy to setup a lti provider.
下面是一个简单的用法示例:
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()
这篇关于为 Moodle 创建 LTI 提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!