How to assign global user roles with external database enrolment plugin.

How to assign global user roles with external database enrolment plugin.

by Raúl González Álvarez -
Number of replies: 1

Hello, this is Raul.

I have set up the external database enrolment plugin and all the enrolments are being syncronized correctly except the enrolments targeted to the  top level of the moodle(courseId=1).

When I run the "php sync.php"  through the command line it launchs an exception relative to the external enrolments in the courseId=1.

 

How could i assign global user roles using an enrolment plugin?

Regards and many thanks,

Raul

 

Average of ratings: -
In reply to Raúl González Álvarez

Re: How to assign global user roles with external database enrolment plugin.

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Raul,

the thing is... you don't assign global roles using an enrolment plugin. You use an authentication plugin instead.

Even if enrolment was performed using roles in Moodle from 1.7.x to 1.9.x, they were conceptually two different things. From Moodle 2.0.x on, they are actually two different things implementationwise (albeit related).

Enrolment only makes sense for (normal) courses, while you can assign roles pretty much everywhere. But the site course is special in this regard. It's not a normal course, in that you don't have sections, can't place activities (other than a 'section 0' forum), doesn't have a grade book, etc. And enrolment is mainly about that: being able to carry activities out and being graded. That's why the enrolment code treats the site course in a that special way.

On the other hand, if you want some users to have special roles in the whole site, that's ok as far as Moodle concerns. But you do so by assigning those roles in the site course, not by enrolling them in the site course. And as I said before, you can do that using an authentication plugin. Right now the only two auth plugins that can assign roles are FirstClass and LDAP. They currently only assign the course creator role, but they could be extented to assign any role (in fact, MDL-30634 proposes an enhancement for LDAP to do so)

Saludos.
Iñaki.