original_string: public function calculate_sample($sampleid, $sampleorigin, $notusedstarttime = false, $notusedendtime = false) {
  
          $course = $this->retrieve('course', $sampleid);
  
          // It may not be available, but if it is the indicator checks if completion is enabled for the cm.
          $cm = $this->retrieve('course_modules', $sampleid);
  
          $completion = new \completion_info($course);
  
          if (!$completion->is_enabled($cm)) {
              $value = self::get_min_value();
          } else if (!$cm && !$completion->has_criteria()) {
              // Course completion enabled with no criteria counts as nothing.
              $value = self::get_min_value();
          } else {
              $value = self::get_max_value();
          }
          return $value;
      }
code: public function calculate_sample($sampleid, $sampleorigin, $notusedstarttime = false, $notusedendtime = false) {
  
          $course = $this->retrieve('course', $sampleid);
  
          // It may not be available, but if it is the indicator checks if completion is enabled for the cm.
          $cm = $this->retrieve('course_modules', $sampleid);
  
          $completion = new \completion_info($course);
  
          if (!$completion->is_enabled($cm)) {
              $value = self::get_min_value();
          } else if (!$cm && !$completion->has_criteria()) {
              // Course completion enabled with no criteria counts as nothing.
              $value = self::get_min_value();
          } else {
              $value = self::get_max_value();
          }
          return $value;
      }
code_tokens: public function calculate_sample ( $ sampleid , $ sampleorigin , $ notusedstarttime = false , $ notusedendtime = false ) { $ course = $ this -> retrieve ( 'course' , $ sampleid ) ; // It may not be available, but if it is the indicator checks if completion is enabled for the cm. $ cm = $ this -> retrieve ( 'course_modules' , $ sampleid ) ; $ completion = new \ completion_info ( $ course ) ; if ( ! $ completion -> is_enabled ( $ cm ) ) { $ value = self :: get_min_value ( ) ; } else if ( ! $ cm && ! $ completion -> has_criteria ( ) ) { // Course completion enabled with no criteria counts as nothing. $ value = self :: get_min_value ( ) ; } else { $ value = self :: get_max_value ( ) ; } return $ value ; }
docstring: Is completion enabled? Work both with courses and activities.
  
  @param int $sampleid
  @param string $sampleorigin
  @param int|false $notusedstarttime
  @param int|false $notusedendtime
  @return float
docstring_tokens: Is completion enabled? Work both with courses and activities .