Administrator account can't see some groups created by script

Administrator account can't see some groups created by script

by Albert R. -
Number of replies: 1

Let me preface by saying that now I realize that the way I created these groups is incorrect and I'm working on solving that, using the Moodle API instead. However, I have a problem with the already created groups that are already being used so I would like to "fix" this in the meantime.

Problem: the administrator account can't see the groups created by my own script, but can see the groups created from within Moodle.

Reason: I created these groups (the ones that the admin can't see) with a script that adds records directly to the mdl_groups table and adds students to those groups by adding records to mdl_group_members table (again, I know this isn't the correct way to go about this).

If I add a user with a teacher role to any of those groups, that user can actually see the groups in Moodle with no problem (in the gradebook, reports, etc). However, the admin account can't see them.

So my question: is there any other record in the database that I need to add or modify so the admin can actually see those groups?  I've been looking everywhere and I can't find any other table where groupid is used, but there must be something somewhere since these groups aren't showing for the admin. I've also looked into the groups_create_group() function in the Moodle source code but I can't figure this out.

Any help with this would be MUCH appreciated since would allow me to fix the already created groups. From now on I will be using the API to create them so I figure this problem won't happen.


Average of ratings: -
In reply to Albert R.

Re: Administrator account can't see some groups created by script

by Albert R. -

I will need to add something that maybe helps figure out what's going on: 

I've created a script that uses the API to create a group. That works fine now (yay I'm doing it the right way). The weird thing is that after creating a group in a course via this method, now all the groups that the admin couldn't see before are showing up. It's like creating a group "the right way" somehow "enabled" all the groups that were created in the wrong way.

I've double-tested this with a second group in a second course that had the same issue, checking right before if I could see the groups with the admin account (I couldn't), then creating a new group in that course via the API, then checking again and then those groups became visible. Very weird!

I would still like to understand what's going on if at all possible, I'm sure there has to be some sort of explanation.