Moodle

Course "idnumber" in settings is not enforced as unique, but treated as such in code

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9
  • Fix Version/s: None
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_19_STABLE

Description

The Course ID Number field that you can edit in settings is not enforced as unique, so you can have multiple courses with the same Course ID Number.

This may be intentional, but you could also argue that an ID number is by definition unique. Certainly whoever coded the following functionality thought so:

http://moodle.org/course/view.php?idnumber=USING001

This link takes you to the course with that idnumber. If you have two courses with the same id number it returns an error: "invalid course id number" and the following text if debugging is on:

"Error: Turn off debugging to hide this error.
SELECT * FROM mdl_course WHERE idnumber = '12345'(with limits 0, 100)
Found more than one record in get_record_sql !"

If this is intended to be unique and fixed then code that ensures uniqueness on creation, edits and backup/restore, similar to the shortname code, will need to be added, as well as a one time fix for existing duplicates. The database should also be updated to enforce this uniqueness as raised in the linked bug about course shortnames.

Issue Links

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Hi David,

about DB enforcing uniqueness, please take a look to MDL-14083 for an explanation. Hope it helps.

About this (course->idnumber)... do you say that the course configuration page doesn't enforce uniqueness? Uhm... really I see the point about enforcing it... but I also think we have discussed this in the past... adding some people here... stay tuned.

Show
Eloy Lafuente (stronk7) added a comment - Hi David, about DB enforcing uniqueness, please take a look to MDL-14083 for an explanation. Hope it helps. About this (course->idnumber)... do you say that the course configuration page doesn't enforce uniqueness? Uhm... really I see the point about enforcing it... but I also think we have discussed this in the past... adding some people here... stay tuned.
Hide
Eloy Lafuente (stronk7) added a comment - - edited

People added. First thought is about to enforce it (like the shortname)... please, feel free to comment to get a final decisson... ciao

Show
Eloy Lafuente (stronk7) added a comment - - edited People added. First thought is about to enforce it (like the shortname)... please, feel free to comment to get a final decisson... ciao
Hide
Penny Leach added a comment -

eh, you know what I think. If things in the database are unique, they should be unique in the database.

of course the question is what to do with the existing non unique records.

Show
Penny Leach added a comment - eh, you know what I think. If things in the database are unique, they should be unique in the database. of course the question is what to do with the existing non unique records.
Hide
Eloy Lafuente (stronk7) added a comment -

No point about uniqueness in DB (see MDL-14083) at least for a while IMO . Just discussing if we should enforce it at application level, when creating courses (manually, loaders...). The objective of that column seems to be clearly about to identify courses in a distinctive way, so seems reasonable to enforce it at application level.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - No point about uniqueness in DB (see MDL-14083) at least for a while IMO . Just discussing if we should enforce it at application level, when creating courses (manually, loaders...). The objective of that column seems to be clearly about to identify courses in a distinctive way, so seems reasonable to enforce it at application level. Ciao
Hide
Penny Leach added a comment -

ok soz

Show
Penny Leach added a comment - ok soz
Hide
Eloy Lafuente (stronk7) added a comment -

haha :-D

Show
Eloy Lafuente (stronk7) added a comment - haha :-D
Hide
Daniel Miksik added a comment -

As I have written elsewhere – http://tracker.moodle.org/browse/MDL-5393?focusedCommentId=32716#action_32716 --, making course ID number unique would be a major trouble for us. At the user/application level the ID has never been unique so we started to use it as non-unique, and it fits our purposes perfectly – it allows us to link to our university information system. And it also corresponds to the documentation and help provided for this field:

I understand that other people use the ID number differently, and I do understand that this has to be addressed somehow. Still, IMHO, forcing the ID to be unique is perhaps the most simple – but not the smartest solution.

Show
Daniel Miksik added a comment - As I have written elsewhere – http://tracker.moodle.org/browse/MDL-5393?focusedCommentId=32716#action_32716 --, making course ID number unique would be a major trouble for us. At the user/application level the ID has never been unique so we started to use it as non-unique, and it fits our purposes perfectly – it allows us to link to our university information system. And it also corresponds to the documentation and help provided for this field: I understand that other people use the ID number differently, and I do understand that this has to be addressed somehow. Still, IMHO, forcing the ID to be unique is perhaps the most simple – but not the smartest solution.
Hide
Penny Leach added a comment -

You are probably right, it's very unfortunate that this is the case. Perhaps a new (UNIQUE!!) field must be added, extid or something that is actually unique and enforced both in application and database.

OT slightly - how does this compare to user.idnumber?

Show
Penny Leach added a comment - You are probably right, it's very unfortunate that this is the case. Perhaps a new (UNIQUE!!) field must be added, extid or something that is actually unique and enforced both in application and database. OT slightly - how does this compare to user.idnumber?
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Dates

  • Created:
    Updated:
    Resolved: