Whats the significance of Conext table and contextlevel.

Whats the significance of Conext table and contextlevel.

by Hardik Akbari -
Number of replies: 3
Hi to all
i was recently trying to fetch list of courses for a user.
and found that query users context table.
also query has contextlevel=50

here is the query.
"SELECT c.id, c.category, c.sortorder, c.shortname, c.fullname, c.idnumber, c.teacher, c.teachers, c.student, c.students, c.guest, c.startdate, c.visible, c.newsitems, c.cost, c.enrol, c.groupmode, c.groupmodeforce, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, cc.path AS categorypath
FROM mdl_course c
JOIN mdl_course_categories cc ON c.category = cc.id
JOIN mdl_context ctx ON ( c.id = ctx.instanceid
AND ctx.contextlevel =50 )
WHERE c.id
IN ( 6, 8, 5 )
LIMIT 0 , 30"

i am just interested to know what is this context thing.

if anybody has any little knowledge about context to help me? big grin

Thanx
_hardik



Average of ratings: -
In reply to Hardik Akbari

Re: Whats the significance of Conext table and contextlevel.

by John Isner -
contextlevel=50 means a course context. Here are the current context types from lib/accesslib.php

25 // context definitions
26 define('CONTEXT_SYSTEM', 10);
27 define('CONTEXT_PERSONAL', 20); // Now gone
28 define('CONTEXT_USER', 30);
29 define('CONTEXT_COURSECAT', 40);
30 define('CONTEXT_COURSE', 50);
31 define('CONTEXT_GROUP', 60);
32 define('CONTEXT_MODULE', 70);
33 define('CONTEXT_BLOCK', 80);

In reply to John Isner

Re: Whats the significance of Conext table and contextlevel.

by Hardik Akbari -
Thanx john,
but thats little bit more confusing,
would you plsss elaborate course context. ?


In reply to Hardik Akbari

Re: Whats the significance of Conext table and contextlevel.

by John Isner -
Contexts form a hierarchy: Blocks and modules are inside courses, courses are inside categories, etc. Here's a somewhat out-of-date diagram. Moodle uses a user's current context to determine his permissions. So if you're a Teacher in a Course context, you have all the permissions you need to edit and manage the course. Course context is represented in the database by the integer 50.

For more information, read this short article in the documentation wiki.