original_string: public function after_restore() {
          global $DB;
  
          // Get the blockid.
          $blockid = $this->get_blockid();
  
          if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
              $config = unserialize(base64_decode($configdata));
              if (!empty($config->activityparentid)) {
                  // Get the mapping and replace it in config.
                  if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
                      $config->activityparent, $config->activityparentid)) {
  
                      // Update the parent module id (the id from mdl_quiz etc...)
                      $config->activityparentid = $mapping->newitemid;
  
                      // Get the grade_items record to update the activitygradeitemid.
                      $info = $DB->get_record('grade_items',
                              array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));
  
                      // Update the activitygradeitemid the id from the grade_items table.
                      $config->activitygradeitemid = $info->id;
  
                      // Encode and save the config.
                      $configdata = base64_encode(serialize($config));
                      $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
                  }
              }
          }
      }
code: public function after_restore() {
          global $DB;
  
          // Get the blockid.
          $blockid = $this->get_blockid();
  
          if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
              $config = unserialize(base64_decode($configdata));
              if (!empty($config->activityparentid)) {
                  // Get the mapping and replace it in config.
                  if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(),
                      $config->activityparent, $config->activityparentid)) {
  
                      // Update the parent module id (the id from mdl_quiz etc...)
                      $config->activityparentid = $mapping->newitemid;
  
                      // Get the grade_items record to update the activitygradeitemid.
                      $info = $DB->get_record('grade_items',
                              array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));
  
                      // Update the activitygradeitemid the id from the grade_items table.
                      $config->activitygradeitemid = $info->id;
  
                      // Encode and save the config.
                      $configdata = base64_encode(serialize($config));
                      $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
                  }
              }
          }
      }
code_tokens: public function after_restore ( ) { global $ DB ; // Get the blockid. $ blockid = $ this -> get_blockid ( ) ; if ( $ configdata = $ DB -> get_field ( 'block_instances' , 'configdata' , array ( 'id' => $ blockid ) ) ) { $ config = unserialize ( base64_decode ( $ configdata ) ) ; if ( ! empty ( $ config -> activityparentid ) ) { // Get the mapping and replace it in config. if ( $ mapping = restore_dbops :: get_backup_ids_record ( $ this -> get_restoreid ( ) , $ config -> activityparent , $ config -> activityparentid ) ) { // Update the parent module id (the id from mdl_quiz etc...) $ config -> activityparentid = $ mapping -> newitemid ; // Get the grade_items record to update the activitygradeitemid. $ info = $ DB -> get_record ( 'grade_items' , array ( 'iteminstance' => $ config -> activityparentid , 'itemmodule' => $ config -> activityparent ) ) ; // Update the activitygradeitemid the id from the grade_items table. $ config -> activitygradeitemid = $ info -> id ; // Encode and save the config. $ configdata = base64_encode ( serialize ( $ config ) ) ; $ DB -> set_field ( 'block_instances' , 'configdata' , $ configdata , array ( 'id' => $ blockid ) ) ; } } } }
docstring: This function, executed after all the tasks in the plan
  have been executed, will perform the recode of the
  target activity for the block. This must be done here
  and not in normal execution steps because the activity
  can be restored after the block.
docstring_tokens: This function executed after all the tasks in the plan have been executed will perform the recode of the target activity for the block . This must be done here and not in normal execution steps because the activity can be restored after the block .