Best way to establish current role for a user

Best way to establish current role for a user

by Mike Wilson -
Number of replies: 2

Hi,

I'm working on a new assessment course format which will display information to staff and students on assignment progress (how many submission have been made, how many assignments have been graded etc).

Could someone point me in the direction of the correct way to establish the current users role on a course please.

I've read through the API docs and can't seem to find it.

Thanks for any help,

Mike

Average of ratings: -
In reply to Mike Wilson

Re: Best way to establish current role for a user

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There is a reason why there isn't any documentation on this - it is usually the wrong question to ask. Instead of 'is this a student', you should be asking 'can this user submit assignments' (if so, display information about their submissions). Instead of 'is this a teacher', you should ask 'can this user grade assignments' (if so, display information about all user's submissions.

That way, it will work with custom roles that grant the same capabilities, but which have different names to the standard roles (and could even cope with roles assigned to particular activities, or with overridden capabilities for certain activities).

Average of ratings: Useful (2)