Closed prjseal closed 1 year ago
That sounds like a good addition! There would be many ways to setup such a system, but a more event driven notification & notificationHandler based system with a Badge Service to process the various notifications could make it quite flexible! 🤔
Yes definitely. We want to raise event when things happen. Then hook into those notifications to consult with the badge engine to see if a badge is required and then apply it
Would you be ok with me giving a go at this when I have the time? 🙂
Yeah sure. Go for it. Please can you split it into separate PRs though. 1 for raising notifications throughout the site. Then one that consumes those notifications and works out which badges to give if any
I'd like to manage the rules of what badges to give for what using Umbraco
Sure thing! I'll start with raising notifications at the locations the application currently hands out badges, and once that one is approved, we can get working on processing those notifications to hand out badges and removing the old badging code in the process!
Brilliant. Thank you so much for joining in with this and helping make it a reality
@cornehoskam please can you add an event for member logged in
Sure thing @prjseal, will work on that next!
Excellent, would you mind creating events for failed registration, failed edit profile and failed submit survey and failed submit question? If you have time?
Sure! By Survey, do you mean a Quiz, or is a survey a new feature you have in mind?
Yeah I meant quiz. Don't know why I said survey 🤣
There you go Paul! I also took the liberty to add a notification for Failed login too, to stay consistent and have a failed counterpart for all the current Notifications!
Brilliant. Thank you. I'll review it later
Lovely! I'll do some thinking about a potential Badging Engine setup now that we have these notifications in place! I'd love to hear if you already have some idea's in mind @prjseal, otherwise I'll let my creativity go lose haha. I'll make sure to share some ideas with you before starting on any code either way 🙂
Hi @prjseal, I've created a basic design of how I thought the assigning of badges using the new notifications could work, without trying to overcomplicate things too much! The essence would be that there is a Badge implementation for each badge in Umbraco, on which the logic for the condition resides. If that condition is met, the various notificationhandlers pass said badge to the badging service to assign the badge to the corresponding users! This would fully decouple the assigning of badges from any controllers, and have NotificationHandlers do the job for us, without having the handlers store the badging logic themselves! I'd love to hear your opinion on this before writing any code 🙂
This is great. How does the Umbraco badge in content map to the individual badge C# implementation?
We could solve that with the alias property on a c# badge, which could be the unique alias of the Umbraco item as a constant/static! We could even reference the ModelsBuilder model from there if we want, but I think using the alias would make it a bit more generic and easier to work with.
Yeah I like that idea. This way we can create as many badges as we want in the content and then when it comes to implementing the logic we can just look for the alias
Because the logic of the badge can be very context dependend, and we only provide the necessary context through the notification itself (and we don't want make the IBadge implementation dependend on the notification), I opted to keep the logic for the badge condition in the notificationhandler for said specific badge to be the most logical place
This is now live and is very exciting. Thank you so much. Fixed in #48
Currently the badges are awarded in the code on submit of a form. It would be good to create some sort of badging engine. Perhaps it can raise an event and we hook into those events, check for the badge types for that type of event and then check if the data associated with this event matches the criteria for the badge and then award the badge.