Details
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.
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.