original_string: protected function process_completion_defaults($data) {
          global $DB;
  
          $data = (array)$data;
          $oldid = $data['id'];
          unset($data['id']);
  
          // Find the module by name since id may be different in another site.
          if (!$mod = $DB->get_record('modules', ['name' => $data['modulename']])) {
              return;
          }
          unset($data['modulename']);
  
          // Find the existing record.
          $newid = $DB->get_field('course_completion_defaults', 'id',
              ['course' => $this->task->get_courseid(), 'module' => $mod->id]);
          if (!$newid) {
              $newid = $DB->insert_record('course_completion_defaults',
                  ['course' => $this->task->get_courseid(), 'module' => $mod->id] + $data);
          } else {
              $DB->update_record('course_completion_defaults', ['id' => $newid] + $data);
          }
  
          // Save id mapping for restoring associated events.
          $this->set_mapping('course_completion_defaults', $oldid, $newid);
      }
code: protected function process_completion_defaults($data) {
          global $DB;
  
          $data = (array)$data;
          $oldid = $data['id'];
          unset($data['id']);
  
          // Find the module by name since id may be different in another site.
          if (!$mod = $DB->get_record('modules', ['name' => $data['modulename']])) {
              return;
          }
          unset($data['modulename']);
  
          // Find the existing record.
          $newid = $DB->get_field('course_completion_defaults', 'id',
              ['course' => $this->task->get_courseid(), 'module' => $mod->id]);
          if (!$newid) {
              $newid = $DB->insert_record('course_completion_defaults',
                  ['course' => $this->task->get_courseid(), 'module' => $mod->id] + $data);
          } else {
              $DB->update_record('course_completion_defaults', ['id' => $newid] + $data);
          }
  
          // Save id mapping for restoring associated events.
          $this->set_mapping('course_completion_defaults', $oldid, $newid);
      }
code_tokens: protected function process_completion_defaults ( $ data ) { global $ DB ; $ data = ( array ) $ data ; $ oldid = $ data [ 'id' ] ; unset ( $ data [ 'id' ] ) ; // Find the module by name since id may be different in another site. if ( ! $ mod = $ DB -> get_record ( 'modules' , [ 'name' => $ data [ 'modulename' ] ] ) ) { return ; } unset ( $ data [ 'modulename' ] ) ; // Find the existing record. $ newid = $ DB -> get_field ( 'course_completion_defaults' , 'id' , [ 'course' => $ this -> task -> get_courseid ( ) , 'module' => $ mod -> id ] ) ; if ( ! $ newid ) { $ newid = $ DB -> insert_record ( 'course_completion_defaults' , [ 'course' => $ this -> task -> get_courseid ( ) , 'module' => $ mod -> id ] + $ data ) ; } else { $ DB -> update_record ( 'course_completion_defaults' , [ 'id' => $ newid ] + $ data ) ; } // Save id mapping for restoring associated events. $ this -> set_mapping ( 'course_completion_defaults' , $ oldid , $ newid ) ; }
docstring: Processor for path element 'completion_defaults'
  
  @param stdClass|array $data
docstring_tokens: Processor for path element completion_defaults