Closed (duplicate)
Project:
User Points Contributed modules
Version:
5.x-3.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Dec 2007 at 09:14 UTC
Updated:
12 May 2011 at 10:16 UTC
Jump to comment: Most recent file
Comments
Comment #1
quicksketchThe 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.
Comment #2
jredding commentedI agree.... additionally I don't understand how this is a match. Can someone expand on how fivestar and userpoints would work together?
Comment #3
andrabr commentedjredding,
userpoints assigns points for performing community-building activities. So it would make sense if someone gaained userpoints for voting or for being voted on...
Comment #4
jredding commentedOK 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.
Comment #5
jredding commentedCheck out the new tutorial for ideas on how to get started!
http://drupal.org/node/198548
Comment #6
gregglesslightly clearer title
Comment #7
jredding commentedrecategorizing off of userpoints as its not a feature for the coreapi but rather a contributed module
Comment #8
kmillecam commentedI 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
Comment #9
palazis commentedVery interesting. Subscribing.
Comment #10
kmillecam commentedIt 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
Comment #11
palazis commentedLets 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?
Comment #12
sammos commentedI'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.
Comment #13
kbahey commentedDoing 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.)
Comment #14
kmillecam commentedI'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.
Comment #15
kbahey commentedKevin
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.
Comment #16
kmillecam commentedThanks 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.
Comment #17
kbahey commentedWe can close this then.
Comment #18
mpaler commentedWhat 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:
Up/Down:
Is this something that can be done by working on userpoints_votingapi ?
Thanks,
Mike
Comment #19
sammos commentedHi,
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.
Comment #20
kmillecam commentedHey 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
Comment #21
mpaler commentedHi Kevin,
I'm working on this. I hope to have something to report back by later this weekend.
Mike
Comment #22
kmillecam commentedAwesome Mike!
Keep us posted.
Kevin
Comment #23
mpaler commentedHi 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
Comment #24
kmillecam commentedCouple 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.
Comment #25
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #26
sammos commentedThis 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!
Comment #27
kmillecam commentedsammos,
userpoints_votingapi is now a separate project.
Make sure you're using this version: http://drupal.org/project/userpoints_votingapi
HTH,
Kevin
Comment #28
kbahey commentedMoving to the appropriate project.
Comment #29
sammos commentedActually, 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
Comment #30
kbahey commented@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.
Comment #31
sammos commentedAlso, 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.
Comment #32
mpaler commentedHi 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
Comment #33
Vuds commentedHey 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!
Comment #34
mpaler commentedHi,
Not sure I understand your question. Can you provide more detail?
Thanks,
Mike
Comment #35
neubreed commentedI 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?
Comment #36
titouilleHi !
I rewritten the userpoints_fivestar module for drupal 6. Don't know if all is ok but you can try it.
I merged the userpoints_votingapi and userpoints_fivestar modules. The goal is the user can set a number of points for each star. The points are given to the author of the voted content.
It works like the following :
1. install userpoints
2. install userpoints_fivestar
3. go to admin/settings/userpoints
4. choose your config in the userpoints fivestar fieldset at the bottom of the screen. You can select the points value affected to the user who vote, if user/author points must be moderate, the category to set the points
5. go to admin/content/types and select a content-type to edit
6. go to fivestar properties
7. here you can choose the points values affected for each star to the author when a user vote in the "user points for author" fieldset.
The only thing I try without success is to rewrite automagically the number of points textfields switch the number of stars, like the labels fieldset...
Hope this help...
(sorry if the post is misplaced and need another thread forum... and for my bad english)
Comment #37
soulfroysDoes't work for me.
Comment #38
soulfroys#36 works perfect now! I realized that it needed the Late Form Alter (http://drupal.org/project/late_form_alter). Tks @titouille!
Comment #39
titouilleThanks soulfroys for your review. And sorry to forgot the late_form_alter dependency in the .info file :-|
I made a little refactor with some comments and the correct dependency for late_form_alter. Here is the new zip with correct .info file. I think too the hook_votingapi_insert and hook_votingapi_delete can be refactored to call the same function with a positiv/negativ param to set the inserted / deleted vote, but don't have time now to do it :-p
Comment #40
Taxoman commentedSee http://drupal.org/project/userpoints_votingapi
Comment #41
iex commentedThanks a lot, seems working fine )
Comment #42
chefarov commentedThank you so much titouille !!
It works fine !
Just a suggestion for future work if you would like.
I think it would be better if the counting depends on average rating and number of votes instead of, granting/substracting points every time a vote is being done.
Anyway, its fine as it is since someone can configure the points so that it adds/subs a small number every time instead of granting a lot of points.
Thanks again.