How to map the country field with external database authentication?

How to map the country field with external database authentication?

av Florian Kohrt -
Antall svar: 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).

Gjennomsnittlig vurdering: -
Som svar til Florian Kohrt

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

av Ken Task -
Bilde av 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

Gjennomsnittlig vurdering:Useful (1)
Som svar til Florian Kohrt

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

av Marcus Green -
Bilde av Core developers Bilde av Particularly helpful Moodlers Bilde av Plugin developers Bilde av 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)



Gjennomsnittlig vurdering:Useful (1)