Help for backup/restore Moodle 2

Help for backup/restore Moodle 2

by Richard Jones -
Number of replies: 0
Picture of Plugin developers Picture of Testers

Hi

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="https://moodle.org/pluginfile.php/114/mod_forum/post/1487796/Savannah%20Cat%20Shoppe%20Pic%201.jpg" alt="pet shop boys" width="424" height="564" class="img-responsive atto_image_button_text-bottom"&gt;&lt;br&gt;&lt;/p&gt;</intro>
    <introformat>1</introformat>
    <title>All about Pets</title>
    <timecreated>1523568038</timecreated>
    <timemodified>0</timemodified>
    <grade>100</grade>
    <pages>
      <page id="25">
        <multipageid>10</multipageid>
        <sequence>1</sequence>
        <prevpageid>24</prevpageid>
        <nextpageid>25</nextpageid>
        <pagetitle>Dogs</pagetitle>
        <pagecontents>&lt;p&gt;Dogs are...&lt;/p&gt;&lt;p&gt;&lt;img src="https://moodle.org/pluginfile.php/114/mod_forum/post/1487796/Dog%20Boxer.jpg" 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>
        <pagecontentsformat>1</pagecontentsformat>
        <timecreated>1523568171</timecreated>
        <timemodified>1523571483</timemodified>
      </page>

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:

http://localhost/dev2moodle/mod/multipage/edit_page.php?courseid=3&multipageid=10&sequence=2&pageid=26

So do I need placeholders for all of those params?

Thanks

Richard

Average of ratings: -