original_string: private function _save() {
          if ($this->timeenrolled === null) {
              $this->timeenrolled = 0;
          }
  
          $result = false;
          // Save record
          if ($this->id) {
              $result = $this->update();
          } else {
              // Make sure reaggregate field is not null
              if (!$this->reaggregate) {
                  $this->reaggregate = 0;
              }
  
              // Make sure timestarted is not null
              if (!$this->timestarted) {
                  $this->timestarted = 0;
              }
  
              $result = $this->insert();
          }
  
          if ($result) {
              // Update the cached record.
              $cache = cache::make('core', 'coursecompletion');
              $data = $this->get_record_data();
              $key = $data->userid . '_' . $data->course;
              $cache->set($key, ['value' => $data]);
          }
  
          return $result;
      }
code: private function _save() {
          if ($this->timeenrolled === null) {
              $this->timeenrolled = 0;
          }
  
          $result = false;
          // Save record
          if ($this->id) {
              $result = $this->update();
          } else {
              // Make sure reaggregate field is not null
              if (!$this->reaggregate) {
                  $this->reaggregate = 0;
              }
  
              // Make sure timestarted is not null
              if (!$this->timestarted) {
                  $this->timestarted = 0;
              }
  
              $result = $this->insert();
          }
  
          if ($result) {
              // Update the cached record.
              $cache = cache::make('core', 'coursecompletion');
              $data = $this->get_record_data();
              $key = $data->userid . '_' . $data->course;
              $cache->set($key, ['value' => $data]);
          }
  
          return $result;
      }
code_tokens: private function _save ( ) { if ( $ this -> timeenrolled === null ) { $ this -> timeenrolled = 0 ; } $ result = false ; // Save record if ( $ this -> id ) { $ result = $ this -> update ( ) ; } else { // Make sure reaggregate field is not null if ( ! $ this -> reaggregate ) { $ this -> reaggregate = 0 ; } // Make sure timestarted is not null if ( ! $ this -> timestarted ) { $ this -> timestarted = 0 ; } $ result = $ this -> insert ( ) ; } if ( $ result ) { // Update the cached record. $ cache = cache :: make ( 'core' , 'coursecompletion' ) ; $ data = $ this -> get_record_data ( ) ; $ key = $ data -> userid . '_' . $ data -> course ; $ cache -> set ( $ key , [ 'value' => $ data ] ) ; } return $ result ; }
docstring: Save course completion status
  
  This method creates a course_completions record if none exists
  @access  private
  @return  bool
docstring_tokens: Save course completion status