Upload users with custom fields containing language filters

Upload users with custom fields containing language filters

by julie prescott -
Number of replies: 1

Hi,

I have a custom user profile field, short name = UserType, which is a menu of choices. Each choice has been given the language <span> tag to translate it between english and chinese.

Eg

<span lang="en" class="multilang">Employee</span><span lang="zh_cn" class="multilang">员工</span>
<span lang="en" class="multilang">Customer</span><span lang="zh_cn" class="multilang">终端用户</span>

When I upload a new user via CSV file I have a column called 'profile_field_UserType' in my CSV which contains the value:

<span lang="en" class="multilang">Employee</span><span lang="zh_cn" class="multilang">员工</span>

When I upload the users preview page says 'Invalid user field: UserType'.

I debugged the code and found that the problem is happening in the function convert_external_data() in /user/profile/field/menu/field.class.php - it is returning each menu option by stripping out the <span> tags. This means that the upload routine is comparing:

<span lang="en" class="multilang">Employee</span><span lang="zh_cn" class="multilang">员工</span>
with
Employee员工

so it's always returning false and not allowing the user to be added.

My question is, how do we get around uploading new users, with custom profile fields which contain multi-language span tags, into the LMS without doing some major re-coding?

My current Moodle version is 3.3.9 Build 20181112

I hope I have given enough information.

Thanks

Julie

Average of ratings: -
In reply to julie prescott

Re: Upload users with custom fields containing language filters

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Julie,

I don’t know if this is relevant or not, but which theme are you using, as there may be some code within the theme that is causing the problem?

Assuming that you have always done this the same way, have you or others made changes to your current version of Moodle or added new plugins?

Just a few thoughts...

Chees

Mary