Replies: 1 comment
-
It takes a long time because each assignment has to check for 30 students, who may have multiple submissions. So, your loop right now is doing the equivalent of 380 * 30, which is 11,400 API calls at minimum. It also depends on what you're doing with the submission data. Is your script processing the submission objet at all? Or are you just writing information to a CSV or database? With each submission, are you using some of those methods to get specific data like comments, media, etc? Here are a couple things you can try to speed it up a little bit in order from least complex to more. Process submissions laterIf you're doing work with each submission, it might be faster to just download everything into a sheet or SQLite database and then process it for whatever you're looking for. Use this script as a pipeline to get data from Canvas to your machine. Get all submissions at the course levelYou have the option of getting all submissions at the course level without looping through assignments. The Canvas documentation lists params you can use to filter results to active students or submissions following a given date. Be sure to pass the # Set up your Canvas object...
submissions = course.get_multiple_submissions(student_ids='all') # Returns a paginated list
for submission in submissions:
# Do stuff here... Use
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a Canvas course with 30 students, but there are 380 assignments.
I am using your canvasapi to get the submissions of each assignment multiple times a day (students can add new submissions throughout the semester)
First I have a list of all assignments
assignments = course.get_assignments()
then multiple times a day I do the following
The second loop takes a long time time to complete. Setting per_page = 100 in get_submission() isn't improving things, but I don't understand enough of how things work to be able to say why it should. Just a "what have I tried so far" comment.
Is there a quicker way to collect the submission data for all students in all assignments?
Beta Was this translation helpful? Give feedback.
All reactions