Is it possible to restore a course and assign an ID number

Is it possible to restore a course and assign an ID number

Grant van Boeschoten -
回帖数:3
Hello,

I would like to be able to restore a course with its original id number.  This would hopefully also impact any other courses that were linked to the original course.  My hope is that by assigning the same ID number, those links from other courses to the restored course would be healthy.

Thanks for any help.
回复Grant van Boeschoten

Re: Is it possible to restore a course and assign an ID number

Ken Task -
Particularly helpful Moodlers的头像
https://docs.moodle.org/402/en/Course_restore

You are in the course itself ...
#4
Destination - Choose whether the course should be restored as a new course or into an existing course

Into an existing course, would keep the same course ID number, me thinks.

'SoS', Ken

回复Ken Task

Re: Is it possible to restore a course and assign an ID number

Grant van Boeschoten -
Thank you for your reply. Let me add some more context. If the original course has been deleted, is that id number available for a restore.

I've been experimenting with this. When I restore the course, I don't see a place to set the ID number. Once it is restored, I can go into course settings and set the id number there, but it does not change the id number in the URL for the course.

CONTEXT: Moodle 3.10
回复Grant van Boeschoten

Re: Is it possible to restore a course and assign an ID number

Ken Task -
Particularly helpful Moodlers的头像
"... add some more context"
Ahhhh, the devils are always in the details! 微笑

In everything moodle id numbers are sequential and the next new whatever will be the next available id number.   That's true of courses.   So a course that has been deleted - it's id is no longer used, but moodle won't go back to find the first id number that's not used and use it.

Using a mysql client, on the DB for your Moodle where a course has been deleted, make this query:
select id,fullname,shortname from mdl_course;

Course ID 1 is your front page and should always remain 1.  
All other course ID's are courses.   You will see gaps in sequence of id column.

Don't think there is a GUI tool to set course ID number.

But, if you are careful and know for sure what course ID a restored course should have, you could restore a course, id number will be the last one added,  then set the course id via DB directly to the id desired.

Catch 22 ... indexes of tables.  You don't see those but they are there.

If you go that route, make sure you backup your DB before such actions.

Got a clone of your production site?   Use that first! 微笑

'SoS', Ken