What is Context and How a question category relates with a course

What is Context and How a question category relates with a course

by Manjula Weerasinghe -
Number of replies: 3
Hi friends,
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,
Manjula


Average of ratings: -
In reply to Manjula Weerasinghe

Re: What is Context and How a question category relates with a course

by Tim Hunt -
Piksa bilong Core developers Piksa bilong Documentation writers Piksa bilong Particularly helpful Moodlers Piksa bilong Peer reviewers Piksa bilong Plugin developers
If you look at the context table, you will see that there are two columns contextlevel and instanceid.

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.)
In reply to Tim Hunt

Re: What is Context and How a question category relates with a course

by George Driscoll -

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?

Thank You,

George A. Driscoll

North Lake College

Irving, Texas

In reply to George Driscoll

Re: What is Context and How a question category relates with a course

by Tim Hunt -
Piksa bilong Core developers Piksa bilong Documentation writers Piksa bilong Particularly helpful Moodlers Piksa bilong Peer reviewers Piksa bilong Plugin developers
You can only do it if the courses that you want to share questions between all belong to the same course category. If so, you can put the questions in the part of the question bank relating to that course category.

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.