Get roles Webservice API

Re: Get roles Webservice API

by Andreas Grabs -
Number of replies: 2
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

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

In reply to Andreas Grabs

Re: Get roles Webservice API

by Thomas Schröder -

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


In reply to Thomas Schröder

Re: Get roles Webservice API

by Declan Lawton -

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.