original_string: public function is_enabled($cm = null) {
          global $CFG, $DB;
  
          // First check global completion
          if (!isset($CFG->enablecompletion) || $CFG->enablecompletion == COMPLETION_DISABLED) {
              return COMPLETION_DISABLED;
          }
  
          // Load data if we do not have enough
          if (!isset($this->course->enablecompletion)) {
              $this->course = get_course($this->course_id);
          }
  
          // Check course completion
          if ($this->course->enablecompletion == COMPLETION_DISABLED) {
              return COMPLETION_DISABLED;
          }
  
          // If there was no $cm and we got this far, then it's enabled
          if (!$cm) {
              return COMPLETION_ENABLED;
          }
  
          // Return course-module completion value
          return $cm->completion;
      }
code: public function is_enabled($cm = null) {
          global $CFG, $DB;
  
          // First check global completion
          if (!isset($CFG->enablecompletion) || $CFG->enablecompletion == COMPLETION_DISABLED) {
              return COMPLETION_DISABLED;
          }
  
          // Load data if we do not have enough
          if (!isset($this->course->enablecompletion)) {
              $this->course = get_course($this->course_id);
          }
  
          // Check course completion
          if ($this->course->enablecompletion == COMPLETION_DISABLED) {
              return COMPLETION_DISABLED;
          }
  
          // If there was no $cm and we got this far, then it's enabled
          if (!$cm) {
              return COMPLETION_ENABLED;
          }
  
          // Return course-module completion value
          return $cm->completion;
      }
code_tokens: public function is_enabled ( $ cm = null ) { global $ CFG , $ DB ; // First check global completion if ( ! isset ( $ CFG -> enablecompletion ) || $ CFG -> enablecompletion == COMPLETION_DISABLED ) { return COMPLETION_DISABLED ; } // Load data if we do not have enough if ( ! isset ( $ this -> course -> enablecompletion ) ) { $ this -> course = get_course ( $ this -> course_id ) ; } // Check course completion if ( $ this -> course -> enablecompletion == COMPLETION_DISABLED ) { return COMPLETION_DISABLED ; } // If there was no $cm and we got this far, then it's enabled if ( ! $ cm ) { return COMPLETION_ENABLED ; } // Return course-module completion value return $ cm -> completion ; }
docstring: Checks whether completion is enabled in a particular course and possibly
  activity.
  
  @param stdClass|cm_info $cm Course-module object. If not specified, returns the course
  completion enable state.
  @return mixed COMPLETION_ENABLED or COMPLETION_DISABLED (==0) in the case of
  site and course; COMPLETION_TRACKING_MANUAL, _AUTOMATIC or _NONE (==0)
  for a course-module.
docstring_tokens: Checks whether completion is enabled in a particular course and possibly activity .