API call to get all existing badges

API call to get all existing badges

by Kalin Popov -
Number of replies: 1

Hey there,

For an application I am working on I would like to get all existing badges and display them on a single page. Badges which have already been awarded will be colored in, while badges which the user does not yet have will be greyed out. When the user clicks on a greyed out badge, they would see the description which would tell them how they can earn said badge, this is a future feature however.

I am aware of the API call core_badges_get_user_badges, but I also need some way to get all badges, site wide and course specific. Is there an API call I am unaware of? If there isn't an existing API call, what would be the best approach to wring a custom API call to achieve this?

I have also been entertaining the idea of creating a badge overseer of sorts which would get all existing badges awarded to it and I would use core_badges_get_user_badges on that user to get all existing badges. Then I would compare with the badge on the current user and create the page that way. With this method however I am running into the issue that if a badge has a criteria for course/activity completion, it cannot be manually awarded. Could it be that I am doing it wrong and that it is actually possible?

Thank you in advance!

Kind Regards,
Kalin Popov

Average of ratings: -
In reply to Kalin Popov

Re: API call to get all existing badges

by tim st.clair -
Picture of Plugin developers
Did you ever find or build anything here? I'd like the same...