Canvas and Mastery are experiencing issues due to an ongoing AWS incident. Follow the status at AWS Health Dashboard and Instructure Status Page
Found this content helpful? Log in or sign up to leave a like!
Hi,
APIs look like they could be incredibly useful for us but the problem is I don't know the coding languages that APIs speak. I'm aware they are powerful and could easily break something. This is why I'm currently just looking at the GET requests and working in the beta environment.
My question is, is it possible in API to:
- Find a new quiz on a course,
- Get all the users who have submitted answers to that Quiz,
- Then generate a list of email addresses for those users?
Do you think that would work? Can anyone help or point me in the right direction please. I've read in the community that Instructure doesn't actively help write the APIs but will point you towards the API documentation. So that's why I'm putting this out to the community.
Thanks
Rich
I don't have any standard resources on coding for API specifically in Canvas, but I have used three sources:
1. Good colleagues who have coded for other APIs
2. The documentation for the requests package in Python: https://docs.python-requests.org/en/latest/user/quickstart/
3. Canvas' own documentation of endpoints: Canvas LMS REST API Documentation (instructure.com)
And if you need a kick-start code example you can have it, of course! But only in Python ...
I've done a lot of my learning with the Canvas API based on trial and error. You begin to understand how to write the calls, then you get a better feel of what you can accomplish (and how complicated you want to make it). I've run API calls in 3 environments: Using Postman (you can download the tool for free), using the Canvas LIVE API site https://yourinstance.instructure.com/doc/api/live (you can use this for test, beta, or live), and using PowerShell with the Invoke-RestMethod cmdlet. I know Python can be used as well, but I haven't worked with it much personally. For any of these methods, you'll need to generate an access token in Canvas from your account settings.
It's easiest to start with single API calls-- when you want to return a piece of information about a single endpoint. Ex- return information about a single course. The Canvas LIVE API gives you an easy way to run these calls and see how they are structured using the "Try it" feature. This will run the call and make any changes if it is a POST, PUT, or DELETE call, so use with caution.
You then can try exploring using a file to run API calls on a list of variables. Ex- return information about each course in a certain subaccount. You'll need to move to another tool such as Postman or PowerShell to accomplish this.
The most complicated would be taking information returned from API call and feeding it into another call, which is the basis of what you'd want to do above.
The general outline of what you need to do is listed below. Use the API documentation find your correct calls, then figure out what tool you feel comfortable using to string these calls together. You will need to use a tool/coding language to accomplish some version of a foreach loop and write to an external file.
1) GET a new quiz (Either by using the quiz ID or finding a list of quiz IDs for a course using a Course ID)
2)GET a list of submissions using the quiz ID(s) from step 1.
3) Foreach submission returned, take the user ID and pass it to a GET user info call
4) Foreach user info call, take the email address and write it to a file.
I hope this helps give you a little more direction.
I did do some testing with the live API, just to make sure I was pulling out some of the right information. Typically it probably is the more complicated thing I want to do.
Thanks for the outline you suggested, that will give me something to work towards. It makes me a bit more hopeful in getting the API calls set up.
Thanks for your help!
I know people hate it when they ask a question and what they get back are more questions, but I'm going to do it anyway.
When you say "new quiz" do you mean "New Quiz" or a new "Classic Quiz"? New Quizzes don't use the Quiz API, they use the assignments API. If you mean new Classic Quiz, then how do you define new? Something needs a starting date to be new.
There's a lot of other details left out in your request that will probably keep someone from providing a total solution. The best anyone could do is respond in generalities.
For example, do you know the name of quiz? If Classic Quizzes, then are you looking for quizzes created after a particular date? Perhaps quizzes taken after a particular date?
With the submissions, you can request submissions either submitted or graded after a date. That can speed things up and reduce the amount of information to download. You can do that without knowing the quiz ID, but it will give you other information that you probably don't want.
There's a dilemma here. If you know the APIs then being specific about what you want can help. If you don't know the API, you're often not specific because you don't know what's available. Worse, you think you have a solution in mind, but it won't work because the API doesn't support that.
One thing to do is think about the process you would go through to do this manually. How do you currently find a new quiz? Then what do you do with it?
Knowing the existing process may help people find better ways to do something.
Sorry, there's more I could write, but class is about to start so I have to stop.
I can see how that could be confusing, yes a New Quiz not a version of a classic quiz. I noticed that New Quizzes seemed to come under the assignment APIs.
You're right, It's tricky to know all the details I need until I understand APIs a bit more. I suppose knowing if it is at all possible is a good start and gives me something to work towards. Thanks for your tip about submission dates, I be sure to include that.
JennyDruckrey posted an outline above, so hopefully I can work something out from there.....or I may have more questions 😂
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in