Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6527

Restore of local plugin tables with child items

$
0
0
by Enrique Castro.  

Hi,

I've been cleaning some customizations embedding them in a local plugin. This plugin defines tables to store additional details to core 'course', 'groups' and 'grade_categories' tables as needed by my University administrative systems. 

I've managed to get the backup of these data working. I have defined backup/restore classes using the course hook. All additional data is relevant at course level.

class backup_local_ulpgccore_plugin extends backup_local_plugin {
protected function define_course_plugin_structure() {

In this way I can get the backup performed and data stored in the .mbz file in the course/course.xml part. 

<course id="3" contextid="1336">
  <shortname>T00</shortname>
  ...
  <plugin_local_ulpgccore_course>
    <term>2</term>
    <credits>6.00</credits>
    <department>242</department>
    <ctype>ob</ctype>
    <groups>
      <group>
        <groupid>6</groupid>
        <faculty>251</faculty>
        <itemid>66</itemid>
      </group>
      <group>
        <groupid>7</groupid>
        <faculty>324</faculty>
        <itemid>77</itemid>
      </group>
    </groups>
    <grade_categories>
      <grade_category>
        <categoryid>3</categoryid>
        <lockedit>1</lockedit>
      </grade_category>
      <grade_category>
        <categoryid>4</categoryid>
        <lockedit>1</lockedit>
      </grade_category>
    </grade_categories>
  </plugin_local_ulpgccore_course>

I've defined the companion restore class to revover these data, but it is working only in part. The first data is recovered but child parts, group and grade_category, are not restored.

The restore class contain the structure

    protected function define_course_plugin_structure() {
        $paths = array();
        $elename = 'plugin_local_ulpgccore_course'; // This defines the postfix of 'process_*' below.
        $elepath = $this->get_pathfor('/');
        $paths[] = new restore_path_element($elename, $elepath);
        $paths[] = new restore_path_element('plugin_local_ulpgccore_grade_category', $elepath.'/grade_categories/grade_category');
        if($groupinfo = $this->get_setting_value('groups')) {
            $paths[] = new restore_path_element('plugin_local_ulpgccore_group', $elepath.'/groups/group');
        }
        return $paths; // And we return the interesting paths.
    }
public function process_plugin_local_ulpgccore_course($data)
public function process_plugin_local_ulpgccore_grade_category($data)
public function process_plugin_local_ulpgccore_group($data)

The process_ ... method are required, if name changed the restore task aborts with a message indicating that a required method is missing.

However, when present those child methods the restore procedure proceed to completion but methods for child items are never executed. Only 'process_plugin_local_ulpgccore_course' gets executed and data is restored, the other two methods never get executed, and those data under 'groups' or 'grade_category' are not restored.

So, I'm missing something but I cannot figure. Any help is welcome!


Viewing all articles
Browse latest Browse all 6527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>