本文整理汇总了PHP中grade_category::_fetch_course_tree_recursion方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_category::_fetch_course_tree_recursion方法的具体用法?PHP grade_category::_fetch_course_tree_recursion怎么用?PHP grade_category::_fetch_course_tree_recursion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_category
的用法示例。
在下文中一共展示了grade_category::_fetch_course_tree_recursion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _fetch_course_tree_recursion
function _fetch_course_tree_recursion($category_array, &$sortorder)
{
// update the sortorder in db if needed
if ($category_array['object']->sortorder != $sortorder) {
$category_array['object']->set_sortorder($sortorder);
}
// store the grade_item or grade_category instance with extra info
$result = array('object' => $category_array['object'], 'type' => $category_array['type'], 'depth' => $category_array['depth']);
// reuse final grades if there
if (array_key_exists('finalgrades', $category_array)) {
$result['finalgrades'] = $category_array['finalgrades'];
}
// recursively resort children
if (!empty($category_array['children'])) {
$result['children'] = array();
//process the category item first
$cat_item_id = null;
foreach ($category_array['children'] as $oldorder => $child_array) {
if ($child_array['type'] == 'courseitem' or $child_array['type'] == 'categoryitem') {
$result['children'][$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
}
}
foreach ($category_array['children'] as $oldorder => $child_array) {
if ($child_array['type'] != 'courseitem' and $child_array['type'] != 'categoryitem') {
$result['children'][++$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
}
}
}
return $result;
}
示例2: _fetch_course_tree_recursion
/**
* An internal function that recursively sorts grade categories within a course
*
* @param array $category_array The seed of the recursion
* @param int $sortorder The current sortorder
* @return array An array containing 'object', 'type', 'depth' and optionally 'children'
*/
private static function _fetch_course_tree_recursion($category_array, &$sortorder)
{
// update the sortorder in db if needed
//NOTE: This leads to us resetting sort orders every time the categories and items page is viewed :(
//if ($category_array['object']->sortorder != $sortorder) {
//$category_array['object']->set_sortorder($sortorder);
//}
if (isset($category_array['object']->gradetype) && $category_array['object']->gradetype == GRADE_TYPE_NONE) {
return null;
}
// store the grade_item or grade_category instance with extra info
$result = array('object' => $category_array['object'], 'type' => $category_array['type'], 'depth' => $category_array['depth']);
// reuse final grades if there
if (array_key_exists('finalgrades', $category_array)) {
$result['finalgrades'] = $category_array['finalgrades'];
}
// recursively resort children
if (!empty($category_array['children'])) {
$result['children'] = array();
//process the category item first
$child = null;
foreach ($category_array['children'] as $oldorder => $child_array) {
if ($child_array['type'] == 'courseitem' or $child_array['type'] == 'categoryitem') {
$child = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
if (!empty($child)) {
$result['children'][$sortorder] = $child;
}
}
}
foreach ($category_array['children'] as $oldorder => $child_array) {
if ($child_array['type'] != 'courseitem' and $child_array['type'] != 'categoryitem') {
$child = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
if (!empty($child)) {
$result['children'][++$sortorder] = $child;
}
}
}
}
return $result;
}