cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Surveyor

How to get assignment due dates?

Jump to solution

I'm a bit new to using canvasapi and I haven't found anything that will let me get the due date of an assignment. I'm a student and wanted to be able to get all my assignments to print ordered by due date. So far, I have been able to fetch and print out assignments, but all I can do is print every single assignment from my courses in order of when they were assigned. How can I get the assignments' due dates and possibly also whether I've already made submissions or not to order them with the most relevant assignments first?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Navigator

@tg1802 

It sounds like you're wanting the information from the assignments page, but returned through the API.

Canvas uses the Assignment Groups API call to fetch the data on the Assignments page.

GET /api/v1/courses/:course_id/assignment_groups?
exclude_response_fields[]=description
exclude_response_fields[]=rubric
include[]=assignments
include[]=discussion_topic
override_assignment_dates=true
per_page=50

That does not include any submission data, though. To see if you have already submitted the assignment, you would need to use the Submissions API.

GET /api/v1/courses/:course_id/students/submissions?
per_page=50

In both cases, you will need to use pagination if there are more than 50 items. You can increase the 50 to 100, but it will take a little longer to fetch if you have a lot of assignments.

Also note that I've split the query parameters to multiple lines to make it easier to read and that there are ampersands & before each of the query parameters except for the first one.

View solution in original post

4 Replies
Highlighted
Navigator

@tg1802 

It sounds like you're wanting the information from the assignments page, but returned through the API.

Canvas uses the Assignment Groups API call to fetch the data on the Assignments page.

GET /api/v1/courses/:course_id/assignment_groups?
exclude_response_fields[]=description
exclude_response_fields[]=rubric
include[]=assignments
include[]=discussion_topic
override_assignment_dates=true
per_page=50

That does not include any submission data, though. To see if you have already submitted the assignment, you would need to use the Submissions API.

GET /api/v1/courses/:course_id/students/submissions?
per_page=50

In both cases, you will need to use pagination if there are more than 50 items. You can increase the 50 to 100, but it will take a little longer to fetch if you have a lot of assignments.

Also note that I've split the query parameters to multiple lines to make it easier to read and that there are ampersands & before each of the query parameters except for the first one.

View solution in original post

Highlighted
Surveyor

Thanks! So I got it to return a list of the assignment groups for all my classes, and I put in "assignments" and "all_dates" for input parameters. How do I actually access the lists of due dates for each assignment group?

0 Kudos
Highlighted

You don't have due dates for each assignment group, you have due dates for each assignment.

The object returned is an array, with one element for each assignment group. Iterate through this array.

Within each assignment group, there is an assignments object that is another array, with one element for each assignment. Iterate through this array.

Within each assignment, you can pull out the dates.

Is there a reason you put all_dates ? I'm fairly sure the list comes tailored to the person making the call if you don't put in the all_dates. That is, the date that it is actually due for the person making the call. If you don't use the all_dates, then look at the due_at, unlock_at, and lock_at dates that are explained in the AssignmentDate object.

0 Kudos
Highlighted

Ok, I realized that the canvasapi python wrapper that I've been using returns the assignments within its own object that doesn't let me get the due dates, so I just rewrote it to use purely api calls with the requests module. Thanks for all your help! I think I can get it to work now.

Top Kudoed Authors
Labels