Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
Hello,
I'm new in canvas LMS and I would like to know if I could use Canvas API to store data from students actions. I tried to use "Store Custom Data" without success. But first, I will explain how I'm working, maybe someone could give me a hand .
In my project, I have a module with a "moodleface-like" page (A page with links to the lessons). All lessons are HTML packages and was imported to this course by canvas import tool (using unzip option).
My course modules:
"CanvasFace":
Each marker is a link in this format:
<a target="_blank" href="<organization>/courses/17/files/2478/download">
<inner html>
</a>
The link refers to a index.html file.
Finally, thats the index of my content:
Everything is working cool, saddly I cant say the same to API commands. I started trying the "Get user profile" and thats throw me an CORS exception. Looking at this forum I found someone suggesting to use "cors-anywhere", so I did it and thats fixed my CORS problem. Now I'm facing a weird problem. Using two differents accounts I figured out the requisition answer was the same for both accounts (same profile was being returned). I didn't found any similar question here.
Further details of my requisitions:
- I have made a token wich one I use in 'Authorization' parameter
- The request url looks similar to that: "https://cors-anywhere.herokuapp.com/https://<organization>/api/v1/users/self/profile"
- I saw in somewhere that self parameter could be used to give the current user ":user_id"
What I'm doing wrong? How can I fix it? Could I use API to store students actions?
Also:
- I'm using Javascript only
- I can't upload my files outside canvas lms
- I read a bit about LTI, can I use that to store custom data? If yes, where can I read more about that?
- Alternatively to API, I could use suspend data of scorm but I dont want to show my content wrapped in scorm player. There is a way to turn off scorm player?
- How can I get user id (or just using self parameter works fine)?
https://canvas.instructure.com/doc/api/users.html#method.profile.settings
Please help! :smileygrin:
PS: I could not send that question to dev forum...
Hello, @renanpinhoassi Welcome to the Canvas Community! We've moved this question to the Canvas Developers space on your behalf. To participate in this conversation or to post new questions to that group, please navigate to the group home page and select Join Group from the Actions dropdown that displays at the top right of the page.
Thanks stefaniesanders
Hi @renanpinhoassi ,
Authorization tokens are user-based. Any program you write using your token will always execute actions and API calls as you.
To allow other users to execute programs you write as themselves, you'll need to implement OAuth to allow them to authorize the application for themselves: OAuth2 - Canvas LMS REST API Documentation
There are several Oauth libraries avialble for Javascript: https://oauth.net/code/javascript/
LTI might also be an option, and would get around the user authorization piece because it embeds the user context, but it could potentially add a heavy processing burden to the client browser, depending on how many plugins you find yourself loading. There's some good LTI and JavaScript here: https://medium.com/lcom-techblog/simple-lti-tool-consumer-in-html-and-javascript-72ca153d7a83
Best,
--j
Thanks @Jay Savage,
Authorization tokens are user-based. Any program you write using your token will always execute actions and API calls as you.
Day after my post I realized what I was doing. I was using a manually generated access token, who could help for test porpuses. Also I realized what I really want to do, generate automatically access tokens to users. I read about Auth and then I tried to implement that. I generated a Dev Key for my API in my admin panel (using the "API Key" option) and so, for test porpuses, I used my key number in "/login/oauth2/auth" method as "client_id" parameter (I can't remember where, but I have read the "client_id" is the short number displayed). Unfortunately, it still not working, at least I'm getting a 401 code (unauthorized). I'll try to contact someone who manages my client structure and see if someone could help me on that. Also, this is my "code", not the final version, I'm just trying to connect the stuffs. If you find something wrong in that, please, call me:
"Executed on my index.html"
There are several Oauth libraries avialble for Javascript: https://oauth.net/code/javascript
I will take a look soon, but I can't do that by myself?
LTI might also be an option, and would get around the user authorization piece because it embeds the user context, but it could potentially add a heavy processing burden to the client browser, depending on how many plugins you find yourself loading. There's some good LTI and JavaScript here: https://medium.com/lcom-techblog/simple-lti-tool-consumer-in-html-and-javascript-72ca153d7a83
Cool, I really know nothing about LTI, so I will take a look on that too. I'm just worried if my content have to be embedded in a Iframe, but I hope I find the answers!
I'll post here when/if I solve my problems.
Thanks for now.
To participate in the Instructure Community, you need to sign up or log in:
Sign In