Issue Details (XML | Word | Printable)

Key: MDL-16764
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Sam Chaffee
Votes: 2
Watchers: 4
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

"profile_field_menu" fields fail during upload of users from csv

Created: 02/Oct/08 08:11 AM   Updated: 20/Aug/09 04:01 AM
Return to search
Component/s: Administration
Affects Version/s: 1.9.2
Fix Version/s: None

File Attachments: 1. Text File profile_field_menu.patch (1 kB)
2. Text File profile_field_menu2.patch (1 kB)
3. Text File uploadusers.patch (2 kB)

Issue Links:
Relates
 

Participants: Eloy Lafuente (stronk7), Hubert Chathi, Petr Skoda and Sam Chaffee
Security Level: None
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
When uploading users from a csv file a menu-type custom user profile does not get the values inserted.

For example I have a user profile field with a shortname of studionumber that is a menu type field. The options are:

1234
2341
3421

In the csv I have:

firstname, lastname, username, email, profile_field_studionumber
testfirst, testlast, testuser, testuser@localhost.com, 2341

When I upload the user, the user gets added, but the custom menu field does not take the supplied value.

I get this error:

Column 'data' cannot be null

INSERT INTO mdl_user_info_data ( USERID, FIELDID, DATA ) VALUES ( 23, 3, null )

    * line 1554 of lib\dmllib.php: call to debugging()
    * line 102 of user\profile\lib.php: call to insert_record()
    * line 355 of user\profile\lib.php: call to profile_field_base->edit_save_data()
    * line 548 of admin\uploaduser.php: call to profile_save_data()

The problem is this:

profile_field_base->edit_save_data() calls profile_field_menu->edit_save_data_preprocess(). This function expects the key of the options array (which is what it is when it is called from editadvanced.php and other forms). However, since the csv file likely (and sensibly) contains a value and not a key edit_save_data_preprocess gets the value as a parameter instead of the key and returns NULL as a result.

I tried a quick hack as a solution and have attached the svn diff of the potential fix (it works, but may not be the most elegant solution).

Hope this helps.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Skoda added a comment - 09/May/09 07:25 PM
Hmm, I think we should better convert the strings to key in uploadusers code before sending to other parts of moodle instead of making the code in /user/* more complex

Hubert Chathi added a comment - 23/Jul/09 11:19 PM
Another option is to change edit_save_data_process to allow both the numeric values, or the actual field values. Attached is a patch (profile_field_menu.patch) to do that. Alternatively, you could just set the $this->options array to be keyed by the value, rather than an integer, and not have to worry about handling both cases. The profile_field_menu2.patch does this.

A third option is to have the CSV upload use a completely different set of functions to set the values.