How to map the country field with external database authentication?

How to map the country field with external database authentication?

Florian Kohrt發表於
Number of replies: 4

After setting up the external database authentication including data mapping for the "Country" field I had hoped that the country of external users will also show up in their Moodle profiles. Unfortunately that does not happen, that is the country field in their Moodle profiles stays unselected.

Because mapping does for other fields I suspect the reason might be that country is not a free-form field but has a limited set of valid values. The external database provides country names in English language which just might not be the correct format.

Do you have any ideas on how to get country mapping right?

I am running Moodle 3.11.7+ (Build: 20220610).

評比平均分數: -
In reply to Florian Kohrt

Re: How to map the country field with external database authentication?

Ken Task發表於
Particularly helpful Moodlers的相片

Please see:

https://docs.moodle.org/400/en/Location

There is a small paragraph for All Country Codes linked page above (English).

It is not unusual for a point release or upgrade of Moodle to acquire new countries not previously in list.

https://github.com/moodle/moodle/blob/master/lang/en/countries.php

'SoS', Ken

評比平均分數:Useful (1)
In reply to Florian Kohrt

Re: How to map the country field with external database authentication?

Marcus Green發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
Core Moodle includes a user field that allows the selection from a list of ISO 3166 country names to be stored and displayed in the dropdown selection box on a user profile page. These values can be seen here.


The country name you are using may not always exactly map to the ISO name, e.g. the official name of what I think of as “The Czech Republic” is stored as the ISO country name of Czechia. These values are stored in a file called
lang\en\countries.php
in the form
$string['GB'] = 'United Kingdom';

So as you say it is not a free form field, but a key/pair mapping. It will also depend on what country name you are using (i.e. is it the ISO name as listed in that Wikipedia link)



評比平均分數:Useful (1)