moodle 3.8+ role_assignments table

moodle 3.8+ role_assignments table

by Chamika Ranasinghe -
Number of replies: 6

Dear All ,

I need to know how come "contextid "field in "role_assignments" table . Any relative tables with this column ??

Please help on me. what im trying to do is ,  need to assign roles of student those who having "No roles " to "Student" role.  ( see attachment1) Attachment1

Average of ratings: -
In reply to Chamika Ranasinghe

Re: moodle 3.8+ role_assignments table

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The query All users enrolled in a course without a role gives you users having "No roles". You should be able to work out how to make any changes directly within the database from this query.

However depending on your needs it's probably better to use a function call, possibly role_assign(). This will ensure appropriate events are triggered within Moodle as there may be internal code or third party plugin code that needs to respond to the changes.

In reply to Leon Stringer

Re: moodle 3.8+ role_assignments table

by Chamika Ranasinghe -
Dear Sir,

The role_assign() function also asking contextid which is not known how it generate . anyway you gave me good reference pages about moodle .thank you
In reply to Chamika Ranasinghe

Re: moodle 3.8+ role_assignments table

by Chamika Ranasinghe -
Dear Leon,

yes ... thanking you for sharing resources i find out where contextid came using that .
Thanks
In reply to Chamika Ranasinghe

Re: moodle 3.8+ role_assignments table

by Acqua Alta -
Picture of Particularly helpful Moodlers

Hi,

Maybe I didn't understand you question, but if you are looking for a way to filter the view of the participants list so you would only see participants with "No roles" status in the "Roles" column, please note that in Moodle 3.8 there is a new filter called "Roles: No roles":


Of course this filter won't automatically change all your records to the requested role ("Student"), but at least it's half the way.

You can get more technical details about this filter and how it was added, here:
MDL-66178 ("Participants list - Filter users with no roles")


In reply to Acqua Alta

Re: moodle 3.8+ role_assignments table

by Chamika Ranasinghe -

Dear Acqua,

There is a table call role_assignments . anyway i manage my situation .thank you 


In reply to Chamika Ranasinghe

Re: moodle 3.8+ role_assignments table

by Acqua Alta -
Picture of Particularly helpful Moodlers
By your answer it seems that you were interested in changing the roles of the users directly in the DB.
OK smile