function get_categories_for_contexts in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/lib/questionlib.php \get_categories_for_contexts()
Get all the category objects, including a count of the number of questions in that category, for all the categories in the lists $contexts.
Parameters
mixed $contexts either a single contextid, or a comma-separated list of context ids.:
string $sortorder used as the ORDER BY clause in the select statement.:
Return value
array of category objects.
1 call to get_categories_for_contexts()
- question_category_options in includes/
moodle/ lib/ questionlib.php - Output an array of question categories.
File
- includes/
moodle/ lib/ questionlib.php, line 1938
Code
function get_categories_for_contexts($contexts, $sortorder = 'parent, sortorder, name ASC') {
global $CFG;
return get_records_sql("\n SELECT c.*, (SELECT count(1) FROM {$CFG->prefix}question q\n WHERE c.id = q.category AND q.hidden='0' AND q.parent='0') as questioncount\n FROM {$CFG->prefix}question_categories c\n WHERE c.contextid IN ({$contexts})\n ORDER BY {$sortorder}");
}