Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2
    • Component/s: Backup
    • Labels:
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      254

      Description

      Right now there isn't support for course formats in 2.0 backup/restore.

      Potentially, attached to course (one new task). Both backup of structures AND encoding links.

      1. 001-backup-course-format.patch
        29 kB
        Brandon Turner
      2. 002-backup-course-format-section.patch
        10 kB
        Brandon Turner

        Activity

        Hide
        Brandon Turner added a comment -

        Please consider these two patches for implementing course format backup and restore. If these don't fit well in the current backup strategy, please let me know how I might be able to help refactor.

        001-backup-course-format.patch
        This adds support for backing up course formats. This is similar to how activity modules behave. Each course format extends the backup_format_task and restore_format_task classes. To indicate that the course format supports backup/restore, a callback_xxx_uses_backup method is added to course/format/xxx/lib.php.

        002-backup-course-format-section.patch
        In our custom course format we maintain a table that stores extra data for each section in the course. I found it hard to backup using the strategy in the first patch because upon restore, none of the sections had been restored prior to restoring the course format. Since we need a reference to each new section number, this was problematic.

        I've attempted to address this in the second patch. I modified the factory methods to allow easily overriding the backup_section_task and restore_section_task classes at the course format level. Course formats must add a callback_xxx_uses_section_backup method to /course/format/xxx/lib.php to indicate they support this type of backup. Formats can support both regular and section-level backups simultaneously.

        Show
        Brandon Turner added a comment - Please consider these two patches for implementing course format backup and restore. If these don't fit well in the current backup strategy, please let me know how I might be able to help refactor. 001-backup-course-format.patch This adds support for backing up course formats. This is similar to how activity modules behave. Each course format extends the backup_format_task and restore_format_task classes. To indicate that the course format supports backup/restore, a callback_xxx_uses_backup method is added to course/format/xxx/lib.php . 002-backup-course-format-section.patch In our custom course format we maintain a table that stores extra data for each section in the course. I found it hard to backup using the strategy in the first patch because upon restore, none of the sections had been restored prior to restoring the course format. Since we need a reference to each new section number, this was problematic. I've attempted to address this in the second patch. I modified the factory methods to allow easily overriding the backup_section_task and restore_section_task classes at the course format level. Course formats must add a callback_xxx_uses_section_backup method to /course/format/xxx/lib.php to indicate they support this type of backup. Formats can support both regular and section-level backups simultaneously.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi Brandon,

        interesting patches... will be working on this in 1-2 weeks, once I finish all the "core" backup/restore related tasks properly.

        Initially, instead of using a new task type I was planning to use simpler plugin support, similar to the subpluggins support used by the workshop module or by the assignments one.

        So it will be, simply, a matter of adding some "plugin points" in the backup (and restore) of course.xml. Perhaps better than introducing a whole task for "just" backup course formats. I'm tiding-up plugins support right now (to be used by another part of the backup - question types) and once implemented... I think it will be really easy to use exactly the same for backup course formats.

        Lets see how that evolves along the next days... depending of how I get it working with questions... we'll decide to follow the (your) task approach or the plugins one.

        Thanks a lot, tty soon... ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi Brandon, interesting patches... will be working on this in 1-2 weeks, once I finish all the "core" backup/restore related tasks properly. Initially, instead of using a new task type I was planning to use simpler plugin support, similar to the subpluggins support used by the workshop module or by the assignments one. So it will be, simply, a matter of adding some "plugin points" in the backup (and restore) of course.xml. Perhaps better than introducing a whole task for "just" backup course formats. I'm tiding-up plugins support right now (to be used by another part of the backup - question types) and once implemented... I think it will be really easy to use exactly the same for backup course formats. Lets see how that evolves along the next days... depending of how I get it working with questions... we'll decide to follow the (your) task approach or the plugins one. Thanks a lot, tty soon... ciao
        Hide
        Brandon Turner added a comment -

        Eloy,

        Great, I look forward to seeing the plugin approach.

        Just wondering, do you have any suggestions on how best to backup custom section data that a course format saves? Our course format has an additional table (one-to-one relationship with the course_sections table) where we store extra data per section. Without something like my second patch, I'm trying to get an idea of how best to backup and restore this.

        Show
        Brandon Turner added a comment - Eloy, Great, I look forward to seeing the plugin approach. Just wondering, do you have any suggestions on how best to backup custom section data that a course format saves? Our course format has an additional table (one-to-one relationship with the course_sections table) where we store extra data per section. Without something like my second patch, I'm trying to get an idea of how best to backup and restore this.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Uhm,

        I think the plugins thing can be the answer for that... as far as it allows to specify different places in the structures where plugins information will be processed. For example, see the workshop for subplugins (not plugins but 99% similar) adding structures to be backup & restore at different places.

        So, I think it will be really easy to add hooks both at course and section level in order to process course_format information. Really easy.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Uhm, I think the plugins thing can be the answer for that... as far as it allows to specify different places in the structures where plugins information will be processed. For example, see the workshop for subplugins (not plugins but 99% similar) adding structures to be backup & restore at different places. So, I think it will be really easy to add hooks both at course and section level in order to process course_format information. Really easy. Ciao
        Hide
        Alexey Guseynov added a comment -

        Brandon, than you to your patch. I need this functionality too.
        And I'm a little bit frustrated, that this issue seems to be forgotten.

        I would like to notice, that /course/format/README.txt still tells, that you should create backuplib.php in format directory. And there is still backup/backuplib.php which uses this uproach.
        But it also seems, that backup/backuplib.php is newer used by any code in moodle 2.0.
        May be this files should be removed/corrected so as not to force developers to try old method and read sources to understand, that it is not supported any more?

        Show
        Alexey Guseynov added a comment - Brandon, than you to your patch. I need this functionality too. And I'm a little bit frustrated, that this issue seems to be forgotten. I would like to notice, that /course/format/README.txt still tells, that you should create backuplib.php in format directory. And there is still backup/backuplib.php which uses this uproach. But it also seems, that backup/backuplib.php is newer used by any code in moodle 2.0. May be this files should be removed/corrected so as not to force developers to try old method and read sources to understand, that it is not supported any more?
        Hide
        Jenny Gray added a comment -

        Eloy - what's your current thinking on this? Is there anything we can do to help advance this functionality?

        Show
        Jenny Gray added a comment - Eloy - what's your current thinking on this? Is there anything we can do to help advance this functionality?
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi,

        sorry by the delay (and thanks for pinging me, Jenny).

        As commented above, now that the plugins support is working completely, I think it's really easy to add support for course_format plugins in backup & restore. For a working example, just take a look to any questions.xml file in any 2.0 backup, that is using already the plugins stuff.

        My main concern is about to agree the places where that course_format information will be allowed (aka, the hooks to implement).

        I think it's 100% logical to allow course_format plugin information to be added to:

        course/course.xml

        <?xml version="1.0" encoding="UTF-8"?>
        <course id="6" contextid="23">
          <shortname>TC</shortname>
          <fullname>Test Course</fullname>
          ...
          ...
          <plugin_format_MYFORMAT_course>
            // The course-related information goes here
          </plugin_format_MYFORMAT_course>
        </course>
        

        and potentially, also to:

        sections/section_XX/section.xml

        <?xml version="1.0" encoding="UTF-8"?>
        <section id="396">
          <number>0</number>
          <name>$@NULL@$</name>
          ...
          ...
          <plugin_format_MYFORMAT_section>
            // The section-related information goes here
          </plugin_format_MYFORMAT_section>
        </section>
        

        Questions:
        a) Do you think we need to be able to "hook" course formats information in other places?
        b) Do course formats need support for own 2.0 files/fileareas or are them just XML?

        Finally it would be interesting to have some real 2.0 course format available (having information to backup & restore) in order to implement the support using it? Anybody has that? (note this is not a must but a good thing to have).

        Comments are welcome, once we agree I think (hopping not being wrong) that we can develop this in 2-3 days.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi, sorry by the delay (and thanks for pinging me, Jenny). As commented above, now that the plugins support is working completely, I think it's really easy to add support for course_format plugins in backup & restore. For a working example, just take a look to any questions.xml file in any 2.0 backup, that is using already the plugins stuff. My main concern is about to agree the places where that course_format information will be allowed (aka, the hooks to implement). I think it's 100% logical to allow course_format plugin information to be added to: course/course.xml <?xml version= "1.0" encoding= "UTF-8" ?> <course id= "6" contextid= "23" > <shortname>TC</shortname> <fullname>Test Course</fullname> ... ... <plugin_format_MYFORMAT_course> // The course-related information goes here </plugin_format_MYFORMAT_course> </course> and potentially, also to: sections/section_XX/section.xml <?xml version= "1.0" encoding= "UTF-8" ?> <section id= "396" > <number>0</number> <name>$@NULL@$</name> ... ... <plugin_format_MYFORMAT_section> // The section-related information goes here </plugin_format_MYFORMAT_section> </section> Questions: a) Do you think we need to be able to "hook" course formats information in other places? b) Do course formats need support for own 2.0 files/fileareas or are them just XML? Finally it would be interesting to have some real 2.0 course format available (having information to backup & restore) in order to implement the support using it? Anybody has that? (note this is not a must but a good thing to have). Comments are welcome, once we agree I think (hopping not being wrong) that we can develop this in 2-3 days. TIA and ciao
        Hide
        Jenny Gray added a comment -

        Hi Eloy, thanks for picking this up again.

        I 100% agree that course/course.xml and sections/section_xx/section.xml are the places for course_format information to be added.

        I do have a table in my course format which has coursemodule information in it, but I think that's pretty unusual.

        I don't have any need for course format files. Again that seems pretty unusual, but the wider community may be able to advise. There's only a few course formats in the plugin database I think.

        I would be happy to test with you using the OU's studyplan course format so that you can generate some data. Would you like a patch?

        Show
        Jenny Gray added a comment - Hi Eloy, thanks for picking this up again. I 100% agree that course/course.xml and sections/section_xx/section.xml are the places for course_format information to be added. I do have a table in my course format which has coursemodule information in it, but I think that's pretty unusual. I don't have any need for course format files. Again that seems pretty unusual, but the wider community may be able to advise. There's only a few course formats in the plugin database I think. I would be happy to test with you using the OU's studyplan course format so that you can generate some data. Would you like a patch?
        Hide
        Jenny Gray added a comment -

        Eloy - this is the OU course format I'm working on, may be helpful for testing course format backup and restore.

        Show
        Jenny Gray added a comment - Eloy - this is the OU course format I'm working on, may be helpful for testing course format backup and restore.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Thanks Jenny, for sure having that real course format will help. Working on it now.

        Show
        Eloy Lafuente (stronk7) added a comment - Thanks Jenny, for sure having that real course format will help. Working on it now.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Hi,

        after some iterations with Jenny (big thanks!), I've completed the implementation of the course formats backup & restore, trying it with the studyplan.zip course format that is attached above. It was great to have that plugin, because it is a complex one and, at the end it has allowed us to complete the support covering a lot of situations.

        So:

        1) Here you can find the current code: https://github.com/stronk7/moodle/compare/master...MDL-22146_backup_course_format_wip

        2) Attached above, you can find the backup & restore implementation for the studyplan course format (studyplan_backup.zip). It can be used as reference for building support in other formats.

        3) I'll be performing a lot of tests along the next days aiming to send the implementation upstream next Monday so, if someone wants to take a look, try it, comment... today is the day!

        Hope it will be useful for you, crazy course-format hackers! Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Hi, after some iterations with Jenny (big thanks!), I've completed the implementation of the course formats backup & restore, trying it with the studyplan.zip course format that is attached above. It was great to have that plugin, because it is a complex one and, at the end it has allowed us to complete the support covering a lot of situations. So: 1) Here you can find the current code: https://github.com/stronk7/moodle/compare/master...MDL-22146_backup_course_format_wip 2) Attached above, you can find the backup & restore implementation for the studyplan course format (studyplan_backup.zip). It can be used as reference for building support in other formats. 3) I'll be performing a lot of tests along the next days aiming to send the implementation upstream next Monday so, if someone wants to take a look, try it, comment... today is the day! Hope it will be useful for you, crazy course-format hackers! Ciao
        Hide
        Jenny Gray added a comment -

        Not sure how I feel about being a crazy course-format hacker!

        But, I owe you a massive THANK YOU. I've done some limited testing of the new code i.e. run backup, checked xml files to see everything I expect is in there, run restore to new course, checked everything is still set in new course. So far so good.

        For the sake of the others - you need to make sure you test if there's an entry already in the course format db tables if you restore into an existing course. That's the only bit left to sort out for me

        Show
        Jenny Gray added a comment - Not sure how I feel about being a crazy course-format hacker! But, I owe you a massive THANK YOU. I've done some limited testing of the new code i.e. run backup, checked xml files to see everything I expect is in there, run restore to new course, checked everything is still set in new course. So far so good. For the sake of the others - you need to make sure you test if there's an entry already in the course format db tables if you restore into an existing course. That's the only bit left to sort out for me
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Sent to integration as PULL-266.

        Resolving this as fixed!

        Show
        Eloy Lafuente (stronk7) added a comment - Sent to integration as PULL-266. Resolving this as fixed!
        Hide
        Helen Foster added a comment -

        Code included in latest 2.0.1+ weekly. Thanks everyone.

        Show
        Helen Foster added a comment - Code included in latest 2.0.1+ weekly. Thanks everyone.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: