Instance ID on restore?

Instance ID on restore?

by J B -
Number of replies: 4
On restoring a module is there any way to find the new instance id of the module within mod/module/restorelib.php (as will appear in /mod/module/view.php?id=####)?
Average of ratings: -
In reply to J B

Re: Instance ID on restore?

by Paul K -

Hello,

I will refresh this almost 10 years old post. Is there any way to get the new instance id, during the restore or import procedure?. There is only a moodle core function which creates the new instance but don't returns any value.

$newinstanceid = $this->apply_activity_instance($newitemid);

Best regards

Paul

In reply to Paul K

Re: Instance ID on restore?

by Paul K -

I will really appreciate for any suggestion, information whether there is a chance to get the new instance id.

Best regards

Paul

In reply to Paul K

Re: Instance ID on restore?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

You might get some hints by looking at the source code of the moosh utility. At the end of a command line restore of an *mbz file you get a message in the form.

New course ID for 'BCP': 301 in 17

Where 301 is the new course id and  17 is the category.

In reply to Marcus Green

Re: Instance ID on restore?

by Paul K -

Thanks Marcus for your hint.

I have found a workaround by inserting temporary data and then updating the record. A litte bit dirty way, but it works as expected.