1

I have an application where I need to fetch records from Moodle using the core Web Service API.

I am receiving courses and categories with the following API calls:

core_course_get_courses
core_course_get_categories

But I am not able to find the right parameter (or maybe my implementation was wrong) for

mod_assign_get_assignments

I tried as below

http://moodle/webservice/rest/server.php?wsfunction=mod_assign_get_assignments&moodlewsrestformat=json&wstoken=token&courseids[0]=27

Can anyone have any idea how I can get assignments from a course?

Please help

wp78de
  • 18,207
  • 7
  • 43
  • 71
TechNo
  • 615
  • 2
  • 7
  • 24

2 Answers2

0

Following method used to fetch records under a course in Moodle

http://moodle/webservice/rest/server.php?wsfunction=mod_assign_get_assignments&moodlewsrestformat=json&wsfunction=core_course_get_contents&moodlewsrestformat=json&courseid=
TechNo
  • 615
  • 2
  • 7
  • 24
  • 2
    This only works if the WebService user is enrolled tothat specific course , otherwise it returns {"courses":[],"warnings":[{"item":"course","itemid":3,"warningcode":"2","message":"User is not enrolled or does not have requested capability"}]} – Tim Dams May 18 '17 at 20:30
  • Thanks a lot! That's exactly I was looking for :D – amalik2205 Nov 04 '19 at 16:33
0

Your command is not working mostly because your web services user is not enrolled in the course. Go to course settings and enroll the user.

This works for me:

https://your.moodlesite.com/webservice/rest/server.php?wsfunction=mod_assign_get_assignments&wstoken=5a67fb5d660a987a5705a4b47c0ad1fa&moodlewsrestformat=json&courseids[0]=3

The last parameter 'courseids' is not necessary.

amalik2205
  • 3,962
  • 1
  • 15
  • 21