User creation and enrollment via flat files

User creation and enrollment via flat files

by Owen Brandt -
Number of replies: 2

One thing I'm not understanding is that the idnumber for both user and course are not required fields and they are editable.  If both the enrollment and user creation flat files need this unique number to work why is it editable?

So for example, I (as admin) create a course and a student user both with a unique idnumber and then the professor goes into the course settings and the student goes into their profile and changes or deletes the idnumber.  What if a future flat file needed to reference that user again or that course?  How would it do that if those unique numbers are gone?  Perhaps I'm not understanding.  Is there a way to prevent the idnumber from being changed after it's set?

Average of ratings: -
In reply to Owen Brandt

Re: User creation and enrollment via flat files (It works, i have other questions)

by Owen Brandt -
Ok I figured out how to lock the idnumber for the user, but the problem of locking the idnumber for the course still exists.  If this changes then I gather that no one will be able to be enrolled or modified via flat file for that course.  Any help would be great.
In reply to Owen Brandt

Re: User creation and enrollment via flat files (It works, i have other questions)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There is currently no way to lock that field without modifying the code. There is a bug requesting exactly that same feature: MDL-5373 (well, in fact I requested the removal of the options from the ldap settings page, as they are worthless, but several people requested that the functionality be fully implemented).

If you are using 1.8.4 or above, you can edit .../course/edit_form.php and search for the lineas that read:

$mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"'); $mform->setHelpButton('idnumber', array('courseidnumber', get_tring('idnumbercourse')), true); $mform->setType('idnumber', PARAM_RAW);

and after them, just add a line like this:

$mform->hardFreeze(array('idnumber'));

You can do pretty much the same with any other field, like fullname, shortname, etc.

Saludos. Iñaki.