Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
773 views
in Plugins by
edited by

I am using the history plugin of NoahY, and some of my users vote and afterwards take back their vote.

"+x points" is showing up for the vote. However, when the vote is removed the "-x points" are not shown. (E.g. for "best answer" it works both ways, a_select and a_unselect.)

event: in_q_vote_nil

Plugin-Version: v 1.0b (in admin it shows 1.1)

 

Line 191 is obviously meant to consider this, however, it is commented out:

//$option_events['in_q_vote_nil'] = (int)$options['points_per_q_voted']*$multi;

?

2 Answers

+1 vote
by
selected by
 
Best answer
This isn't possible, I don't think, unless the event records what sort of unvote it is.  Currently, it just records it as an unvote, and so unvoting a down vote looks the same to the script as unvoting an upvote.

EDIT: okay, should be fixed now; I realized the oldvote was being passed, so we just had to look up what the old vote was.
by
Thanks a lot Noah, now it works!

We just have to change line 193 to:
$option_events['in_a_vote_up'] = (int)$options['points_per_a_voted'.$upvote]*$multi; // *(-1);

to show positive points for voting up instead of negative ones.


I have made 5 changes marked with "eetv". Please see: https://github.com/echteinfachtv/q2a-history/commit/2937030775400f3dc6f2a2c3e7de24df760d06fb


PS: I do not know the operator "@$options" just used "$options". What is that?
by
the @ just means that if the index is not set, it won't throw an error but return null instead; it's used to suppress error notices.
by
good to know! thanks for updating the history plugin.
0 votes
by
edited by

I thought the solution is the following (at least it shows the minus points*):

change:
//$option_events['in_q_vote_nil'] = (int)$options['points_per_q_voted']*$multi;
to:
$option_events['in_q_vote_nil'] = (int)$options['points_per_q_voted'.$upvote]*$multi;

and change:
//$option_events['in_a_vote_nil'] = (int)$options['points_per_a_voted']*$multi;
to:
$option_events['in_a_vote_nil'] = (int)$options['points_per_a_voted'.$upvote]*$multi;

 

* However, now I get server errors:
PHP Notice:  Undefined index:  points_per_q_voted in /qa-include/qa-app-format.php(1452) : eval()'d code on line 191
PHP Notice:  Undefined index:  points_per_a_voted in /qa-include/qa-app-format.php(1452) : eval()'d code on line 194
 

...