original_string: public function category_listing(core_course_category $category = null) {
  
          if ($category === null) {
              $selectedparents = array();
              $selectedcategory = null;
          } else {
              $selectedparents = $category->get_parents();
              $selectedparents[] = $category->id;
              $selectedcategory = $category->id;
          }
          $catatlevel = \core_course\management\helper::get_expanded_categories('');
          $catatlevel[] = array_shift($selectedparents);
          $catatlevel = array_unique($catatlevel);
  
          $listing = core_course_category::top()->get_children();
  
          $attributes = array(
                  'class' => 'ml-1 list-unstyled',
                  'role' => 'tree',
                  'aria-labelledby' => 'category-listing-title'
          );
  
          $html  = html_writer::start_div('category-listing card w-100');
          $html .= html_writer::tag('h3', get_string('categories'),
                  array('class' => 'card-header', 'id' => 'category-listing-title'));
          $html .= html_writer::start_div('card-body');
          $html .= $this->category_listing_actions($category);
          $html .= html_writer::start_tag('ul', $attributes);
          foreach ($listing as $listitem) {
              // Render each category in the listing.
              $subcategories = array();
              if (in_array($listitem->id, $catatlevel)) {
                  $subcategories = $listitem->get_children();
              }
              $html .= $this->category_listitem(
                      $listitem,
                      $subcategories,
                      $listitem->get_children_count(),
                      $selectedcategory,
                      $selectedparents
              );
          }
          $html .= html_writer::end_tag('ul');
          $html .= $this->category_bulk_actions($category);
          $html .= html_writer::end_div();
          $html .= html_writer::end_div();
          return $html;
      }
code: public function category_listing(core_course_category $category = null) {
  
          if ($category === null) {
              $selectedparents = array();
              $selectedcategory = null;
          } else {
              $selectedparents = $category->get_parents();
              $selectedparents[] = $category->id;
              $selectedcategory = $category->id;
          }
          $catatlevel = \core_course\management\helper::get_expanded_categories('');
          $catatlevel[] = array_shift($selectedparents);
          $catatlevel = array_unique($catatlevel);
  
          $listing = core_course_category::top()->get_children();
  
          $attributes = array(
                  'class' => 'ml-1 list-unstyled',
                  'role' => 'tree',
                  'aria-labelledby' => 'category-listing-title'
          );
  
          $html  = html_writer::start_div('category-listing card w-100');
          $html .= html_writer::tag('h3', get_string('categories'),
                  array('class' => 'card-header', 'id' => 'category-listing-title'));
          $html .= html_writer::start_div('card-body');
          $html .= $this->category_listing_actions($category);
          $html .= html_writer::start_tag('ul', $attributes);
          foreach ($listing as $listitem) {
              // Render each category in the listing.
              $subcategories = array();
              if (in_array($listitem->id, $catatlevel)) {
                  $subcategories = $listitem->get_children();
              }
              $html .= $this->category_listitem(
                      $listitem,
                      $subcategories,
                      $listitem->get_children_count(),
                      $selectedcategory,
                      $selectedparents
              );
          }
          $html .= html_writer::end_tag('ul');
          $html .= $this->category_bulk_actions($category);
          $html .= html_writer::end_div();
          $html .= html_writer::end_div();
          return $html;
      }
code_tokens: public function category_listing ( core_course_category $ category = null ) { if ( $ category === null ) { $ selectedparents = array ( ) ; $ selectedcategory = null ; } else { $ selectedparents = $ category -> get_parents ( ) ; $ selectedparents [ ] = $ category -> id ; $ selectedcategory = $ category -> id ; } $ catatlevel = \ core_course \ management \ helper :: get_expanded_categories ( '' ) ; $ catatlevel [ ] = array_shift ( $ selectedparents ) ; $ catatlevel = array_unique ( $ catatlevel ) ; $ listing = core_course_category :: top ( ) -> get_children ( ) ; $ attributes = array ( 'class' => 'ml-1 list-unstyled' , 'role' => 'tree' , 'aria-labelledby' => 'category-listing-title' ) ; $ html = html_writer :: start_div ( 'category-listing card w-100' ) ; $ html .= html_writer :: tag ( 'h3' , get_string ( 'categories' ) , array ( 'class' => 'card-header' , 'id' => 'category-listing-title' ) ) ; $ html .= html_writer :: start_div ( 'card-body' ) ; $ html .= $ this -> category_listing_actions ( $ category ) ; $ html .= html_writer :: start_tag ( 'ul' , $ attributes ) ; foreach ( $ listing as $ listitem ) { // Render each category in the listing. $ subcategories = array ( ) ; if ( in_array ( $ listitem -> id , $ catatlevel ) ) { $ subcategories = $ listitem -> get_children ( ) ; } $ html .= $ this -> category_listitem ( $ listitem , $ subcategories , $ listitem -> get_children_count ( ) , $ selectedcategory , $ selectedparents ) ; } $ html .= html_writer :: end_tag ( 'ul' ) ; $ html .= $ this -> category_bulk_actions ( $ category ) ; $ html .= html_writer :: end_div ( ) ; $ html .= html_writer :: end_div ( ) ; return $ html ; }
docstring: Presents a course category listing.
  
  @param core_course_category $category The currently selected category. Also the category to highlight in the listing.
  @return string
docstring_tokens: Presents a course category listing .