I create a course custom field for a dedicate application exporting datas from courses.
Here the value for courseID=12 :

I had to export the value of this custom field called 'rate' ('Taux' in french) for every courses in the list. I search in documentation and found this : https://docs.moodle.org/dev/Custom_fields_API#Example_code_for_course_custom_fields
So I wrote this function :

Despite the record in database :

The result is… empty 🙃

Where is my mistake?
Thanks for your attention.
Patrick