Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

How to get courses in a category and any subcategories with courses

$
0
0
by KS Læring.  

Using curl and jq, I can fetch course id and fullname from a category, like this:


curl "https://domain/webservice/rest/server.php?wstoken=token_string_here&wsfunction=core_course_get_courses_by_field&moodlewsrestformat=json&field="category"&value="category_id_here"" | jq -r '.courses[] | "\(.id) \(.fullname)"'

However, I would to include any subcategories below the chosen category_id and get those courses as well, i.e.

-- (starting category) -- any courses in starting category + subcategory1 with its courses + subcategory2 with its courses etc.

Is this possible directly with the APIs in Moodle 3.5.x by changing the command line above?


Viewing all articles
Browse latest Browse all 2361

Trending Articles