Grant ability to Switch Role without granting ability to Assign Role

Grant ability to Switch Role without granting ability to Assign Role

by Clint Lalonde -
Number of replies: 5
We want our Teachers to be able to switch their view to a student view using Switch Roles, but we do not want them to be able to Assign users into that student role. It seems to me that the 2 functions are connected - you can't give someone the ability to Switch to a different role unless you give them the ability to also assign that role to a user. Is this correct, or is there a way to give someone the ability to switch roles without giving them the ability to assign that role?

We're using ver 1.8.


Average of ratings: -
In reply to Clint Lalonde

Re: Grant ability to Switch Role without granting ability to Assign Role

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Yes, you're right. As said in the doc, you can't switch to roles you can't assign.

I would also, like you, be interested to allow some roles to switch roles, but not assign them...
In reply to Séverin Terrier

Re: Grant ability to Switch Role without granting ability to Assign Role

by Clint Lalonde -
Thanks for the reply Severin.
In reply to Séverin Terrier

Re: Grant ability to Switch Role without granting ability to Assign Role

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You might hope that if you turned off the Assign roles to users (moodle/role:assign) capability from teachers, but left them with the Switch to other roles (moodle/role:switchroles) capability, then it would work as you want, but it doesn't. I wonder why?

Well that is what the documentation says anyway. It might be worth testing to see if it is true.
In reply to Tim Hunt

Re: Grant ability to Switch Role without granting ability to Assign Role

by Clint Lalonde -
Thanks for responding, Tim. I've tested this and the documented behaviour is correct. Seems that you can't give the ability to switch roles without also giving the ability to assign that role.


In reply to Tim Hunt

Re: Grant ability to Switch Role without granting ability to Assign Role

by Brett Hinton -
The answer I think lies in this bug report in the tracker:

http://tracker.moodle.org/browse/MDL-11313

It seems that the switch role function is not tied only to the switch role capability, but also the assign role capability. Without both of them the ability to switch roles doesn't function.