Instance ID on restore?

Instance ID on restore?

von J B -
Anzahl Antworten: 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=####)?
Als Antwort auf J B

Re: Instance ID on restore?

von 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

Als Antwort auf Paul K

Re: Instance ID on restore?

von Paul K -

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

Best regards

Paul

Als Antwort auf Paul K

Re: Instance ID on restore?

von Marcus Green -
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers Nutzerbild von 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.

Als Antwort auf Marcus Green

Re: Instance ID on restore?

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