Moodle
  1. Moodle
  2. MDL-27532

Course reports should be able to store table data in course backup

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.0.4
    • Component/s: Backup
    • Labels:
      None
    • Testing Instructions:
      Hide

      Difficulty: Moderate (requires local install)

      1. No standard Moodle course report uses this facility. Consequently, to test it is necessary to 'fake' it. Unpack the attachment backup.zip and place the files in the new 'backup' folder inside course/report/log. (This backup folder should be at the same level as the existing db and lang folders.)

      2. Create a course with short name FROGTEST (the name is significant!). Add an activity such as a label. Back up the course using default settings.

      3. Restore the backup to a new course using default settings. On the last screen of restore (the one where it actually does the restore) you should notice some ugly test text with a heading 'Restoring!' and the id 13 and the variant 'ribbit'. [Now delete the restored course if you like.]

      4. Go back to the original course and change its short name to ZOMBIETEST. Now do the backup again using default settings.

      5. Restore the new backup to a new course. Verify that the test text shown above does not appear this time.

      6. For completeness, take a look at the restored course (main page) and check it appears OK.

      7. To clean up, delete the restored and created courses, and delete the superfluous 'backup' folder from within the coursereport/log code area.

      Show
      Difficulty: Moderate (requires local install) 1. No standard Moodle course report uses this facility. Consequently, to test it is necessary to 'fake' it. Unpack the attachment backup.zip and place the files in the new 'backup' folder inside course/report/log. (This backup folder should be at the same level as the existing db and lang folders.) 2. Create a course with short name FROGTEST (the name is significant!). Add an activity such as a label. Back up the course using default settings. 3. Restore the backup to a new course using default settings. On the last screen of restore (the one where it actually does the restore) you should notice some ugly test text with a heading 'Restoring!' and the id 13 and the variant 'ribbit'. [Now delete the restored course if you like.] 4. Go back to the original course and change its short name to ZOMBIETEST. Now do the backup again using default settings. 5. Restore the new backup to a new course. Verify that the test text shown above does not appear this time. 6. For completeness, take a look at the restored course (main page) and check it appears OK. 7. To clean up, delete the restored and created courses, and delete the superfluous 'backup' folder from within the coursereport/log code area.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Pull Master Branch:
      MDL-27532-master
    • Rank:
      17202

      Description

      Course reports (e.g. coursereport_xx, in course/report/xx) are allowed to have database tables etc. This works great.

      However, if there is any course-specific data in those tables, I could not find a way to back it up with the course.

      I would like to be able to back it up with the course. We added something similar for theme backup a little while ago.

      This would only give an extra ability to custom course report plugins which store some course-related data. As the plugins supplied with core Moodle do not store any data, this would not affect those plugins.

        Activity

        Hide
        Sam Marshall added a comment -

        Hopefully this simple implementation is OK. It permits course reports to have course-level settings only (I didn't add hooks at session level or whatever.)

        If/when this is integrated I will write documentation similar to http://docs.moodle.org/en/Development:Backup_2.0_theme_data

        Show
        Sam Marshall added a comment - Hopefully this simple implementation is OK. It permits course reports to have course-level settings only (I didn't add hooks at session level or whatever.) If/when this is integrated I will write documentation similar to http://docs.moodle.org/en/Development:Backup_2.0_theme_data
        Hide
        Sam Marshall added a comment -

        To explain the reasoning for the test code a bit in case it is not clear:

        1) 13 and 'ribbit' are the values that are stored in the backup file, so displaying them proves that the restore process is getting the values correctly.

        2) in order to test the process for including or not including the course report data in any particular backup, I made it include the backup data only if the course shortname contains the text 'FROG'. So the test checks that it does not put anything in the backup, when the course shortname doesn't have that text.

        Show
        Sam Marshall added a comment - To explain the reasoning for the test code a bit in case it is not clear: 1) 13 and 'ribbit' are the values that are stored in the backup file, so displaying them proves that the restore process is getting the values correctly. 2) in order to test the process for including or not including the course report data in any particular backup, I made it include the backup data only if the course shortname contains the text 'FROG'. So the test checks that it does not put anything in the backup, when the course shortname doesn't have that text.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Sam Marshall added a comment -

        thanks eloy, rebased.

        Show
        Sam Marshall added a comment - thanks eloy, rebased.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        looks perfect. About to integrate it. Just guessing if we can also backport this to 20_STABLE (we have done that for other plugins already).

        I'll cherrypick it back to 20_STABLE if you don't have anything against it.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - looks perfect. About to integrate it. Just guessing if we can also backport this to 20_STABLE (we have done that for other plugins already). I'll cherrypick it back to 20_STABLE if you don't have anything against it. TIA and ciao
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Done, integrated to master and backported to 20_STABLE by cherry-picking (after confirmation from Sam).

        Thanks and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Done, integrated to master and backported to 20_STABLE by cherry-picking (after confirmation from Sam). Thanks and ciao
        Hide
        Rajesh Taneja added a comment -

        Test Passed.
        Thanks for providing the enhancement

        Show
        Rajesh Taneja added a comment - Test Passed. Thanks for providing the enhancement
        Hide
        Eloy Lafuente (stronk7) added a comment -

        And this is now part of Moodle upstream, many thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - And this is now part of Moodle upstream, many thanks!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: