Comments (6)
The HTTP 500 server error was an issue of the ltijs library:
Cvmcosta/ltijs#193
from lti-1.3-canvas-lms.
Hi @Liziqiuqiu,
the error occurs when there is probably something wrong with your configuration.
Have you seen this issue?
If not, you can try the solutions I suggested in this issue.
Specifically, you could check whether the url
parameters match. This should be the same as in the ISS value in the config/security.yml file, so it depends on the config form the Canvas Instance.
from lti-1.3-canvas-lms.
Hi Simon,
Thank you so much for the suggestion. I updated the URI to 'https://canvas.test.instructure.com/' (for a Instructure-hosted test server), and it works. Your assistance is greatly appreciated.
By the way, I have also encountered another issue. The '/grade' and '/members' endpoints do not work. The code remains the same as in your repo.
I chose the LTI 1.3 advantage services when I registered the developer key and then examined the idtoken.platformContext. I found that I have the necessary scope, 'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem'. However, the const response = await lti.Grade.getLineItems(idtoken, { resourceLinkId: true })
and const lineItem = await lti.Grade.createLineItem(idtoken, newLineItem)
calls failed.
Have you encountered similar situations before, or could you please provide some guidance for troubleshooting?
error:
POST /grade 500 Internal Server Error
GET /members 500 Internal Server Error
the platformContext.endpoint info
endpoint: {
scope: [
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem',
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem.readonly',
'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly',
'https://purl.imsglobal.org/spec/lti-ags/scope/score',
'https://canvas.instructure.com/lti-ags/progress/scope/show'
],
Code of the routes.js
const router = require('express').Router()
const path = require('path')
// Requiring Ltijs
const lti = require('ltijs').Provider
// Grading route
router.post('/grade', async (req, res) => {
try {
const idtoken = res.locals.token // IdToken
const score = req.body.grade // User numeric score sent in the body
console.log(idtoken.platformContext)
// Creating Grade object
const gradeObj = {
userId: idtoken.user,
scoreGiven: score,
scoreMaximum: 100,
activityProgress: 'Completed',
gradingProgress: 'FullyGraded'
}
// Selecting linetItem ID
let lineItemId = idtoken.platformContext.endpoint.lineitem // Attempting to retrieve it from idtoken
if (!lineItemId) {
console.log("inside if");
const response = await lti.Grade.getLineItems(idtoken, { resourceLinkId: true })
// console.log(response);
const lineItems = response.lineItems
if (lineItems.length === 0) {
// Creating line item if there is none
console.log('Creating new line item')
const newLineItem = {
scoreMaximum: 100,
label: 'Grade',
tag: 'grade',
resourceLinkId: idtoken.platformContext.resource.id,
}
console.log("lineItem");
const lineItem = await lti.Grade.createLineItem(idtoken, newLineItem)
console.log(lineItem);
// const lineItem = await lti.Grade.createLineItem(idtoken, newLineItem)
console.log("after creting lineItem");
lineItemId = lineItem.id
} else lineItemId = lineItems[0].id
}
console.log("before sending grade");
// Sending Grade
const responseGrade = await lti.Grade.submitScore(idtoken, lineItemId, gradeObj)
return res.send(responseGrade)
} catch (err) {
console.log(err.message)
return res.status(500).send({ err: err.message })
}
})
// Names and Roles route
router.get('/members', async (req, res) => {
try {
const result = await lti.NamesAndRoles.getMembers(res.locals.token)
if (result) return res.send(result.members)
return res.sendStatus(500)
} catch (err) {
console.log(err.message)
return res.status(500).send(err.message)
}
})
// Deep linking route
router.post('/deeplink', async (req, res) => {
try {
const resource = req.body
const items = {
type: 'ltiResourceLink',
title: 'Ltijs Demo',
custom: {
name: resource.name,
value: resource.value
}
}
const form = await lti.DeepLinking.createDeepLinkingForm(res.locals.token, items, { message: 'Successfully Registered' })
if (form) return res.send(form)
return res.sendStatus(500)
} catch (err) {
console.log(err.message)
return res.status(500).send(err.message)
}
})
// Return available deep linking resources
router.get('/resources', async (req, res) => {
const resources = [
{
name: 'Resource1',
value: 'value1'
},
{
name: 'Resource2',
value: 'value2'
},
{
name: 'Resource3',
value: 'value3'
}
]
return res.send(resources)
})
// Get user and context information
router.get('/info', async (req, res) => {
const token = res.locals.token
const context = res.locals.context
const info = {}
if (token.userInfo) {
if (token.userInfo.name) info.name = token.userInfo.name
if (token.userInfo.email) info.email = token.userInfo.email
}
if (context.roles) info.roles = context.roles
if (context.context) info.context = context.context
return res.send(info)
})
// Wildcard route to deal with redirecting to React routes
router.get('*', (req, res) => res.sendFile(path.join(__dirname, '../public/index.html')))
module.exports = router
from lti-1.3-canvas-lms.
@Liziqiuqiu thanks for the hint,
Yes, since this example application is based on ltijs you would have to follow the issue you linked.
I will close the issue.
If you have any other questions, you can create a new issue.
from lti-1.3-canvas-lms.
Hi Simon,
This is not an issue, but rather a question I've come across. However, I'm unsure where to seek help. I will remove this if it's not the appropriate place to post this question.
In the readme document, the second step is to set up a Canvas instance. I've followed the Production Start tutorial and can access the instance. However, I'm unable to locate the login page; I don't know how to login into the system; all I can find is the public directory shown below. Could you please provide some guidance?
Thank you so much!!!
Have a wonderful Christmas season ahead!
from lti-1.3-canvas-lms.
Hi @Liziqiuqiu,
Based on your question, I have created a new issue for a better overview.
We can discuss your question further there.
from lti-1.3-canvas-lms.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lti-1.3-canvas-lms.