How do I renumber Student Id numbers

How do I renumber Student Id numbers

av Mark Fellowes -
Antall svar: 4

We recently created a test student with an Id number that was much larger than the existing students (999999 instead of the next number in series 10001)

Can someone please provide a SQL update query that can renumber the incorrect student id's to follow suit of the original numbers.

And also if this is not available, which tables will have a relationship to this student id so I ensure all relationships tables / rows are updated.

Thankyou

Gjennomsnittlig vurdering: -
Som svar til Mark Fellowes

Re: How do I renumber Student Id numbers

av Marcus Green -
Bilde av Core developers Bilde av Particularly helpful Moodlers Bilde av Plugin developers Bilde av Testers
You can see how tables are related here
http://www.examulator.com/er
But those id values are supposed to be arbitrary and should not be used for humans to identify, use remember or value, they are for computers. I doubt if it is realistically possible to achieve what you want.
Som svar til Marcus Green

Re: How do I renumber Student Id numbers

av Mark Fellowes -
Hi Marcus,
Thanks for your link etc.. the scheme diagrams are hmmmmm very large giving the number of tables they hit... Everything is possible... blunker I can update them manually but didn't want to miss a table / relationship. I work with SQL/DB2 for many years and we had to overcome this issue occasionally. Just needed the tables storing the stduent id's.. thankyou again
Som svar til Marcus Green

Re: How do I renumber Student Id numbers

av Davo Smith -
Bilde av Core developers Bilde av Particularly helpful Moodlers Bilde av Peer reviewers Bilde av Plugin developers
To echo what Marcus has said here, changing a single student's id would require updating records across hundreds of database tables. It is an impractically huge task.

The closest option available would be to somehow create a new user account with the id that you require (which will be tricky as the id generation is done by the underlying database, not by the Moodle code itself) and then use the 3rd party Merge Users plugin to merge the accounts together. This is not recommended.

Even if you did manage to "solve" this problem (which isn't really a problem in the first place) the very next user generated would still have the large id value that you are trying to avoid.
Gjennomsnittlig vurdering:Useful (1)
Som svar til Mark Fellowes

Re: How do I renumber Student Id numbers

av Michael Milette -
Bilde av Core developers Bilde av Documentation writers Bilde av Particularly helpful Moodlers Bilde av Plugin developers Bilde av Testers Bilde av Translators
Hi Mark,

A user id in Moodle is a reference to many other tables in a relational complex level database. The id field is also an auto-incremented number.

Have you considered using a different field for your student ID number? If you don't care for any of the existing built-in ones, you could create custom profile field. If you need it to be auto-incrementing for each student, you could even create your own custom profile field type for this. That way, it would work independently from Moodle's record ID number.