Moodle

Relinking itemnumber

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.3
  • Fix Version/s: 2.0.8
  • Component/s: Backup
  • Labels:
    None
  • Difficulty:
    Moderate
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

The gradebook API offers the use of itemnumber for when an activity has multiple graded items in a single instance. My understanding is that this has to be a unique ID, like one from a table used by the activity module. On restore though, this value is not relinked, but rather stays set to the original value in the backup file. Using a non-unique ID is not an option as backups could conflict when being restored to another site.

The solution that first came to mind is to write up a new restore method hook that is stored in mod/modname/restorelib.php that has the sole purpose of relinking this ID to a new one.

  1. restorelib.patch
    24/Dec/08 5:09 AM
    1 kB
    Mark Nielsen
  2. restorelib.php
    24/Dec/08 5:11 AM
    0.4 kB
    Mark Nielsen

Activity

Hide
Mark Nielsen added a comment -

Here is a proposed solution. It only works for modules and I wasn't sure how strict the re-linking should be. The code only skips the creation of the graded item if the function exists in the module's restorelib.php and the function returns false. The other place we may want this to skip the creation is if the function doesn't exist as it probably will create an invalid graded item.

Show
Mark Nielsen added a comment - Here is a proposed solution. It only works for modules and I wasn't sure how strict the re-linking should be. The code only skips the creation of the graded item if the function exists in the module's restorelib.php and the function returns false. The other place we may want this to skip the creation is if the function doesn't exist as it probably will create an invalid graded item.
Hide
Mark Nielsen added a comment -

Attaching an example implementation of the new hook in the module's restorelib.php file.

Show
Mark Nielsen added a comment - Attaching an example implementation of the new hook in the module's restorelib.php file.
Hide
Petr Škoda (skodak) added a comment -

Hello,
this looks like a good candidate for 2.0 backup/restore rewrite.
Thanks for the report and patch.

Petr

Show
Petr Škoda (skodak) added a comment - Hello, this looks like a good candidate for 2.0 backup/restore rewrite. Thanks for the report and patch. Petr
Hide
Helen Foster added a comment -

Editing the issue component.

Show
Helen Foster added a comment - Editing the issue component.

People

Dates

  • Created:
    Updated: