I need to get question categories related to a certain course. but I found that in the database, question category table has no direct relation with course category table. Question category table link with context table through contextid field. But I don't understand the use of a context. I want to get the question categories relates to a course when I create a new quiz ( I need to get the contextid of the course which the currently creating quiz belongs to, in mod/quiz/mod_form.php page and mod/quiz/lib.php page). I'd be very grateful if anyone could help me out.
thanks & regards,
contextlevel tells you what sort of context you have, according the the numbers at the top of lib/accesslib.php. So you want rows where contextlevel is CONTEXT_COURSE, that is 50. In this case, instanceid links to the id from the course table.
(For CONTEXT_USER, instanceid links to user.id, and for CONTEXT_MODULE it links to course_modules.id, and so on.)
Is there a way to identify the relationship between a course and the question categories in the question bank that relate to that course? I am trying to make a set of question categories available to the teachers of a particular course without distracting them by making all of the questions categories available to them.
I have read about the concept of "context" as applied to question categories within the question bank, but I cannot find a way to link a course to a set or subset of question categories. I was hoping to do this without having to directly manipulate the contents of the context table. Each question category within the question bank has a name that uniquely identifies it. Courses are uniquely identified. Does the mechanism exist within Moodle 1.9.2 to specify for each course the question categories that apply to that course?
George A. Driscoll
North Lake College
Otherwise, the best you can do is probably to arrange the question categories at site level in such a way that it is as easy as possible for different groups of teachers to find the questions they need.