Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-75196

Improve mod_data link processing for backup

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_500_STABLE
    • MOODLE_500_STABLE
    • MDL-75196-main
    • Hide

      Automated tests:
      1. Run unit test mod_data\backup\encode_links_test::test_encode_links()

      Manual testing (this serves to test backup/restore with user data that is not covered by the unit test):
      1. Create a course
      2. Create a database activity
      3. Choose "Image gallery preset"
      4. Create a new entry and click on "Save"
      5. Copy the URL (should be the single entry URL following the pattern https://.../mod/data/view.php?d=xy&rid=abc).
      6. Create a label and insert

      7. Do a course backup including at least the database and the label and including user data.
      8. Restore the backup to a new course.
      9. Click the first link in the label. Confirm it points to the restored database.
      10. Click the second link in the label. Click on "Cancel". Confirm that you see the restored entry from step 4 in the restored database.

      Show
      Automated tests: 1. Run unit test mod_data\backup\encode_links_test::test_encode_links() Manual testing (this serves to test backup/restore with user data that is not covered by the unit test): 1. Create a course 2. Create a database activity 3. Choose "Image gallery preset" 4. Create a new entry and click on "Save" 5. Copy the URL (should be the single entry URL following the pattern https://.../mod/data/view.php?d=xy&rid=abc ). 6. Create a label and insert a link to the url from step 5 a link that is constructed like that from the url from step 5: Change https://.../mod/data/view.php?d=xy&rid=abc to https://.../mod/data/edit.php?d=xy&backto=ZZZ where ZZZ is https://.../mod/data/view.php?d=xy&rid=abc passed to urlencode (you can use https://www.urlencoder.org/ for that). 7. Do a course backup including at least the database and the label and including user data. 8. Restore the backup to a new course. 9. Click the first link in the label. Confirm it points to the restored database. 10. Click the second link in the label. Click on "Cancel". Confirm that you see the restored entry from step 4 in the restored database.
    • Hide

      Code verified against automated checks.

      Checked MDL-75196 using repository: https://github.com/sh-csg/moodle.git

      More information about this report

      Built on: Fri Feb 28 15:24:52 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-75196 using repository: https://github.com/sh-csg/moodle.git main (0 errors / 0 warnings) [branch: MDL-75196-main | CI Job ] More information about this report Built on: Fri Feb 28 15:24:52 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-75196 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18764/ PHPUnit (sqlsrv / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64278/ Behat (NonJS - boost and classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64279/ Behat (Firefox - boost / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64280/ Behat (Firefox - classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64281/ App tests (stable app version) / complete) Built on: Mon Mar 24 10:20:46 UTC 2025

      mod_data is used as a highly customizable activity. Courses and presets are widely shared between users.

      To hide some of the parts that might confuse from the students, trainers often set direct links to pages that allow to add an entry or something similar.

      If you do a course backup, these links do not completely get processed by the backup to link to the new id of the database or entry. This leads to an unnecessary manual workload for the trainers.

       

      Steps to reproduce:

      1. Create a course and a database activity.
      2. Choose "Image gallery preset" (this is just to speed up the test, behavior is the same for every database).
      3. Go to the "New entry" page and copy the url up to the part "?d=.." ("https://.../mod/data/edit.php?d=1")
      4. Add a label including a link to that page.
      5. Do a course backup including at least the database and the label.
      6. Restore the backup to a new course (this also happens if you restore to an existing course).
      7. Click the link in the label. It will point to the database activity in the "old" course instead of the new one.

       

      Expected behavior:

      The link should be processed by backup/restore to point to the restored database activity (as other links, e.g. to view.php do).

       

      Proposed solution:

      Add new rules to backup / restore in mod_data to match at least the most widely used functions.

      Patch:

      Adds support for links to

      • view page of the database (list and single view)
      • edit page of the database (to add new entries)
      • index page showing all databases in the course

      The links are also supported when using the urlencode() function. This is necessary to support the backurl parameter of edit.php.

            stefan.hanauska Stefan Hanauska
            stefan.hanauska Stefan Hanauska
            Stephan Robotta Stephan Robotta
            Ferran Recio Ferran Recio
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            9 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.