See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
Class that holds a tree of availability conditions.
Copyright: | 2014 The Open University |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 797 lines (30 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
tree:: (19 methods):
__toString()
__construct()
check_available()
is_applied_to_user_lists()
filter_user_list()
get_user_list_sql()
is_available_for_all()
get_full_information()
get_result_information()
get_full_information_recursive()
get_logic_flags()
save()
is_empty()
get_all_children()
recursive_get_all_children()
update_after_restore()
update_dependency_id()
get_nested_json()
get_root_json()
__toString() X-Ref |
Display a representation of this tree (used for debugging). return: string Text representation of tree |
__construct($structure, $lax = false, $root = true) X-Ref |
Decodes availability structure. This function also validates the retrieved data as follows: 1. Data that does not meet the API-defined structure causes a coding_exception (this should be impossible unless there is a system bug or somebody manually hacks the database). 2. Data that meets the structure but cannot be implemented (e.g. reference to missing plugin or to module that doesn't exist) is either silently discarded (if $lax is true) or causes a coding_exception (if $lax is false). param: \stdClass $structure Structure (decoded from JSON) param: boolean $lax If true, throw exceptions only for invalid structure param: boolean $root If true, this is the root tree return: tree Availability tree |
check_available($not, info $info, $grabthelot, $userid) X-Ref |
No description |
is_applied_to_user_lists() X-Ref |
No description |
filter_user_list(array $users, $not, info $info,capability_checker $checker) X-Ref |
Tests against a user list. Users who cannot access the activity due to availability restrictions will be removed from the list. This test ONLY includes conditions which are marked as being applied to user lists. For example, group conditions are included but date conditions are not included. The function operates reasonably efficiently i.e. should not do per-user database queries. It is however likely to be fairly slow. param: array $users Array of userid => object param: bool $not If tree's parent indicates it's being checked negatively param: info $info Info about current context param: capability_checker $checker Capability checker return: array Filtered version of input array |
get_user_list_sql($not, info $info, $onlyactive) X-Ref |
No description |
is_available_for_all($not = false) X-Ref |
No description |
get_full_information(info $info) X-Ref |
Gets full information about this tree (including all children) as HTML for display to staff. param: info $info Information about location of condition tree return: string HTML data (empty string if none) |
get_result_information(info $info, result $result) X-Ref |
Gets information about this tree corresponding to the given result object. (In other words, only conditions which the student actually fails will be shown - and nothing if display is turned off.) param: info $info Information about location of condition tree param: result $result Result object return: string HTML data (empty string if none) |
get_full_information_recursive($not, info $info, ?result $result, $root, $hidden = false) X-Ref |
Gets information about this tree (including all or selected children) as HTML for display to staff or student. param: bool $not True if there is a NOT in effect param: info $info Information about location of condition tree param: result|null $result Result object if this is a student display, else null param: bool $root True if this is the root item param: bool $hidden Staff display; true if this tree has show=false (from parent) return: string|renderable Information to render |
get_logic_flags($not) X-Ref |
Converts the operator for the tree into two flags used for computing the result. The 2 flags are $innernot (whether to set $not when calling for children) and $andoperator (whether to use AND or OR operator to combine children). param: bool $not Not flag passed to this tree return: array Array of the 2 flags ($innernot, $andoperator) |
save() X-Ref |
No description |
is_empty() X-Ref |
Checks whether this tree is empty (contains no children). return: boolean True if empty |
get_all_children($classname) X-Ref |
Recursively gets all children of a particular class (you can use a base class to get all conditions, or a specific class). param: string $classname Full class name e.g. core_availability\condition return: array Array of nodes of that type (flattened, not a tree any more) |
recursive_get_all_children($classname, array &$result) X-Ref |
Internal function that implements get_all_children efficiently. param: string $classname Full class name e.g. core_availability\condition param: array $result Output array of nodes |
update_after_restore($restoreid, $courseid,\base_logger $logger, $name) X-Ref |
No description |
update_dependency_id($table, $oldid, $newid) X-Ref |
No description |
get_nested_json(array $children, $op = self::OP_AND) X-Ref |
Returns a JSON object which corresponds to a tree. Intended for unit testing, as normally the JSON values are constructed by JavaScript code. This function generates 'nested' (i.e. not root-level) trees. param: array $children Array of JSON objects from component children param: string $op Operator (tree::OP_xx) return: stdClass JSON object |
get_root_json(array $children, $op = self::OP_AND, $show = true) X-Ref |
Returns a JSON object which corresponds to a tree at root level. Intended for unit testing, as normally the JSON values are constructed by JavaScript code. The $show parameter can be a boolean for all OP_xx options. For OP_AND and OP_NOT_OR where you have individual show options, you can specify a boolean (same for all) or an array. param: array $children Array of JSON objects from component children param: string $op Operator (tree::OP_xx) param: bool|array $show Whether 'show' option is turned on (see above) return: stdClass JSON object ready for encoding |