Hello everyone,
I wanted to know if it was possible to get the roles of a user via the webservice. I haven’t found any endpoints to do that, and the only answers told me to go through the database, but I don’t have access to it.
Is there a way to do that?
Thank you and have a nice day !
Get roles Webservice API
Number of replies: 5Re: Get roles Webservice API
Hi Venel,
in my opinion there is no such webservice. What do you want to achieve? Maybe there is another way to do that.
Best regards
Andreas
Re: Get roles Webservice API
I don’t know if there’s any other way to do that.
Thanks again for your time.
Re: Get roles Webservice API
Hi Venel,
I am sorry, but you still keep saying the same things like in the german forum. As I said, there is no webservice to get the roles of a user. But if you'd tell us what do you want to do, maybe there is an alternative way to achieve your goal.
If you want to get all users from course for example you maybe can use the webservice function: "core_enrol_get_enrolled_users_with_capability". By naming the capability you could differ between students and teachers.
The problem with roles is that they can be changed without to inform the external system. Capabilities for example always are the same.
Best regards
Andreas
Re: Get roles Webservice API
Hello everyone,
We have users (teachers and students) stored in an ldap tree. We wrote a Flask/Python-tool to synchronize our users cohorts and courses (to moodle and nextcloud simultaneously).
When users are logging in manually they automatically get a role (student). When teachers are logging in, they get the role editingteacher by their ldap group.
The tool will create all users so that we can enrol them to their courses before the term starts. I can see all roles with names and shortnames in https://m.corvi.schule/admin/roles/manage.php and within the database.
But when enroling a user to a course, I need to know the role id (int). And I see no way so far to get this role id using the rest api(e.g. from role shortname).
Any hint/idea? Or maybe another approach to what we would like to accomplish?
So far we are creating a dummy course "role template" with administrator in it. Then we can get the roles from there. But this has to be done manually - so another solution would help us a lot.
Thanks
Thomas
Re: Get roles Webservice API
Hi,
According to me, you must reach out to some known web developers for a perfect solution to your web service query. Recently I get in touch with one of the development experts from India and they help me swiftly through a couple of my projects. It is always better to have someone who has a better knowledge of the queries you are facing. You can reach out to them at https://www.moweb.com/
DM me if you are looking for any details.
Thank you,
Declan Lawton.