mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-61132 Quiz: "Random" question from "Top" categories
* Support for adding ranodm questions from "Top" categories
This commit is contained in:
parent
9275220de3
commit
3b8f3198de
6 changed files with 68 additions and 7 deletions
|
@ -1030,6 +1030,23 @@ function question_get_top_category($contextid, $create = false) {
|
|||
return $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of top categories in the given contexts in the array("categoryid,categorycontextid") format.
|
||||
*
|
||||
* @param array $contextids List of context ids
|
||||
* @return array
|
||||
*/
|
||||
function question_get_top_categories_for_contexts($contextids) {
|
||||
global $DB;
|
||||
|
||||
$concatsql = $DB->sql_concat_join("','", ['id', 'contextid']);
|
||||
list($insql, $params) = $DB->get_in_or_equal($contextids);
|
||||
$sql = "SELECT $concatsql FROM {question_categories} WHERE contextid $insql AND parent = 0";
|
||||
$topcategories = $DB->get_fieldset_sql($sql, $params);
|
||||
|
||||
return $topcategories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default category in the most specific context.
|
||||
* If no categories exist yet then default ones are created in all contexts.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue