How to get all assignments for a course.

How to get all assignments for a course.

by George Dorn -
Number of replies: 3

I'm working on a REST client to do some student analytics.  I can get a list of all of the courses via core_course_get_courses, and I can get a list of all of the users in each course via core_enrol_get_enrolled_users.  However, the next step, getting all of the assignments in a course, seems to be done via mod_assign_get_assignments, but this function appears to be extremely limited and intended for students and teachers only.

For example, here's the results I get with various combinations of parameters:

wsfunction=mod_assign_get_assignments&courseids[]=1

Yields error message "User is not enrolled or does not have requested capability".  This is technically correct; the admin user the token is assigned to isn't enrolled.

wsfunction=mod_assign_get_assignments&courseids[]=1&capabilities[]=moodle/grade:edit

Yields the same error message.  This one is confusing, because the documentation suggests that specifying capabilities might override the user, but in any case the admin user has all capabilities and so should be able to get assignments this way.

 

I'm guessing mod_assign_get_assignments just isn't the right tool for the job, but does another tool exist?  It must be available through a web service (as this is to be fully automated) and it has to have all assignments, not just those belonging to the user with the API key specified.

 

 

 

 

wsfunction=mod_assign_get_assignments&courseids[]=1&capabilities[]=moodle/grade:edit

Average of ratings: Useful (3)
In reply to George Dorn

Re: How to get all assignments for a course.

by Alessandro Forghieri -

Having the same problem - did you ever find a solution?

Thanks

In reply to Alessandro Forghieri

Re: How to get all assignments for a course.

by Gennady Kolomoets -

And again.

If Web Service user is enrolled to some course the mod_assign_get_assignments returns data, otherwise it returns {"courses":[],"warnings":[{"item":"course","itemid":3,"warningcode":"2","message":"User is not enrolled or does not have requested capability"}]}

To enroll the Web Service user to all courses is inconsistent. So is there a solution to resolve the problem?

Thanks

In reply to George Dorn

Re: How to get all assignments for a course.

by Ryan VanAlstine -

Has anyone found a solution for this yet?  I'm running into the same issue.