Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Class for performing operations on question categories. More...
Public Member Functions | |
__construct ($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) | |
Constructor. More... | |
add_category ($newparent, $newcategory, $newinfo, $return=false, $newinfoformat=FORMAT_HTML, $idnumber=null) | |
Create a new category. More... | |
delete_category ($categoryid) | |
Deletes an existing question category. More... | |
display_move_form ($questionsincategory, $category) | |
display_user_interface () | |
Displays the user interface. | |
edit_single_category ($categoryid) | |
get_course_ids ($categories) | |
gets all the courseids for the given categories More... | |
get_question_categories ($parent=null, $sort="sortorder ASC") | |
Gets question categories. More... | |
initialize ($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) | |
Initializes this classes general category-related variables. | |
move_questions ($oldcat, $newcat) | |
move_questions_and_delete_category ($oldcat, $newcat) | |
output_edit_lists () | |
Outputs a list to allow editing/rearranging of existing categories. More... | |
output_new_table () | |
Outputs a table to allow entry of a new category. | |
question_category_object ($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) | |
Old syntax of class constructor. More... | |
set_viable_parents (&$parentstrings, $category) | |
Sets the viable parents. More... | |
update_category ($updateid, $newparent, $newname, $newinfo, $newinfoformat=FORMAT_HTML, $idnumber=null, $redirect=true) | |
Updates an existing category with given params. More... | |
Public Attributes | |
question_category_edit_form | $catform |
Object representing form for adding / editing categories. | |
array | $editlists = array() |
nested lists to display categories. | |
moodle_url | $pageurl |
Object representing url for this page. | |
array | $str |
common language strings. | |
$tab | |
$tabsize = 3 | |
Class for performing operations on question categories.
question_category_object::__construct | ( | $page, | |
$pageurl, | |||
$contexts, | |||
$currentcat, | |||
$defaultcategory, | |||
$todelete, | |||
$addcontexts | |||
) |
Constructor.
int | $page | page number |
moodle_url | $pageurl | base URL of the display categories page. Used for redirects. |
context[] | $contexts | contexts where the current user can edit categories. |
int | $currentcat | id of the category to be edited. 0 if none. |
int | null | $defaultcategory | id of the current category. null if none. |
int | $todelete | id of the category to delete. 0 if none. |
context[] | $addcontexts | contexts where the current user can add questions. |
question_category_object::add_category | ( | $newparent, | |
$newcategory, | |||
$newinfo, | |||
$return = false , |
|||
$newinfoformat = FORMAT_HTML , |
|||
$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.
string | $newparent | 'categoryid,contextid' of the parent category. |
string | $newcategory | the name. |
string | $newinfo | the description. |
bool | $return | if true, return rather than redirecting. |
int | string | $newinfoformat | description format. One of the FORMAT_ constants. |
null | $idnumber | the idnumber. '' is converted to null. |
bool|int | New category id if successful, else false. |
question_category_object::delete_category | ( | $categoryid | ) |
Deletes an existing question category.
int | deletecat id of category to delete |
question_category_object::get_course_ids | ( | $categories | ) |
gets all the courseids for the given categories
array | categories contains category objects in a tree representation |
array | courseids flat array in form categoryid=>courseid |
question_category_object::get_question_categories | ( | $parent = null , |
|
$sort = "sortorder ASC" |
|||
) |
Gets question categories.
int | parent - if given, restrict records to those with this parent id. |
string | sort - [[sortfield [,sortfield]] {ASC|DESC}] |
array | categories |
question_category_object::output_edit_lists | ( | ) |
Outputs a list to allow editing/rearranging of existing categories.
$this->initialize() must have already been called
question_category_object::question_category_object | ( | $page, | |
$pageurl, | |||
$contexts, | |||
$currentcat, | |||
$defaultcategory, | |||
$todelete, | |||
$addcontexts | |||
) |
question_category_object::set_viable_parents | ( | & | $parentstrings, |
$category | |||
) |
Sets the viable parents.
Viable parents are any except for the category itself, or any of it's descendants The parentstrings parameter is passed by reference and changed by this function.
array | parentstrings a list of parentstrings |
object | category |
question_category_object::update_category | ( | $updateid, | |
$newparent, | |||
$newname, | |||
$newinfo, | |||
$newinfoformat = FORMAT_HTML , |
|||
$idnumber = null , |
|||
$redirect = true |
|||
) |
Updates an existing category with given params.
Warning! parameter order and meaning confusingly different from add_category in some ways!
int | $updateid | id of the category to update. |
int | $newparent | 'categoryid,contextid' of the parent category to set. |
string | $newname | category name. |
string | $newinfo | category description. |
int | string | $newinfoformat | description format. One of the FORMAT_ constants. |
int | $idnumber | the idnumber. '' is converted to null. |
bool | $redirect | if true, will redirect once the DB is updated (default). |