Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
qbank_managecategories\question_category_list Class Reference
Inheritance diagram for qbank_managecategories\question_category_list:
moodle_list

Public Member Functions

 __construct ($type='ul', $attributes='', $editable=false, $pageurl=null, $page=0, $pageparamname='page', $itemsperpage=DEFAULT_QUESTIONS_PER_PAGE, $context=null)
 Constructor.
 
 add_item ($item)
 
 display_page_numbers ()
 display list of page numbers for navigation
 
 find_item ($id, $suppresserror=false)
 Recurse down the tree and find an item by it's id.
 
 get_child_ids ()
 Returns an array of ids of child items.
 
 get_items_peers ($itemid)
 Returns an array of ids of peers of an item.
 
 get_records ()
 Set the array of records of list items.
 
 get_top_level_parent_id ($item)
 Returns the highest category id that the $item can have as its parent.
 
 item_is_first_on_page ($itemid)
 
 item_is_last_on_page ($itemid)
 
 list_from_records ($paged=false, $offset=0)
 Produces a hierarchical tree of list items from a flat array of records.
 
 move_item_left ($id)
 Moves the item one step up in the tree.
 
 move_item_right ($id)
 Make item with id $id the child of the peer that is just above it in the sort order.
 
 move_item_up_down ($direction, $id)
 Move a record up or down.
 
 process_actions ($left, $right, $moveup, $movedown)
 Process any actions.
 
 reorder_peers ($peers)
 
 set_parent ($parent)
 
 to_html ($indent=0, $extraargs=array())
 Returns html string.
 

Public Attributes

 $attributes
 
array $childparent
 keys are child ids, values are parents.
 
$context $context = null
 Context.
 
 $editable
 
 $fieldnamesparent = 'parent'
 
 $firstitem = 1
 
array $items = array()
 of $listitemclassname objects.
 
 $lastitem = 999999
 
$lastlist $lastlist = null
 Reference to list displayed above this one.
 
$listitemclassname $listitemclassname = '\qbank_managecategories\question_category_list_item'
 List item class name.
 
$nextlist $nextlist = null
 Reference to list displayed below this one.
 
 $offset = 0
 
 $page = 0
 
 $pagecount
 
 $paged = false
 
 $pageparamname
 
 $pageurl
 
list_item $parentitem = null
 or derived class.
 
array $records = array()
 Records from db, only used in top level list.
 
$sortby $sortby = 'parent, sortorder, name'
 Sort by string.
 
$table $table = "question_categories"
 Table name.
 
string $type
 'ol' or 'ul'.
 

Constructor & Destructor Documentation

◆ __construct()

qbank_managecategories\question_category_list::__construct ( $type = 'ul',
$attributes = '',
$editable = false,
$pageurl = null,
$page = 0,
$pageparamname = 'page',
$itemsperpage = DEFAULT_QUESTIONS_PER_PAGE,
$context = null )

Constructor.

Parameters
string$type
string$attributes
boolean$editable
moodle_url$pageurlurl for this page
integer$pageif 0 no pagination. (These three params only used in top level list.)
string$pageparamnamename of url param that is used for passing page no
integer$itemsperpageno of top level items.
context$context

Member Function Documentation

◆ find_item()

moodle_list::find_item ( $id,
$suppresserror = false )
inherited

Recurse down the tree and find an item by it's id.

Parameters
integer$id
boolean$suppresserrorerror if not item found?
Return values
list_itemcopy or null if item is not found

◆ get_child_ids()

moodle_list::get_child_ids ( )
inherited

Returns an array of ids of child items.

Return values
arraypeer ids

◆ get_items_peers()

moodle_list::get_items_peers ( $itemid)
inherited

Returns an array of ids of peers of an item.

Parameters
intitemid - if given, restrict records to those with this parent id.
Return values
arraypeer ids

◆ get_records()

qbank_managecategories\question_category_list::get_records ( )

Set the array of records of list items.

Reimplemented from moodle_list.

◆ get_top_level_parent_id()

qbank_managecategories\question_category_list::get_top_level_parent_id ( $item)

Returns the highest category id that the $item can have as its parent.

Note: question categories cannot go higher than the TOP category.

Parameters
list_item$itemThe item which its top level parent is going to be returned.
Return values
int

Reimplemented from moodle_list.

◆ item_is_first_on_page()

moodle_list::item_is_first_on_page ( $itemid)
inherited
Parameters
integer$itemidan item id.
Return values
booleanIs the item with the given id the first top-level item on the current page?

◆ item_is_last_on_page()

moodle_list::item_is_last_on_page ( $itemid)
inherited
Parameters
integer$itemidan item id.
Return values
booleanIs the item with the given id the last top-level item on the current page?

◆ list_from_records()

moodle_list::list_from_records ( $paged = false,
$offset = 0 )
inherited

Produces a hierarchical tree of list items from a flat array of records.

'parent' field is expected to point to a parent record. records are already sorted. If the parent field doesn't point to another record in the array then this is a top level list

Parameters
integer$offsethow many list toplevel items are there in lists before this one
Return values
array(boolean,integer)whether there is more than one page, $offset + how many toplevel items where there in this list.

◆ move_item_left()

moodle_list::move_item_left ( $id)
inherited

Moves the item one step up in the tree.

Parameters
int$idan item index.
Return values
list_itemthe item that used to be the parent of the item moved.

◆ move_item_right()

moodle_list::move_item_right ( $id)
inherited

Make item with id $id the child of the peer that is just above it in the sort order.

Parameters
integer$id

◆ move_item_up_down()

moodle_list::move_item_up_down ( $direction,
$id )
inherited

Move a record up or down.

Parameters
string$directionup / down
integer$id

◆ process_actions()

qbank_managecategories\question_category_list::process_actions ( $left,
$right,
$moveup,
$movedown )

Process any actions.

Parameters
integer$leftid of item to move left
integer$rightid of item to move right
integer$moveupid of item to move up
integer$movedownid of item to move down
Return values
void

Reimplemented from moodle_list.

◆ to_html()

moodle_list::to_html ( $indent = 0,
$extraargs = array() )
inherited

Returns html string.

Parameters
integer$indentdepth of indentation.

The documentation for this class was generated from the following file: