|
| add_category (string $newparent, string $newcategory, string $newinfo, string $newinfoformat=FORMAT_HTML, ?string $idnumber=null,) |
| Create a new category.
|
|
| delete_category (int $categoryid) |
| Deletes an existing question category.
|
|
| get_max_sortorder (int $parentid) |
| Get current max sort in a given parent.
|
|
| get_real_question_ids_in_category (int $categoryid) |
| Returns ids of the question in the given question category.
|
|
| idnumber_is_unique_in_context (?string $idnumber, int $contextid, ?int $excludecategoryid=null) |
| Check there is no question category with the given ID number in the given context.
|
|
| is_only_child_of_top_category_in_context (int $categoryid) |
| Checks whether this is the only child of a top category in a context.
|
|
| is_top_category (int $categoryid) |
| Checks whether the category is a "Top" category (with no parent).
|
|
| move_questions (int $oldcat, int $newcat) |
| Move questions to another category.
|
|
| move_questions_and_delete_category (int $oldcat, int $newcat) |
| Move questions and then delete the category.
|
|
| require_can_delete_category (int $todelete) |
| Ensures that this user is allowed to delete this category.
|
|
| require_manage_category (context $context) |
| Check the user can manage categories in the given context.
|
|
| update_category (int $updateid, string $newparent, string $newname, string $newinfo, string $newinfoformat=FORMAT_HTML, ?string $idnumber=null, ?int $sortorder=null,) |
| Updates an existing category with given params.
|
|
|
array array | $managedcontexts = [] |
| Cached checks for managecategories permissions in each context.
|
|
◆ add_category()
core_question\category_manager::add_category |
( |
string | $newparent, |
|
|
string | $newcategory, |
|
|
string | $newinfo, |
|
|
string | $newinfoformat = FORMAT_HTML, |
|
|
?string | $idnumber = null ) |
Create a new category.
Data is expected to come from question_category_edit_form.
By default redirects on success, unless $return is true.
- Parameters
-
string | $newparent | 'categoryid,contextid' of the parent category. |
string | $newcategory | the name. |
string | $newinfo | the description. |
string | $newinfoformat | description format. One of the FORMAT_ constants. |
?string | $idnumber | the idnumber. '' is converted to null. |
- Return values
-
◆ delete_category()
core_question\category_manager::delete_category |
( |
int | $categoryid | ) |
|
Deletes an existing question category.
- Parameters
-
int | $categoryid | id of category to delete. |
◆ get_max_sortorder()
core_question\category_manager::get_max_sortorder |
( |
int | $parentid | ) |
|
Get current max sort in a given parent.
- Parameters
-
int | $parentid | The ID of the parent category. |
- Return values
-
int | current max sort order |
◆ get_real_question_ids_in_category()
core_question\category_manager::get_real_question_ids_in_category |
( |
int | $categoryid | ) |
|
Returns ids of the question in the given question category.
This method only returns the real question. It does not include subquestions of question types like multianswer.
- Parameters
-
int | $categoryid | id of the category. |
- Return values
-
int[] | array of question ids. |
◆ idnumber_is_unique_in_context()
core_question\category_manager::idnumber_is_unique_in_context |
( |
?string | $idnumber, |
|
|
int | $contextid, |
|
|
?int | $excludecategoryid = null ) |
Check there is no question category with the given ID number in the given context.
- Parameters
-
?string | $idnumber | The ID number to look for. |
int | $contextid | The context to check the categories in. |
?int | $excludecategoryid | If set, exclude this category from the check (e.g. if this is the one being edited). |
- Return values
-
- Exceptions
-
◆ is_only_child_of_top_category_in_context()
core_question\category_manager::is_only_child_of_top_category_in_context |
( |
int | $categoryid | ) |
|
Checks whether this is the only child of a top category in a context.
- Parameters
-
int | $categoryid | a category id. |
- Return values
-
- Exceptions
-
◆ is_top_category()
core_question\category_manager::is_top_category |
( |
int | $categoryid | ) |
|
Checks whether the category is a "Top" category (with no parent).
- Parameters
-
int | $categoryid | a category id. |
- Return values
-
- Exceptions
-
◆ move_questions()
core_question\category_manager::move_questions |
( |
int | $oldcat, |
|
|
int | $newcat ) |
Move questions to another category.
- Parameters
-
int | $oldcat | id of the old category. |
int | $newcat | id of the new category. |
- Exceptions
-
◆ move_questions_and_delete_category()
core_question\category_manager::move_questions_and_delete_category |
( |
int | $oldcat, |
|
|
int | $newcat ) |
Move questions and then delete the category.
- Parameters
-
int | $oldcat | id of the old category. |
int | $newcat | id of the new category. |
◆ require_can_delete_category()
core_question\category_manager::require_can_delete_category |
( |
int | $todelete | ) |
|
Ensures that this user is allowed to delete this category.
- Parameters
-
int | $todelete | a category id. |
- Exceptions
-
required_capability_exception | |
dml_exception|moodle_exception | |
◆ require_manage_category()
core_question\category_manager::require_manage_category |
( |
context | $context | ) |
|
Check the user can manage categories in the given context.
This caches a successful check in $this->managedcontexts in case we check the same context multiple times.
- Parameters
-
- Return values
-
- Exceptions
-
required_capability_exception | |
◆ update_category()
core_question\category_manager::update_category |
( |
int | $updateid, |
|
|
string | $newparent, |
|
|
string | $newname, |
|
|
string | $newinfo, |
|
|
string | $newinfoformat = FORMAT_HTML, |
|
|
?string | $idnumber = null, |
|
|
?int | $sortorder = null ) |
Updates an existing category with given params.
Warning! parameter order and meaning confusingly different from add_category in some ways!
- Parameters
-
int | $updateid | id of the category to update. |
string | $newparent | 'categoryid,contextid' of the parent category to set. |
string | $newname | category name. |
string | $newinfo | category description. |
string | $newinfoformat | description format. One of the FORMAT_ constants. |
?string | $idnumber | the idnumber. '' is converted to null. |
?int | $sortorder | The updated sortorder. Not updated if null. |
◆ $managedcontexts
array array core_question\category_manager::$managedcontexts = [] |
|
protected |
Cached checks for managecategories permissions in each context.
$managedcontexts;
The documentation for this class was generated from the following file:
- question/classes/category_manager.php