Leading through Chaos - Insights and Actions • Browse the resources from the keynote presented by the Academic Strategy Team.
Hi!
So i have a case where i need to manually create about 100 courses and then add one teacher to each course. So i decided to do it via the REST-API using a python script.
Currently i have made the part of the python script that creates the courses by looping through a csv file and fill in the details needed to create the course. This part works like a charm.
The problem i have is that i now have to find the course again to add the teacher to the course. Adding the teachers after i have found the course shouldn`t be a problem, but i am a little uncertain about how to find the course i just created. Does anyone know a smart way to do this in the script?
- Jan Thomas
Solved! Go to Solution.
Hi @JanTrinborg,
When you make successfully make a POST call to create a course, the API should return a course object, which will include the course id. That course id is what you'd need for the subsequent enrollment call. Personally, I'd have your code create a course, do the teacher enrollment(s), then move to the next line in your CSV and repeat. If you create all the courses first before doing enrollments, you'll need to keep track of all of the course ids, which is doable but probably not ideal.
-Chris
Hi @JanTrinborg,
When you make successfully make a POST call to create a course, the API should return a course object, which will include the course id. That course id is what you'd need for the subsequent enrollment call. Personally, I'd have your code create a course, do the teacher enrollment(s), then move to the next line in your CSV and repeat. If you create all the courses first before doing enrollments, you'll need to keep track of all of the course ids, which is doable but probably not ideal.
-Chris
Hi again!
Thanks for the help! I have now managed to get the course id. But i have now discovered another problem. As i mentioned in the first post i am going to add teachers to the manually created course (In the same loop), but i see that to enroll someone you need their canvas id. Is there possible to enroll someone by using their SIS id? Or do you need to use the Canvas ID? In that case is it an easy way to fetch the Canvas ID by using the SIS ID?
- Jan Thomas
Hi @JanTrinborg,
When doing the enrollment, you should be able to use the sis id by sending in the following format (replace the Z's with whatever the sis_id for the user is):
enrollment[user_id]=sis_user_id:ZZZZZZZZ
-Chris
Hi and thanks again for the answer!
I tried the method you said but didn`t get it to work..
In the part of the script that has to do with the enrollment i send a POST with this type of a request:
Hi @JanTrinborg,
My guess is that the ':' characters in your sis_user_id are throwing off the system. There's a document about encoding/escaping that may be applicable to your situation. Hopefully that helps get you on the right path.
-Chris
Hi!
So i finally figured it out. For some reason the beta environment didn`t have the functionality to add users with SIS ID. I changed my testing over to the test environment and it finally worked. Thanks for the help!
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
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.