I created a badge that required 15 user points to get.

Once my user reached 15 points, the badge was awarded.

One of the user's nodes was deleted, causing the point count to drop to 9.

The user still had the badge.

Comments

mstef’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta1
Status: Fixed » Patch (to be ported)
StatusFileSize
new1.09 KB

This was a pretty obvious fix..

In userpoints_badges_userpoints(), on $op = points after, you check badges already received and skip to the next one. Meaning that if the user's points dropped, you never check that again. What should be done, is all of the user's point badges should be removed, and re-added if the user is still above the point threshold.

Here's a patch

kbahey’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Fixed

Thank you for contributing the patch.

It is now committed, and will be in the -dev release in about 9 hours from now.

mstef’s picture

Awesome - thanks

barrya’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Patch (to be ported) » Fixed

I've just been looking at this myself.

My understanding on how it currently works.

Badges are calculated on the users current points. if this increases above a badge threshold they are awarded that badge. If it decreases below a certain threshold then the badge is removed.

This works fine if a user is unable to spend their points, i.e. the points system is purely in place to track site activity etc. As soon as you bring points in as a reward system, i.e. do things on the site, earn points then exchange them for a reward then you are penalising your users for exchanging their points.

Both usages of badges are valid, and therefore rather than enforcing a one rule fits all situation, perhaps there should be a config option to set how point deductions are catered for? i.e. calculate badges on "lifetime points earned" or "current points balance".

barrya’s picture

StatusFileSize
new5.08 KB

You know how an idea sticks in your head, and won't go away till you have done something about it? well here we go. Attached is a patch to do my idea above.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tbillion’s picture

barrya I dont understand the format of this patch... the + and - are tooo crazy! think you could clear it up a bit?