Currently:
Upvote = +1
Downvote = -1
I need to be able to vote multiple times. I am creating a voting currency, where users are able to vote 10 times on a specific content type and may upvote 5 times for a specific node/entity
I believe this feature will be useful for other modules, such as Userpoints.
Brainstorm Solution:
- Add checkbox to field settings. If checked, then voting is a currency. IE. Downvote (-1), Upvote (0), Upvote (+1).
- Add 2 Constants to the module. DEFAULT_HIGH_VALUE = 1, DEFAULT_LOW_VALUE = -1
- Add 2 Textfields to field settings. One to set the high value. One to set the low value. When you create the vud_field, they will default to DEFAULT_HIGH_VALUE & DEFAULT_LOW_VALUE.
In Code:
- Add entity value check in
vud_vote()(in vud.theme.inc)(call function to query grab $entity_id currency checkbox value) - Change
// vud.theme.inc line 200ish $up_access = $user_vote <= 0; $down_access = $user_vote >= 0;to Final solution might be simplier than this
$high_value = isset(entity_load($entity_id)['high_value']) : entity_load($entity_id)['high_value'] ? DEFAULT_HIGH_VALUE; $low_value = isset(entity_load($entity_id)['low_value']) : entity_load($entity_id)['low_value'] ? DEFAULT_LOW_VALUE; $up_access = $user_vote < $high_value; $down_access = $user_vote > $low_value;
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | multi-vote-1869790-3.patch | 13.45 KB | istryker |
Comments
Comment #1
marvil07 commentedSorry, IMO it's out of the scope of the module.
At first look I tough this can be done from a custom widget, but since we are using entity id as part of the votingapi vote being casted, it's not currently possible to do multiple votes on the same entity. There will be a way to by pass it after #813534: +N/-N votes on widgets, but without the historical information.
So, I am closing this as won't fix.
For this case, maybe it worths to use votingapi directly.
Comment #2
istryker commentedYes it can, I am working on a patch. That is why I assigned it to myself. The patch should be fairly straightforward, and should not conflict with how the module works currently. The only thing I am worried about is the UI, which I will need feedback on.
Comment #3
istryker commentedHere is the patch. It wasn't as straightforward as I thought it would be as the amount of variables pass during the ajax calls are very minimal.
Comment #5
istryker commented#3: multi-vote-1869790-3.patch queued for re-testing.
Comment #7
istryker commentedMoving to needs review, I don't know why it failed simple test. Is/Was it broken? There is a vud.test file that should've ran.
Comment #8
istryker commented#3: multi-vote-1869790-3.patch queued for re-testing.
Comment #10
istryker commented#3: multi-vote-1869790-3.patch queued for re-testing.