Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
This class represents a complete tree of categories, grade_items and final grades, organises as an array primarily, but which can also be converted to other formats. More...
Public Member Functions | |
__construct ($courseid, $fillers=true, $category_grade_last=false, $collapsed=null, $nooutcomes=false) | |
Constructor, retrieves and stores a hierarchical array of all grade_category and grade_item objects for the given courseid. More... | |
category_collapse (&$element, $collapsed) | |
Static recursive helper - removes items from collapsed categories. More... | |
category_grade_last (&$element) | |
Static recursive helper - makes the grade_item for category the last children. More... | |
exporttojson ($root=null, $tabs="\t") | |
Returns a JSON representation of the grade-tree using recursion. More... | |
exporttoxml ($root=null, $tabs="\t") | |
Returns a well-formed XML representation of the grade-tree using recursion. More... | |
fill_levels (&$levels, &$element, $depth) | |
Static recursive helper - fills the levels array, useful when accessing tree elements of one level. More... | |
get_calculation_icon ($element, $gpr, $returnactionmenulink=false) | |
Return calculation icon for given element. More... | |
get_edit_icon ($element, $gpr, $returnactionmenulink=false) | |
Return edit icon for give element. More... | |
get_element_header (&$element, $withlink=false, $icon=true, $spacerifnone=false, $withdescription=false, $fulltotal=false) | |
Returns name of element optionally with icon and link. More... | |
get_element_icon (&$element, $spacerifnone=false) | |
Returns icon of element. More... | |
get_grade_analysis_icon (grade_grade $grade) | |
Returns an action icon leading to the grade analysis page. More... | |
get_grade_analysis_url (grade_grade $grade) | |
Returns URL of a page that is supposed to contain detailed grade analysis. More... | |
get_grade_eid ($grade_grade) | |
Returns the grade eid - the grade may not exist yet. More... | |
get_hiding_icon ($element, $gpr, $returnactionmenulink=false) | |
Return hiding icon for give element. More... | |
get_item ($itemid) | |
Returns a specific Grade Item. More... | |
get_item_eid ($grade_item) | |
Returns the grade_item eid. More... | |
get_items () | |
Returns the array of grade items. More... | |
get_levels () | |
Returns the array of levels. More... | |
get_locking_icon ($element, $gpr) | |
Return locking icon for given element. More... | |
get_params_for_iconstr ($element) | |
Given a grade_tree element, returns an array of parameters used to build an icon for that element. More... | |
get_reset_icon ($element, $gpr, $returnactionmenulink=false) | |
Return a reset icon for the given element. More... | |
grade_tree ($courseid, $fillers=true, $category_grade_last=false, $collapsed=null, $nooutcomes=false) | |
Old syntax of class constructor. More... | |
inject_colspans (&$element) | |
Static recursive helper - add colspan information into categories. More... | |
inject_fillers (&$element, $depth) | |
Static recursive helper - makes full tree (all leafes are at the same level) More... | |
locate_element ($eid) | |
Parses the array in search of a given eid and returns a element object with information about the element it has found. More... | |
no_outcomes (&$element) | |
Static recursive helper - removes all outcomes. More... | |
Static Public Member Functions | |
static | can_output_item ($element) |
Determines whether the grade tree item can be displayed. More... | |
Public Attributes | |
$context | |
$courseid | |
array | $items |
Grade items $items. | |
array | $levels |
2D array of grade items and categories $levels | |
course_modinfo | $modinfo |
Reference to modinfo for current course (for performance, to save retrieving it from courseid every time). More... | |
object | $top_element |
The basic representation of the tree as a hierarchical, 3-tiered array. More... | |
This class represents a complete tree of categories, grade_items and final grades, organises as an array primarily, but which can also be converted to other formats.
It has simple method calls with complex implementations, allowing for easy insertion, deletion and moving of items and categories within the tree.
@uses grade_structure
grade_tree::__construct | ( | $courseid, | |
$fillers = true , |
|||
$category_grade_last = false , |
|||
$collapsed = null , |
|||
$nooutcomes = false |
|||
) |
Constructor, retrieves and stores a hierarchical array of all grade_category and grade_item objects for the given courseid.
Full objects are instantiated. Ordering sequence is fixed if needed.
int | $courseid | The Course ID |
bool | $fillers | include fillers and colspans, make the levels var "rectangular" |
bool | $category_grade_last | category grade item is the last child |
array | $collapsed | array of collapsed categories |
bool | $nooutcomes | Whether or not outcomes should be included |
|
static |
Determines whether the grade tree item can be displayed.
This is particularly targeted for grade categories that have no total (None) when rendering the grade tree. It checks if the grade tree item is of type 'category', and makes sure that the category, or at least one of children, can be output.
array | $element | The grade category element. |
bool | True if the grade tree item can be displayed. False, otherwise. |
grade_tree::category_collapse | ( | & | $element, |
$collapsed | |||
) |
Static recursive helper - removes items from collapsed categories.
array | &$element | The seed of the recursion |
array | $collapsed | array of collapsed categories |
void |
grade_tree::category_grade_last | ( | & | $element | ) |
Static recursive helper - makes the grade_item for category the last children.
array | &$element | The seed of the recursion |
void |
grade_tree::exporttojson | ( | $root = null , |
|
$tabs = "\t" |
|||
) |
Returns a JSON representation of the grade-tree using recursion.
array | $root | The current element in the recursion. If null, starts at the top of the tree. |
string | $tabs | Tab characters used to indent the string nicely for humans to enjoy |
string |
grade_tree::exporttoxml | ( | $root = null , |
|
$tabs = "\t" |
|||
) |
Returns a well-formed XML representation of the grade-tree using recursion.
array | $root | The current element in the recursion. If null, starts at the top of the tree. |
string | $tabs | The control character to use for tabs |
string::$xml |
grade_tree::fill_levels | ( | & | $levels, |
& | $element, | ||
$depth | |||
) |
Static recursive helper - fills the levels array, useful when accessing tree elements of one level.
array | &$levels | The levels of the grade tree through which to recurse |
array | &$element | The seed of the recursion |
int | $depth | How deep are we? |
void |
|
inherited |
Return calculation icon for given element.
array | $element | An array representing an element in the grade_tree |
object | $gpr | A grade_plugin_return object |
bool | $returnactionmenulink | return the instance of action_menu_link instead of string |
string|action_menu_link |
|
inherited |
Return edit icon for give element.
array | $element | An array representing an element in the grade_tree |
object | $gpr | A grade_plugin_return object |
bool | $returnactionmenulink | return the instance of action_menu_link instead of string |
string|action_menu_link |
|
inherited |
Returns name of element optionally with icon and link.
array | &$element | An array representing an element in the grade_tree |
bool | $withlink | Whether or not this header has a link |
bool | $icon | Whether or not to display an icon with this header |
bool | $spacerifnone | return spacer if no icon found |
bool | $withdescription | Show description if defined by this item. |
bool | $fulltotal | If the item is a category total, returns $categoryname."total" instead of "Category total" or "Course total" |
string | header |
|
inherited |
Returns icon of element.
array | &$element | An array representing an element in the grade_tree |
bool | $spacerifnone | return spacer if no icon found |
string | icon or spacer |
|
inherited |
Returns an action icon leading to the grade analysis page.
grade_grade | $grade |
string |
|
inherited |
Returns URL of a page that is supposed to contain detailed grade analysis.
At the moment, only activity modules are supported. The method generates link to the module's file grade.php with the parameters id (cmid), itemid, itemnumber, gradeid and userid. If the grade.php does not exist, null is returned.
moodle_url|null | URL or null if unable to construct it |
|
inherited |
Returns the grade eid - the grade may not exist yet.
grade_grade | $grade_grade | A grade_grade object |
string | eid |
|
inherited |
Return hiding icon for give element.
array | $element | An array representing an element in the grade_tree |
object | $gpr | A grade_plugin_return object |
bool | $returnactionmenulink | return the instance of action_menu_link instead of string |
string|action_menu_link |
grade_tree::get_item | ( | $itemid | ) |
Returns a specific Grade Item.
int | $itemid | The ID of the grade_item object |
grade_item |
|
inherited |
Returns the grade_item eid.
grade_item | $grade_item | A grade_item object |
string | eid |
grade_tree::get_items | ( | ) |
Returns the array of grade items.
array |
grade_tree::get_levels | ( | ) |
Returns the array of levels.
array |
|
inherited |
Return locking icon for given element.
array | $element | An array representing an element in the grade_tree |
object | $gpr | A grade_plugin_return object |
string |
|
inherited |
Given a grade_tree element, returns an array of parameters used to build an icon for that element.
array | $element | An array representing an element in the grade_tree |
array |
|
inherited |
Return a reset icon for the given element.
array | $element | An array representing an element in the grade_tree |
object | $gpr | A grade_plugin_return object |
bool | $returnactionmenulink | return the instance of action_menu_link instead of string |
string|action_menu_link |
grade_tree::grade_tree | ( | $courseid, | |
$fillers = true , |
|||
$category_grade_last = false , |
|||
$collapsed = null , |
|||
$nooutcomes = false |
|||
) |
grade_tree::inject_colspans | ( | & | $element | ) |
Static recursive helper - add colspan information into categories.
array | &$element | The seed of the recursion |
int |
grade_tree::inject_fillers | ( | & | $element, |
$depth | |||
) |
Static recursive helper - makes full tree (all leafes are at the same level)
array | &$element | The seed of the recursion |
int | $depth | How deep are we? |
int |
grade_tree::locate_element | ( | $eid | ) |
Parses the array in search of a given eid and returns a element object with information about the element it has found.
int | $eid | Gradetree Element ID |
object | element |
grade_tree::no_outcomes | ( | & | $element | ) |
Static recursive helper - removes all outcomes.
array | &$element | The seed of the recursion |
void |
|
inherited |
Reference to modinfo for current course (for performance, to save retrieving it from courseid every time).
Not actually set except for the grade_tree type.
object grade_tree::$top_element |
The basic representation of the tree as a hierarchical, 3-tiered array.
$top_element