In Moodle, I have some courses where the users are assigned to groups. I need to make the user group info in the course to be available via javascript, so that I can access the group info and do stuff like show and hide content based on the user group.
For example, suppose a course has groups and each group is a country. When an user enter the course, the map of the country he is assigned for will be shown in the course HTML content area. To achieve that, I need to get his course info throught javascript and show the correct map.
I have access as admin to Moodle administration, I have access to Moodle files and database. I’m a PHP and Javascript developer. I’m not a Moodle expert but I have already created some custom course content using HTML + JS + CSS.
I just need to know how to expose the user group via javascript in a Moodle course.
I have read some Moodle documentation and searched the internet, but I couldn’t find much clean information on how to do that.
A user can be in more than one group in a course – there is a PHP function that will return the user’s groups in a course –
groups_get_user_groups($courseid)