cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MyDestinyAdmin
Community Member

Assignments API Call: List Assignments in descending order of creation/due date or most recent

Jump to solution

Hi,

I would like to get a list of assignments sorted by their creation_at or due_date in descending order(most recent assignments). On https://canvas.instructure.com/doc/api/assignments.html#method.assignments_api.index  , I can see an order_by which only accepted position, name, and due_at but doesn't specify an order_direction. Could someone please help me with this?

Thanks in advance! 

Labels (1)
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
jerry_nguyen
Community Participant

@MyDestinyAdmin 

No, you can't change the order. I had a look at the source code of the API endpoint and it's set as latest_due_date order.

You will need to go write a loop to go through the array, here is an example in Javascript (https://stackoverflow.com/questions/10123953/how-to-sort-an-object-array-by-date-property)

Alternatively, you can do it visually through @James 's spreadsheet here https://community.canvaslms.com/t5/Higher-Ed-Canvas-Users/Adjust-All-Assignment-Dates-on-One-Page/ba...

 

 

View solution in original post

3 Replies
MatthewMoreno
Community Member

While you wait for an answer, is it possible to reverse the list yourself?

jerry_nguyen
Community Participant

@MyDestinyAdmin 

No, you can't change the order. I had a look at the source code of the API endpoint and it's set as latest_due_date order.

You will need to go write a loop to go through the array, here is an example in Javascript (https://stackoverflow.com/questions/10123953/how-to-sort-an-object-array-by-date-property)

Alternatively, you can do it visually through @James 's spreadsheet here https://community.canvaslms.com/t5/Higher-Ed-Canvas-Users/Adjust-All-Assignment-Dates-on-One-Page/ba...

 

 

View solution in original post

MyDestinyAdmin
Community Member

Thanks. I would like to sort it through the API as there can be 100s of assignments(potentially) and I would like to only get the 10 most recent. I know it's possible through code but the concern here is the number of API calls then to get all the assignments.