[3.7] Are shortnames supposed to be unique or not?

Re: [3.7] Are shortnames supposed to be unique or not?

by Randy Thornton -
Number of replies: 0
Picture of Documentation writers
The course shortname must be unique. This is and has always been so.

This is enforced in the code in /course/lib.php in the function create_course (lines 2392 et seq. in 3.7.) See screenshot.

If you try to create a new course with a duplicate shortname or change the shortname of an existing course to one already in use, you will get the error "Short name is already used for another course." If you try to creat a new course in the Site admin > Courses > Course upload tool with a duplicate shortname, you will get the error: "The course exists and update is not allowed" because the shortname is already used. And if you set the Course upload mode to "Create new courses, or update existing ones", it will not make a new course but will update the already existing course that has that shortname.

This is a constraint in the code, not in the table but you will notice that all the table indices for mdl_course are all either unique or refer to other items that are unique. Changing the code to allow duplicates would not be a trivial task. It would be far, far easier to change your theme so that the breadcrumb and or the NavDrawer would show what you prefer there.

Randy
Attachment screenshot_5392.jpg
Average of ratings: Useful (1)