original_string: public static function get_course_blocks($courseid, $returncontents = false) {
          global $PAGE;
  
          $warnings = array();
          $params = self::validate_parameters(self::get_course_blocks_parameters(),
              ['courseid' => $courseid, 'returncontents' => $returncontents]);
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          // Specific layout for frontpage course.
          if ($course->id == SITEID) {
              $PAGE->set_pagelayout('frontpage');
              $PAGE->set_pagetype('site-index');
          } else {
              $PAGE->set_pagelayout('course');
              // Ensure course format is set (view course/view.php).
              $course->format = course_get_format($course)->get_format();
              $PAGE->set_pagetype('course-view-' . $course->format);
          }
  
          $allblocks = self::get_all_current_page_blocks(false, $params['returncontents']);
  
          return array(
              'blocks' => $allblocks,
              'warnings' => $warnings
          );
      }
code: public static function get_course_blocks($courseid, $returncontents = false) {
          global $PAGE;
  
          $warnings = array();
          $params = self::validate_parameters(self::get_course_blocks_parameters(),
              ['courseid' => $courseid, 'returncontents' => $returncontents]);
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          // Specific layout for frontpage course.
          if ($course->id == SITEID) {
              $PAGE->set_pagelayout('frontpage');
              $PAGE->set_pagetype('site-index');
          } else {
              $PAGE->set_pagelayout('course');
              // Ensure course format is set (view course/view.php).
              $course->format = course_get_format($course)->get_format();
              $PAGE->set_pagetype('course-view-' . $course->format);
          }
  
          $allblocks = self::get_all_current_page_blocks(false, $params['returncontents']);
  
          return array(
              'blocks' => $allblocks,
              'warnings' => $warnings
          );
      }
code_tokens: public static function get_course_blocks ( $ courseid , $ returncontents = false ) { global $ PAGE ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_course_blocks_parameters ( ) , [ 'courseid' => $ courseid , 'returncontents' => $ returncontents ] ) ; $ course = get_course ( $ params [ 'courseid' ] ) ; $ context = context_course :: instance ( $ course -> id ) ; self :: validate_context ( $ context ) ; // Specific layout for frontpage course. if ( $ course -> id == SITEID ) { $ PAGE -> set_pagelayout ( 'frontpage' ) ; $ PAGE -> set_pagetype ( 'site-index' ) ; } else { $ PAGE -> set_pagelayout ( 'course' ) ; // Ensure course format is set (view course/view.php). $ course -> format = course_get_format ( $ course ) -> get_format ( ) ; $ PAGE -> set_pagetype ( 'course-view-' . $ course -> format ) ; } $ allblocks = self :: get_all_current_page_blocks ( false , $ params [ 'returncontents' ] ) ; return array ( 'blocks' => $ allblocks , 'warnings' => $ warnings ) ; }
docstring: Returns blocks information for a course.
  
  @param int $courseid The course id
  @param bool $returncontents Whether to return the block contents
  @return array Blocks list and possible warnings
  @throws moodle_exception
  @since Moodle 3.3
docstring_tokens: Returns blocks information for a course .