Count points awarded instead of votes cast, also add custom time period (with PATCH)

fred0 - June 16, 2009 - 23:46
Project:User Points Voting API
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

One of the things that has come up on my live site is that users are confused about the threshold for votes and points. The reason for this is that currently, the module looks at the votingapi_vote table and counts all votes for the past 24 hours in the threshold and awards points only if the that threshold isn't met. That means that if a user keeps voting on things after meeting the threshold, then those new votes that exceed the threshold can easily maintain the threshold and the user never (or rarely) gets new points after the period elapses for points awarded.

To fix that, I am suggesting we count points awarded in the time period instead of votes cast. That way, users can keep voting (should they choose to even thought they won't get points) and then they will start being awarded points again once previous vote points start to drop out of the threshold.

Also, it occurred to me that it might be nice to be able to define the time period in the interface to allow other options (hourly, daily, weekly, monthly annually).

I've attached patches that change the counting to use userpoints_txn to count the threshold and adds a custom time period setting. The userpoints_votingapi.install.patch file alters the variables table for the custom time period part.

I haven't fully tested these, but they seem to work. Can anyone else give it a whirl and confirm?

Thanks!

AttachmentSize
userpoints_votingapi.install.patch675 bytes
userpoints_votingapi.module.patch2.99 KB

#1

fred0 - June 17, 2009 - 05:49

Oops. Already found bugs myself.
Here's a new patch for the module. The install file from the first post is fine.

This patch fixes a problem with the db_query statement. Also, it fixes a bug which exists in the current dev version of the module where on the last line is says

return ($number <= $threshold ? TRUE : FALSE);

the <= actually allows 1 point above the threshold to be awarded.
It should just be
return ($number < $threshold ? TRUE : FALSE);

Finally, it occurred to me that making the threshold a pre-defined array was restricting to the site admin and a freeform textfield made more sense so, that is changed as well.

AttachmentSize
userpoints_votingapi.module.patch 3.13 KB

#2

fred0 - November 8, 2009 - 22:28

Would still love to see this change to the module. Here's patches against the latest (Sept 29, 2008) dev version.

AttachmentSize
userpoints_votingapi.install.patch 693 bytes
userpoints_votingapi.module.patch 3.01 KB

#3

fred0 - November 8, 2009 - 22:31

Let's try that again.

AttachmentSize
userpoints_votingapi.install.patch 693 bytes
userpoints_votingapi.module.patch 3.06 KB

#4

fred0 - November 10, 2009 - 18:32

Re-rolled to fix db_query to match change to the userpoints_txn schema.

AttachmentSize
userpoints_votingapi.install.patch 693 bytes
userpoints_votingapi.module.patch 3.06 KB
 
 

Drupal is a registered trademark of Dries Buytaert.