Enable/Disable by API - Course Setting - content download

Jump to solution
eric_hybner
Community Explorer

I sincerely hope I will need to apologize for wasting your time with an easy question resolved by reading the right friendly manual.

I have not been successful in finding any API (REST nor GraphQL) access to the "Allow course content to be downloaded and viewed offline" course setting.

In fact, I am not finding most course settings in the GraphQL API.

1) Are all settings top-level children of a course, and if not listed there, not yet implemented, or is there a sub-collection I am missing?

2) Is there API access to the aforementioned course setting (which also does not have any lock option at the account/sub-account level)?

Thank you!

Labels (2)
0 Likes
1 Solution
James
Community Champion

@eric_hybner 

The full list of recognized course settings  is found in the source code. From the API documentation, you can click on the name of the controller (small and gray to the right of the heading). Often it doesn't provide definitive results, but this time I was able to find it in the same file.

Normally, I would just watch the network traffic like @chriscas suggested, but we don't have that option turned on, so I wasn't able to take that route.

That said, it looks like there is no course prefix required when using the Update course settings endpoint. So it would just be enable_offline_web_export rather than course[enable_offline_web_export].

The call through the web interface is not always to an API and so the parameters may differ. Normally they are the same. My expectation here is that the Course Settings page in Canvas has more than just course settings on it, so it was necessary to include the course prefix. When making the API call, the course settings is all that endpoint does so the prefix is not necessary.

I cannot test this since we don't support offline export, but it may look something like this.

PUT <instance>/api/v1/courses/:course_id/settings?enable_offline_web_export=1

I would use JSON instead

{
  "enable_offline_web_export": true
}

 

As for GraphQL, it was a great idea that was never fully flushed out. With some new development (new Quizzes), Canvas has even reverted back to the REST API after saying they would use GraphQL.

There are some things that are REST only, some that are GraphQL only, and some that are both. There are even some settings that are neither and have to be made through the web interface.

View solution in original post