course context id

course context id

by Jason Lea -
Number of replies: 2
Does a course have a unique contextid?

if so is it easy locate?

help would be apprecaited
Average of ratings: -
In reply to Jason Lea

Re: course context id

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes. There is a unique context for each course, activity, block, course category and user.

You can find them in the mdl_context table. There, the contextlevel tells you what type of context it is. So, for example, 50 = course and 70 = activity. (The full list of types is defined at the top of lib/accesslib.php.)

Then, depending on the type of context, the instanceid column links to the appropriate database table. So, if contextlevel = 50, then instanceid matches an id from the mdl_course table. And for contextlevel = 70, instanceid refers to mdl_course_modules.id.
In reply to Tim Hunt

Re: course context id

by John Wyatt -

My Dog 'Named booley' is not here right now and he is the boolean expert.

I see where contextlevel of '50' is for a course but what does the corresponding number '160' mean in my mdl_role_assignments table.

John Wyatt