Custom profile fields, datetype, enabled by default?

Custom profile fields, datetype, enabled by default?

by Peter Haasdijk -
Number of replies: 6

Custom profile fields of type date are enabled by default, on today's date when i do a user upload.

To me it seems more logical to have these dates disabled during a user upload. Can I change that somewhere?

Average of ratings: -
In reply to Peter Haasdijk

Re: Custom profile fields, datetype, enabled by default?

by Peter Haasdijk -
I was going to ask this question again (forgotten i did allready). Is there anyone who has an idea how to solve this?
In reply to Peter Haasdijk

Re: Custom profile fields, datetype, enabled by default?

by Randy Thornton -
Picture of Documentation writers
Peter,

The user upload is doing exactly what a user would do manually: the user has to enable the field in their profile before they are allowed enter the date. "Enable" here really means, "Create/edit the data."

If you have set the custom field to not locked, then they can edit it either way the Enable checkbox is set by default. The Enable checkbox behaves just like all the other fields in the user profile: when the user is Editing their profile, all the fields are immediately able to be edited (unless locked.)

So, the check box behaves in a way consistent with other fields in edit mode by being On by default.

If you want to prevent users from changing it, set the field to Locked.

The default of today's date is not actually set for all users. It is just the system default so there is some date to start with when editing it. It is not actually part of the user profile: the actual user data is not created until the data is uploaded or manually entered in the field. This is true for all custom profile fields, actually. When you define a custom profile field and you have 500 users, for example, Moodle does not create 500 new user profile fields with the default data. It does not actually create them until they are filled in via upload or manual profile editing.

The only advantage I can see from having the Enable checkbox set to Off after the user upload would be that it forces the user to check the Enable box if they want to edit the date on their profile. Do you have a specific reason for wanting that to be set to Off after an upload while still allowing users to edit it later if they want?


In reply to Randy Thornton

Re: Custom profile fields, datetype, enabled by default?

by Peter Haasdijk -
Hi Randy,

I will give you an example of a situation where dates are used in the user profile.
In this case, documents are issued with a certain validity date. This date must be saved per user and, if necessary, modified by an administrator.
The user does not see these dates. The fields are hidden on the user profile. The administrator sees them and can edit them.

When a user upload is done without specifying data with which these fields can be filled, today's date will be saved. Unless the fields are disabled during the import. In the case of this customer, about 10 fields have to be disabled with every import.

So here it makes more sense to disable the fields by default.

Would that be possible?
In reply to Peter Haasdijk

Re: Custom profile fields, datetype, enabled by default?

by Randy Thornton -
Picture of Documentation writers
Ah, now I understand what you are trying to accomplish. If you upload the date field and the data is empty, it has to do something and it puts a 0.

For example, this upload file:

username,profile_field_birthdate
gmarx,1890-10-02
cmarx,
hmarx,1888-11-23

will put 0 for the birthdate for Chico Marx since it is empty. When this is seen on screen, it just shows today's date on screen. It does not actually save today's date as the birthday: it just knows that 0 means nothing and so shows today's date. If you ran a report on the user data, it would have just a 0.

When you say "disable by default" that is not what is really happening: the enable is only a manual thing in the profile to help manual editing. The field is always available to be edited by an admin or via upload.

It sounds like what you really want is: if the data for a field in the upload file is empty, then do nothing. Skip it. Don't create it. The only way to do that would be to recode the process in the uploaduser php files.

Right now however, when you include the data in the upload file, it will create or update the data. The only way to avoid this is to remove those lines from the upload file.
In reply to Randy Thornton

Re: Custom profile fields, datetype, enabled by default?

by Peter Haasdijk -
Thank you Randy. This should be a workable solution for this customer.
At first I was hoping not to have to include the fields in the csv file, but that doesn't work the way I want (then today's date will appear in the profile). I now made a template in excel for the client and that seems OK for him.
Thanks again,
Cheers,
Peter
In reply to Peter Haasdijk

Re: Custom profile fields, datetype, enabled by default?

by Randy Thornton -
Picture of Documentation writers
Peter,

Thanks sounds like the only solution for right now.

I agree the way this works in not well designed: 0 is a perfectly valid date and time (January 1, 1970 00:00) for one thing; showing today's date on screen makes it seem like that is some default, which it is not. The upload process should at least put a null in the data, or preferably do nothing at all.