General developer forum

Help for backup/restore Moodle 2

Richard Jones
Help for backup/restore Moodle 2
Particularly helpful MoodlersPlugin developersTesters


I've got a basic resource plugin that has multiple subpages (so two database tables).  I have the backup xml file created (at least it looks ok):

<multipage id="10">
    <name>Test multipage</name>
    <intro>&lt;p&gt;Domestic pets and their habits.&lt;/p&gt;&lt;p&gt;&lt;img src="" alt="pet shop boys" width="424" height="564" class="img-responsive atto_image_button_text-bottom"&gt;&lt;br&gt;&lt;/p&gt;</intro>
    <title>All about Pets</title>
      <page id="25">
        <pagecontents>&lt;p&gt;Dogs are...&lt;/p&gt;&lt;p&gt;&lt;img src="" alt="dog" width="274" height="378" class="img-responsive atto_image_button_text-bottom"&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;... handsome.&lt;/p&gt;</pagecontents>

The module instance (10) is restoring OK into the main table with the next id in the auto sequence (yay!) but the subpages are not being restored properly.

I suspect my encoding/decoding but I'm not sure how to do that.  Eg encoding rule for edit_page:

 // Action for editing a page. Prints an HTML form.
        $pattern = '#'.$base.'/edit_page\.php\?id=([0-9]+)#';
        $replacement = '$@MULTIPAGEEDITPAGE*$1@$';
        $content = preg_replace($pattern, $replacement, $content);

Decoding rule:

$rules[] = new restore_decode_rule('MULTIPAGEEDITPAGE', '/mod/multipage/edit_page.php?id=$1', 'course_module');

Do I need to explicitly supply all the required parameters that go with an edit page in both rules?  Or is it something else - I feel I don't have a good handle on this part and the doc is a little lacking.  The most similar is the lesson module but that's quite a complex example.

The actual style of the url is:


So do I need placeholders for all of those params?



Average of ratings: -