mozilla / django-badger

django-badger is a reusable Django app for creating and awarding badges. See also badges.mozilla.org
https://github.com/mozilla/django-badger
BSD 3-Clause "New" or "Revised" License
117 stars 61 forks source link

Added prerequisites number field, to allow auto-awarding based on a subset of the prerequisites #171

Open askvictor opened 11 years ago

willkg commented 10 years ago

This work seems to be done in pull #172, too. Are you looking to land both pull requests?

askvictor commented 10 years ago

Crap; I seem to have stuffed up my PR. The two were different features. The use case for this one is along these lines:

willkg commented 10 years ago

That makes a lot of sense to me.

@lmorchard I haven't reached a good enough understanding of the django-badger architecture to know whether this makes sense or whether there's a better way to implement the use case. Can you take a look at this?

lmorchard commented 10 years ago

TL;DR: This looks good, but we might not want to merge it because I'd like to simplify the core badge model.

The issue is I could see a prereq feature growing for a lot of cases - eg. all prereqs, 3 of 5 prereqs, 1 required badge and 1 more from a set of choices, complex trees of preteqs, etc.

So, it occurs to me that this would work better in a per-app badges.py as a signal handler, keeping the core model simpler. That is, remove the current prerequisite checking from the core model altogether. Then, subscribe to badge_was_awarded in an app's badges.py and do the prereq work there.

It might also be interesting if we had a place to grow "helpers" for badges.py that offer common but optional nuggets of badge logic like this.

askvictor commented 10 years ago

Perhaps provide two different levels of badges - a simple, stripped down version, and a more fully featured, customisable one? This might allow developers to do less coding in setting up a more complex badging system. Just a though - I guess I'd like to see how the signal/badges.py system would work.

As for more complex prerequisites (e.g. badge Q is prereqs: 1 required badge (badge A) + 1 out of a set of 3 ( badges X,Y,Z) )- this could be implemented without any extra code changes, by creating a tree of badges involving 'meta' badges (meta is probably the wrong term, but I'm basing it off dpkg meta packages), which are awarded but not displayed. So in the above example there'd be a meta badge W which has prereq 1 out of (X,Y,Z). Badge Q has pre-reqs both A and W. Not sure from an end-user perspective if this would be more or less confusing that alternatives.