userpoints integration with votingapi module

andrabr - December 5, 2007 - 09:14
Project:User Points Contributed modules
Version:5.x-3.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

http://drupal.org/project/userpoints - is a perfect match for FiveStar

#1

quicksketch - December 7, 2007 - 04:05
Project:Fivestar» User Points
Version:5.x-1.8» 5.x-3.x-dev
Component:Code» Code: userpoints

The integration should come from the other end I believe. VotingAPI provides a hook for submitting votes, where UserPoints should hook in. That way it'll work with *any* voting widget, not just Fivestar or NoteVote.

#2

jredding - December 7, 2007 - 11:54

I agree.... additionally I don't understand how this is a match. Can someone expand on how fivestar and userpoints would work together?

#3

andrabr - December 10, 2007 - 01:39

jredding,

userpoints assigns points for performing community-building activities. So it would make sense if someone gaained userpoints for voting or for being voted on...

#4

jredding - December 10, 2007 - 01:57

OK now it makes sense. Fivestar is the wrong module as it just displays a nice pretty interface. The Voting API is where the integration should go.

This should be a new contrib module.

Anyone got the time? Want to submit a new module? This probably wouldn't take too long.

#5

jredding - December 10, 2007 - 02:05

Check out the new tutorial for ideas on how to get started!
http://drupal.org/node/198548

#6

greggles - December 18, 2007 - 22:24
Title:Integration with UserPoints module» userpoints integration with votingapi module

slightly clearer title

#7

jredding - December 26, 2007 - 08:32
Component:Code: userpoints» Other

recategorizing off of userpoints as its not a feature for the coreapi but rather a contributed module

#8

kmillecam - January 25, 2008 - 03:24

I would like to see this happen and am willing to do some of the heavy lifting.

So, let me think out loud for a minute ...

1) User casts a vote using Fivestar or some other voting mechanism.
2) Fivestar passes voting info to votingAPI for processing.

Where would it make sense for the User Points contrib module to know that a vote is/has been cast?

3) User Points would recognize that a vote has been cast and will process the proper number of points.

Please feel free to offer direction, advice, (or code) ;-)

Thanks,
Kevin

#9

palazis - January 29, 2008 - 17:59

Very interesting. Subscribing.

#10

kmillecam - January 29, 2008 - 21:05

It appears that the way to pull this off is to add the User Points API code to the Voting API module.

So whenever a vote is committed by Voting API, information is fired (via the User Points API) to the userpoints module

This is how the nodevote.module works with User Points.

Is there a better way to do this or should I approach the Voting API team with some proposed additions to their code?

Thanks,
Kevin

#11

palazis - January 31, 2008 - 07:57

Lets us think about the following scenario:
1) User 1 creates Story 1 and (possibly) earns some points about it, e.g. 10 points.
2) User 2 votes for Story 1 using Voting API and Fivestar UI, e.g. gives 5 stars for Story 1.
2a) User 2 earns some points for voting Story 1, e.g. 10 points.
2b) User 1 earns some points too because his Story was voted by another user, e.g. 5 points. Note: In case his story was voted negatively (e.g. 1 star only) perhaps 5 points should be subtracted from User 1.
3) Is this discussion here concerned about 2a or 2b? Or both? Personally I believe that both are useful.
4) Another useful module for voting that works with Voting API is the new User Karma module. This module uses its own points (like karmic points). I have contacted the maintainer of User Karma, because I believed that User Karma and User Points should join forces. See http://drupal.org/node/211136 issue.
Any other ideas or thoughts?

#12

sammos - February 5, 2008 - 21:01

I'm also very interested in this - both 2a and 2b. I am willing to contribute to a bounty for making this happen - I have an immediate need for this feature! (and time is of the essence unfortunately). I noticed that userpoints (or userpoints contrib?) has some integration with voteupdown and nodevote for scenario 2a only. But, it does seem that it makes sense to integrate with voteapi such that any voting module can be used. I'm planning to use fivestar for my project.

#13

kbahey - February 6, 2008 - 03:04

Doing it at the Voting API level makes it available to all modules that uses that API (e.g. voteup/down, fivestar, and a few others).

It has to have a user interface that maps how many votes to how many points, as well as the vote type (node, comment, ...etc.)

#14

kmillecam - February 6, 2008 - 05:31

I've uploaded an initial release here: http://drupal.org/node/211965

userpoints_votingapi - part of the User Points Contrib collection of modules.

Feedback is welcome.

#15

kbahey - February 6, 2008 - 20:23

Kevin

That is awesome.

Please update the main project page listing your module in it like the others

http://drupal.org/project/userpoints_contrib

There is a problem I see in this tarball. ALL the modules are included even though many of them are not API 3.x compliant yet. Not sure if this is a tagging issue or what.

#16

kmillecam - February 6, 2008 - 21:49

Thanks Khalid,

I've updated the project page.

I noticed the 2.x versions of the modules but I thought they waiting to be updated to 3.x.

#17

kbahey - February 6, 2008 - 22:00
Status:active» fixed

We can close this then.

#18

mpaler - February 7, 2008 - 23:31

What I really want to do (and I believe others above have alluded to this) is to assign a +/- point value to the actual vote being cast depending on the voting system being utilized.

For example:

Fivestar:

Vote      Points
----------------
1          -2
2          -1
3           0
4           1
5           2

Up/Down:

Vote     Points
-------------------
Up          1
Down    -1

Is this something that can be done by working on userpoints_votingapi ?

Thanks,
Mike

#19

sammos - February 8, 2008 - 21:34

Hi,
I was excited to see the new userpoints_votingapi and I'm planning to try it out this weekend and give feedback.

I would like to be able to award points to the person who voted (sounds like it does this) but ALSO be able to award points to the person who authored the voted-upon content. This is a great feature because it rewards people based on the quality of their content (assessed by how many votes their content has gotten). So, if Person A votes on Person B's content - say 3 of 5 stars - then Person B gets 3 userpoints awarded to them. If somebody else votes and gives them 1 star they get 1 userpoint. Etc. Vote up/down, since it casts a negative vote on vote down, would subtract a userpoint. Or it could be more configurable like mpaler suggested so that you define the ratio of points to userpoints more specifically.

#20

kmillecam - February 8, 2008 - 22:00
Project:User Points» User Points Contributed modules
Version:5.x-3.x-dev» 5.x-3.x-dev
Component:Other» Code: userpoints_votingapi

Hey Mike,

This will take some thinking.

I'm not sure we can assume that sites will be only one voting module. So the code would have to take all the various voting modules into account.

Fivestar, for example, gives the admin the freedom to choose the number of stars (4?,8?,12?) so the code would have to account for this too.

When a vote is cast, userpoints_votingapi awards points to the voter. It does, however, have access to the nodeID that is being voted on. Using that nodeID, we could look up the node author and give them points based on the vote.

I guess at that point we use the userpoints_api() to make two inserts into the userpoints_txn table; one for the voter and another for the author of the node being voted on.

Does this make sense?
Can anyone weigh in on the technical issues with this approach?

Thanks,
Kevin

#21

mpaler - February 8, 2008 - 23:46

Hi Kevin,

I'm working on this. I hope to have something to report back by later this weekend.

Mike

#22

kmillecam - February 9, 2008 - 03:31

Awesome Mike!

Keep us posted.

Kevin

#23

mpaler - February 13, 2008 - 19:34

Hi Kevin,

Attached is my crack at a userpoints/votingapi module. Give it a look when you get a chance -- perhaps it can work as a foundation for future Userpoints/Voting API integration -- however, I believe it works and may be useful to some in its current form. At least it works for me, though I haven't ported it to production yet.

To be honest, I don't believe there can be a userpoints/voting api that is voting system agnostic (Fivestar, Up Down, etc). Just getting this thing to work with Fivestar required a patch to that module that I is (hopefully) being reviewed over at that project.

If people don't feel like downloading the attached tarball I can paste the module code here...

Here's the readme so I don't have to re-write:

The Userpoints_Fivestar module assigns userpoints to the author of a node when their content is voted on using the Fivestar module.
It also requires you have Userpoints and the Voting API installed and only works with the Fivestar module voting widget.

The module does the following:
- Adds userpoints to the account of the author of a node that is voted upon via the Fivestar module.
- Administrator can configure how many points a star is worth including negative values.
- Module is enabled/disabled for CCK content types from the Fivestar settings panel.
- Adjusts author userpoints properly if a vote is changed or deleted.
- Adjusts voter userpoints properly if a vote is changed or deleted (ie. plays nicely with the userpoints_votingapi.module)

To install the module:
- Copy the module to your /userpoints_contrib directory wherever that is located.
- Enable the module at: /admin/build/modules
- Grant rights to the module at: /admin/user/access
- Configure the module settings in the Fivestar settings for all desired CCK content types.

Any questions/feedback is greatly appreciated.

Mike

AttachmentSize
userpoints_fivestar.tar_.gz 3.57 KB

#24

kmillecam - February 13, 2008 - 21:27

Couple quick notes:

Nice Job Mike! I took a quick look at your code and noticed a few things you'll want to change:
- there are a couple references to dsm() that'll break if devel is not installed and running
- you reference a function in userpoints_votingapi so you should add that to your dependencies list.

Kevin

Edit:
It might be simpler (for the user too) if you changed this:
$threshold = variable_get(userpoints_votingapi_daily_threshold, 0);
to this:
$threshold = variable_get(userpoints_fivestar_daily_threshold, 0);
and set your own threshold variable for fivestar.

This way users wouldn't have to install userpoints_votingapi if they really didn't need it.

#25

Anonymous (not verified) - February 27, 2008 - 21:34
Status:fixed» closed

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

#26

sammos - July 22, 2008 - 21:38
Title:userpoints integration with votingapi module» wonderful but voting does not work now
Component:Code: userpoints_votingapi» Code

This is great! I'm excited to start using it. I've installed it but now, the fivestar widget doesn't work. When I turn this module off it works again. What happens is that it tries to save the vote but never succeeds.

I don't have devel installed; is that why it breaks? I'd rather not have devel installed on my live site. Can you possibly revise the code and repost the tarball? Or give me some pointers and I'll take a stab at it myself?

Thanks!

#27

kmillecam - July 22, 2008 - 21:49

sammos,

userpoints_votingapi is now a separate project.

Make sure you're using this version: http://drupal.org/project/userpoints_votingapi

HTH,
Kevin

#28

kbahey - July 23, 2008 - 19:00
Project:User Points Contributed modules» User Points Voting API
Version:5.x-3.x-dev» 5.x-2.2
Status:closed» active

Moving to the appropriate project.

#29

sammos - July 24, 2008 - 18:32
Project:User Points Voting API» User Points Contributed modules
Version:5.x-2.2» 5.x-3.0

Actually, I'm talking about userpoints_fivestar module which I downloaded from this page. I am using the latest version of userpoints_votingapi (5.x-2.2) and userpoints_fivestar downloaded from comment 23 above: http://drupal.org/node/197991#comment-728760

But when I turn on this userpoints_fivestar, the fivestar widget stops working.

My goal is to award points to those whose content has been voted on - I need userpoints_fivestar exactly! If only I could get it to work.

Any help much appreciated. Thank you.

This was originally posted as User Points Contributed Modules although it does not appear to me that this module has made its way into that package. So I'm putting the thread back where I found it.

Best,
-Sam

#30

kbahey - July 24, 2008 - 18:43
Title:wonderful but voting does not work now» userpoints integration with votingapi module
Status:active» duplicate

@sammos

The original issue title was "userpoints integration with votingapi module". Do not change issue titles please.

The proper way to handle any module that uses voting api (fivestar included) is using what kmillecam mentioned in #27. It was written specifically to provide that feature for any module that uses voting api.

So this whole issue is now marked as duplicate.

You can use a non-advocated way/patch/module all you like, but you have to realize that you will be on your own when doing so.

#31

sammos - July 24, 2008 - 18:44

Also, I found this userpoints_fivestar module based on your post on this thread: http://drupal.org/node/241268#comment-797005

It looks like skyweb was also trying to get this to work and had the same issue. I'll post there too.

#32

mpaler - July 26, 2008 - 14:04

Hi Sammos,

Sorry you're having difficulties. Did you install the devel module? If you don't want to install that try commenting out all references to dsm() in the userpoints_fivestar.module

Hope that helps.

Mike

#33

Vuds - September 15, 2008 - 19:16

Hey Mike,

I've just installed your module from #23 and it's working very well as expected, thanks! I use the last stable versions from userpoints and userpoint_votingapi, and also the devel module but as soon as I finish the site development I'll uninstall it, so I commented the lines with dsm().

Just one thing, it is showing nothing in the Operation column for Users' view or view for Moderation. Could you please verify that?

Thanks again!

#34

mpaler - September 17, 2008 - 18:41

Hi,

Not sure I understand your question. Can you provide more detail?

Thanks,
Mike

#35

neubreed - May 20, 2009 - 02:44
Category:feature request» bug report

I found that if a user edits their own comment after the initial post, the points get awarded again and again. Is there a way to block this?

 
 

Drupal is a registered trademark of Dries Buytaert.