Sort module items inside a module

Jump to solution
nschutz
Community Contributor

Does anyone know how to sort module items alphabetically via API calls? We we have some old courses that group the module items by types within a module. For example, all the pages, then all the assignments, then all the discussions. Since we need to apply prerequisites to all these module  items, we need to first have them sorted in the right order (they all start with a number like 1.05) before we apply prerequisite requirements.

1 Solution
pklove
Community Champion

There isn't a simple re-order alphabetically call, but you could do it by calling "List module items" (/api/v1/courses/:course_id/modules/:module_id/items), work out the order from the returned item information, and then update the order using module_item[position] in the "Update a module item" endpoint (/api/v1/courses/:course_id/modules/:module_id/items/:id).

If you have a programmer its quite straightforward.

View solution in original post