I'm glad my explanation helped. Regarding your further questions, I'm really not entirely certain. I've looked over things a bit, but haven't figured out exactly what you want. The code I can find that seems most useful is here:
But that's having to do with reports, not raw context. And asking how to use the object from mdl_context, I'm really not sure - in what manner are you trying to use it?
Roles and permissions
Can't administrate roles and context
This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.