core_course_get_courses just course id and shortname

Re: core_course_get_courses just course id and shortname

by Michael Chan -
Number of replies: 1

I'm not sure the solution mentioned by Edwin would work for some.  There is an issue described in this thread regarding the core_course_get_courses method: https://moodle.org/mod/forum/discuss.php?d=362784

It would be ideal if there was an additional filter like "category id" for the core_course_get_courses method to prevent the web service call from timing/erroring out.  However, it does not look like there has been any work for this issue.

In reply to Michael Chan

Re: core_course_get_courses just course id and shortname

by Michael Chan -

I've since realized there is the core_course_get_courses_by_field method that was introduced in version 3.2.  Here is the syntax to filter by a category value, but you can also filter by id, course id, short name or category:

https://MOODLEURL/webservice/rest/server.php?wstoken=TOKENVALUE&wsfunction=core_course_get_courses_by_field&field=category&value=[###]&moodlewsrestformat=json

Please ensure the new API method is added as a function to the webservice token so you have the proper access.

Average of ratings: Useful (1)