original_string: public static function get_blocks_branch(\context $coursecontext) {
          global $DB;
  
          if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
              throw new \coding_exception('A course context should be provided');
          }
  
          $branches = [];
  
          $children = $coursecontext->get_child_contexts();
          foreach ($children as $childcontext) {
  
              if ($childcontext->contextlevel !== CONTEXT_BLOCK) {
                  continue;
              }
  
              $blockinstance = block_instance_by_id($childcontext->instanceid);
              $displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $childcontext]));
              $branches[] = self::complete([
                  'text' => $displayname,
                  'contextid' => $childcontext->id,
              ]);
  
          }
  
          return $branches;
      }
code: public static function get_blocks_branch(\context $coursecontext) {
          global $DB;
  
          if ($coursecontext->contextlevel !== CONTEXT_COURSE) {
              throw new \coding_exception('A course context should be provided');
          }
  
          $branches = [];
  
          $children = $coursecontext->get_child_contexts();
          foreach ($children as $childcontext) {
  
              if ($childcontext->contextlevel !== CONTEXT_BLOCK) {
                  continue;
              }
  
              $blockinstance = block_instance_by_id($childcontext->instanceid);
              $displayname = shorten_text(format_string($blockinstance->get_title(), true, ['context' => $childcontext]));
              $branches[] = self::complete([
                  'text' => $displayname,
                  'contextid' => $childcontext->id,
              ]);
  
          }
  
          return $branches;
      }
code_tokens: public static function get_blocks_branch ( \ context $ coursecontext ) { global $ DB ; if ( $ coursecontext -> contextlevel !== CONTEXT_COURSE ) { throw new \ coding_exception ( 'A course context should be provided' ) ; } $ branches = [ ] ; $ children = $ coursecontext -> get_child_contexts ( ) ; foreach ( $ children as $ childcontext ) { if ( $ childcontext -> contextlevel !== CONTEXT_BLOCK ) { continue ; } $ blockinstance = block_instance_by_id ( $ childcontext -> instanceid ) ; $ displayname = shorten_text ( format_string ( $ blockinstance -> get_title ( ) , true , [ 'context' => $ childcontext ] ) ) ; $ branches [ ] = self :: complete ( [ 'text' => $ displayname , 'contextid' => $ childcontext -> id , ] ) ; } return $ branches ; }
docstring: Gets the blocks branch for the provided course.
  
  @param \context $coursecontext
  @return null
docstring_tokens: Gets the blocks branch for the provided course .