original_string: public function set_category_by_id($categoryid) {
          global $SITE;
          if (!is_null($this->_course)) {
              throw new coding_exception('Course has already been set. You cannot change the category now.');
          }
          if (is_array($this->_categories)) {
              throw new coding_exception('Course category has already been set. You cannot to change it now.');
          }
          $this->ensure_theme_not_set();
          $this->set_course($SITE);
          $this->load_category($categoryid);
          $this->set_context(context_coursecat::instance($categoryid));
      }
code: public function set_category_by_id($categoryid) {
          global $SITE;
          if (!is_null($this->_course)) {
              throw new coding_exception('Course has already been set. You cannot change the category now.');
          }
          if (is_array($this->_categories)) {
              throw new coding_exception('Course category has already been set. You cannot to change it now.');
          }
          $this->ensure_theme_not_set();
          $this->set_course($SITE);
          $this->load_category($categoryid);
          $this->set_context(context_coursecat::instance($categoryid));
      }
code_tokens: public function set_category_by_id ( $ categoryid ) { global $ SITE ; if ( ! is_null ( $ this -> _course ) ) { throw new coding_exception ( 'Course has already been set. You cannot change the category now.' ) ; } if ( is_array ( $ this -> _categories ) ) { throw new coding_exception ( 'Course category has already been set. You cannot to change it now.' ) ; } $ this -> ensure_theme_not_set ( ) ; $ this -> set_course ( $ SITE ) ; $ this -> load_category ( $ categoryid ) ; $ this -> set_context ( context_coursecat :: instance ( $ categoryid ) ) ; }
docstring: Set the course category this page belongs to manually.
  
  This automatically sets $PAGE->course to be the site course. You cannot
  use this method if you have already set $PAGE->course - in that case,
  the category must be the one that the course belongs to. This also
  automatically sets the page context to the category context.
  
  @param int $categoryid The id of the category to set.
  @throws coding_exception
docstring_tokens: Set the course category this page belongs to manually .