Create two courses, A and B
Manually enrol 2 users (Bob and John) as students on both courses
Manually enrol 2 users (Eve and Kate) as teachers on both courses
Add a course meta link to course B on course A, so that the users have 2 enrolments on course A
Create a group in course A and go to the add users screen
Make sure none of the users appear under "Multiple roles"
Make sure John and Bob are listed under "Student"
Make sure Kate and Eve are listed under "Teacher"

Description

When viewing the Add/remove users to a group page, there are two lists:
-Group members
-Potential members

In both lists, users appear under two headings: 'Student' and 'Multiple roles'. This is despite the fact that none of the users have multiple roles, i.e. they all have the role of student in the course (and entire system) and no other roles.

Note, this seems to only happen in courses that have 'Course meta link' as an enrollment method. Users appearing under the heading of 'Student' are members of no or one group. Users appearing under Multiple roles are members of multiple groups, although some are in no groups, but perhaps in multiple courses.

It seems that the term 'role' is being confused with group or course membership.

To replicate this issue:

Create two courses, A and B, with a user enrolled manually as student on both

Add a course meta link to course B on course A, so that the user has 2 enrolments on course A as a student

Michael Aherne
added a comment - 17/Oct/12 6:47 PM - edited This does seem to be happening in both 2.3 stable and master. I haven't worked out how to reproduce the data that's causing it yet, though.
In any case, the attached patch seems to fix it.
I'm not convinced that in_array is the most performance-friendly way to do it, but I'm not noticing any deterioration. Can anyone comment on whether this is a sensible patch?

Hi Fred, thanks for the feedback. I've worked out how to replicate this and added some instructions.

I think I've worked out what might be happening. It seems that enrolment plugins where roles_protected returns true get their own entry in role_assignments, regardless of whether the same role has already been assigned on the course by another plugin. On the other hand, plugins where the roles are unprotected effectively share a single role_assignment entry. This problem only manifests itself where multiple plugins have assigned the same role and at least one of them returns true for roles_protected.

I'll look at updating the patch to use your suggestion instead of in_array - it does look much better!

Michael Aherne
added a comment - 11/Jan/13 10:22 AM Hi Fred, thanks for the feedback. I've worked out how to replicate this and added some instructions.
I think I've worked out what might be happening. It seems that enrolment plugins where roles_protected returns true get their own entry in role_assignments, regardless of whether the same role has already been assigned on the course by another plugin. On the other hand, plugins where the roles are unprotected effectively share a single role_assignment entry. This problem only manifests itself where multiple plugins have assigned the same role and at least one of them returns true for roles_protected.
I'll look at updating the patch to use your suggestion instead of in_array - it does look much better!
Cheers, Michael.

Thanks for the patch Michael. I have added some testing instructions based on your replication tests, usually you would have been asked to do it, but as it was fairly straight forward I've added them to push this issue for integration.

Frédéric Massart
added a comment - 14/Jan/13 2:40 AM Thanks for the patch Michael. I have added some testing instructions based on your replication tests, usually you would have been asked to do it, but as it was fairly straight forward I've added them to push this issue for integration.
Big thanks,
Fred

The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

Dan Poltawski
added a comment - 18/Jan/13 7:24 AM The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.
TIA and ciao