|
static | add_indented_names (array $categories, int $nochildrenof=-1) |
| Format categories into an indented list reflecting the tree structure.
|
|
static | combine_id_context (\stdClass $category) |
| Combine id and context id for a question category.
|
|
static | flatten_category_tree (array &$categories, $id, int $depth=0, int $nochildrenof=-1) |
| Only for the use of add_indented_names().
|
|
static | get_categories_for_contexts (string $contexts, string $sortorder='parent, sortorder, name ASC', bool $top=false, int $showallversions=0,) |
| Get all the category objects, including a count of the number of questions in that category, for all the categories in the lists $contexts.
|
|
static | question_add_context_in_key (array $categories) |
| Add context in categories key.
|
|
static | question_category_options (array $contexts, bool $top=false, int $currentcat=0, bool $popupform=false, int $nochildrenof=-1, bool $escapecontextnames=true,) |
| Output an array of question categories.
|
|
static | question_category_select_menu (array $contexts, bool $top=false, int $currentcat=0, string $selected="", int $nochildrenof=-1, bool $return=false,) |
| Output a select menu of question categories.
|
|
static | question_fix_top_names (array $categories, bool $escape=true) |
| Finds top categories in the given categories hierarchy and replace their name with a proper localised string.
|
|
static | question_remove_stale_questions_from_category (int $categoryid) |
| Remove stale questions from a category.
|
|
static qbank_managecategories\helper::flatten_category_tree |
( |
array & | $categories, |
|
|
| $id, |
|
|
int | $depth = 0, |
|
|
int | $nochildrenof = -1 ) |
|
static |
Only for the use of add_indented_names().
Recursively adds an indentedname field to each category, starting with the category with id $id, and dealing with that category and all its children, and return a new array, with those categories in the right order.
- Parameters
-
array | $categories | an array of categories which has had childids fields added by flatten_category_tree(). Passed by reference for performance only. It is not modfied. |
int | $id | the category to start the indenting process from. |
int | $depth | the indent depth. Used in recursive calls. |
int | $nochildrenof | |
- Return values
-
array | a new array of categories, in the right order for the tree. |
static qbank_managecategories\helper::question_remove_stale_questions_from_category |
( |
int | $categoryid | ) |
|
|
static |
Remove stale questions from a category.
This finds and removes any old-style random questions (qtype = random), or any questions that were deleted while they were in use by a quiz (status = hidden), but those usages have since been removed.
If a category only contains stale questions, the users are unable to delete the question category unless they move those stale questions to another one category, but to them the category may appear empty. The purpose of this function is to detect the questions that may have gone stale and remove them.
You will typically use this prior to checking if the category contains questions.
- Parameters
-
int | $categoryid | The category ID. |
- Exceptions
-