How to retain course id

This forum post has been removed

Number of replies: 5
The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: How to retain course id

by Carlos Peñas -
I think it isn't possible. AFAIK when restoring, moodle creates a new course giving it a new number. perhaps if you manage to create a new, empty course with the same id number than the old one, you can restore old backup inside that new course.

In the other side... activity locking relies on two tables in the database, some extra fields in "course_modules" and a new one called "*prefix*_course_module_locks" there you can change "courseid" field for your locks

But module ids are also recalculated on restoring, perhaps it breaks your activity locks too

I don't know if there's a restore mode that do not recalculate ids for courses sections and modules, so I hope this helps
In reply to Carlos Peñas

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: How to retain course id

by Carlos Peñas -
I've some clues but I'm afraid this is a big and tedious task.

Mysql tables which deals with AL are mdl__course_module_locks and mdl_course _modules

Well in :
Lockid is the mdl_course_module "id" of blocker activity/res
moduleid is the "lock owner", the mdl_course_modules "id" of blocked act/res

These are the fields you need to recalculate:

in order to know which is which:

in Course modules you need the fields: "module" and "instance"
looking for "id" at table "mdl_modules" you'll see which is the kind of module

and looking to table "mdl_<kind>" the "id" field is the value of "instance". that row should contain enough data to identify your new created resorce ....

BUT:

If you're willing to test a piece of VERY EXPERIMENTAL code, we at Warp Networks are working for a customer who wants to backup&restore courses of an Activity Locking enabled moodle. We plan to release soon this patch to moodle community for versions 1.7.1+ and 1.8.1 but needs more testing.

It's a patch for backuplib.php and restorelib.php. in our tests we were able to back-up a (little) course from 1.7.1 CVS and restore it to a 1.8.1

if you want to give it a try, feel free to send me a message, I can't attach it here due to size restrictions and because we want test it more before release it in moodle modules database.

Good Luck
In reply to Carlos Peñas

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: How to retain course id

by Carlos Peñas -
I made it temporary available here.

There's two folders one for each version of moodle, You'll surely need access to moodle setup where the 1.7.1 course is deployed.

Once patched moodle saves aditional info in moodle.xml about locks. And restore locks recalculating module ids for fields "moduleid" and "lockid"

It's presented in two folders with .diff files and .php files. the diff ones are for use with *nix "patch" shell program and contains only the changes made to original files, have a glance at them is a quick way to see what's changed. The php ones are the whole modified file just for copy over originals. REMEMBER TO KEEP A COPY OF THE OLD ONES BEFORE USE.
There's README files with this and other facts

Our patch only overwrites backup/backuplib.php and backup/restorelib.php not altering any files nor tables in database, so once applied can be safely removed restoring these two php files if somethig goes wrong.

Please grab it and email me for further instructions if needed. You should see mi mail address at my profile.

ThankU!