Non-editing teacher is unable to get group members programmatically

Non-editing teacher is unable to get group members programmatically

by Nils Kattenbeck -
Number of replies: 0

This issue is primarily about webservices. The root problem however still exists in the API and seems confusing.

We have some non-editing teachers who use webservices to grade submissions faster. However for group submissions there seems to be no way to save a grade without knowing a userid from a group member.

Current workflow for non-group assignments (scripted):

  1. Manually get course id
  2. Get all assignments using "mod_assign_get_assignments"
  3. Select the correct assignment to get the assignment id
  4. Get all submissions using "mod_assign_get_submissions"
  5. Some tests are executed on the submission and a grade is determined
  6. The grade is saved using "mod_assign_save_grade" and the "userid" corresponding to the submission

However this fails for group assignments. The save_grade function expects a userid which for group submissions is set to 0. If access to a single userid was possible everything would work.

Sadly "core_group_get_group_members" is not available in the default moodle service. Adding a new service with the required service would work however for some reason the "moodle/course:managegroups" capability is required. This is a capability which non-editing teachers do not have and we do not want to grant this capability. Confusingly non-editing teachers are able to view user groups without problems in the enrolled users overview.


Is there maybe another function I missed from where user <-> group mappings can be extrapolated?

Moodle Version is 3.9.x

Average of ratings: -