original_string: public function mark_complete($timecomplete = null) {
          global $USER;
  
          // Never change a completion time.
          if ($this->timecompleted) {
              return;
          }
  
          // Use current time if nothing supplied.
          if (!$timecomplete) {
              $timecomplete = time();
          }
  
          // Set time complete.
          $this->timecompleted = $timecomplete;
  
          // Save record.
          if ($result = $this->_save()) {
              $data = $this->get_record_data();
              \core\event\course_completed::create_from_completion($data)->trigger();
          }
  
          return $result;
      }
code: public function mark_complete($timecomplete = null) {
          global $USER;
  
          // Never change a completion time.
          if ($this->timecompleted) {
              return;
          }
  
          // Use current time if nothing supplied.
          if (!$timecomplete) {
              $timecomplete = time();
          }
  
          // Set time complete.
          $this->timecompleted = $timecomplete;
  
          // Save record.
          if ($result = $this->_save()) {
              $data = $this->get_record_data();
              \core\event\course_completed::create_from_completion($data)->trigger();
          }
  
          return $result;
      }
code_tokens: public function mark_complete ( $ timecomplete = null ) { global $ USER ; // Never change a completion time. if ( $ this -> timecompleted ) { return ; } // Use current time if nothing supplied. if ( ! $ timecomplete ) { $ timecomplete = time ( ) ; } // Set time complete. $ this -> timecompleted = $ timecomplete ; // Save record. if ( $ result = $ this -> _save ( ) ) { $ data = $ this -> get_record_data ( ) ; \ core \ event \ course_completed :: create_from_completion ( $ data ) -> trigger ( ) ; } return $ result ; }
docstring: Mark this user complete in this course
  
  This generally happens when the required completion criteria
  in the course are complete.
  
  @param integer $timecomplete Time completed (optional)
  @return void
docstring_tokens: Mark this user complete in this course