PDA

View Full Version : Total Votes in poll plug-in


theodore
01-19-2009, 09:26 AM
Hi

How can i get the total votes in poll plug-in ?
I mean total votes in all questions, not {answer.vote}, but total poll votes (sum from all answers)


.

shketuljko
01-20-2009, 12:16 PM
Try with this:

<vte:value select="{answer.all_votes}" />


like this box:

<vte:box module="box_poll">
<vte:params>
<vte:param name="search_pid" value="{poll.id}" />
<vte:param name="poll_list" value="1" />
</vte:params>
<vte:template>
<div id="poll_answer_list">
<vte:if test="{answer_list}">
<vte:foreach item = "answer" from = "{answer_list}" key="index">
<div class="poll_line">
<span class="poll_answer_title"><vte:value select="{answer.answer}" /></span>
<img src="{VIVVO_THEME}img/poll_bar.gif" style="width:{answer.get_percent|'3'}px;height:15px;" />
(<vte:value select="{answer.vote}" /> <vte:value select="{LNG_PLUGIN_POLL_NUMBER_VOTES}" />)
</div>
</vte:foreach>
(<vte:value select="{answer.all_votes}" />)
</vte:if>
</div>
</vte:template>
</vte:box>

theodore
01-20-2009, 12:27 PM
Ok I try it and..... yes works :)


Thaaaanks


.

shketuljko
01-20-2009, 12:55 PM
Nice :)
No problem ;)

Big Island
01-26-2009, 03:23 PM
Excellent. How can we display percentage rather than total number of votes?

krcko
01-26-2009, 04:37 PM
{answer.get_percent}?

but I'm not sure I understand what you want...

damic
01-26-2009, 04:39 PM
I'd actually be interested in knowing this too. Also - is there a way that I can allow multiple votes?

Big Island
01-26-2009, 05:02 PM
Instead of showing the number of votes in the poll plugin (reader side, not admin side) we would like to show the percentage.

krcko
01-26-2009, 07:59 PM
open {TEMPLATE DIR}/box/plugin_poll.tpl, around line 33 you should find:

<vte:value select="{answer.vote}" />

replace that line with:

<vte:value select="{answer.get_percent}" />%

damic
01-26-2009, 11:13 PM
Question on that krcko... that new line of code works perfect on the actual poll (on the page - such as main page)... but when clicking view all polls.... it still shows number of votes rather than percentage. Is that possible to change too? Thanks!

krcko
01-27-2009, 08:27 AM
yes it's possible, just open {TEMPLATE DIR}/plugin/poll.tpl and replace this line (should be at line 25):

(<vte:value select="{answer.vote}" /> <vte:value select="{LNG_PLUGIN_POLL_NUMBER_VOTES}" />)

with this one:

(<vte:value select="{answer.get_percent}" />%)

damic
01-27-2009, 01:28 PM
That seemed to fix it krcko - thanks much.

Another question on the polls though... is there a way that I can possibly remove the "cookie" control... meaning someone can vote multiple times? This particular client really wants people to be able to do that for some reason.

krcko
01-27-2009, 05:28 PM
you may try this (haven't tested but it should work):

- open {VIVVO ROOT}/plugins/poll/poll.class.php, around line 208 you should find this code:

function is_voted(){
if (isset ($_SESSION['vivvo']) && isset($_SESSION['vivvo']['poll']) && $_SESSION['vivvo']['poll'][$this->id]){
return true;
}else{
return false;
}
}

- replace that code with:

function is_voted(){
return false;
}

damic
01-27-2009, 07:04 PM
Thanks krcko! That seems to be working just fine. Thanks much for the info -

krcko
01-27-2009, 08:28 PM
np, glad that i can help :)

dojen
02-03-2009, 11:17 PM
thanks it worked!:)

zontech
08-23-2010, 09:55 AM
@ various contributors,

Going back quite a ways to this code from krcko

yes it's possible, just open {TEMPLATE DIR}/plugin/poll.tpl and replace this line (should be at line 25):
Code:

(<vte:value select="{answer.vote}" /> <vte:value select="{LNG_PLUGIN_POLL_NUMBER_VOTES}" />)

with this one:
Code:

(<vte:value select="{answer.get_percent}" />%)

I also wanted to show poll results ONLY as percentages - not actual number of votes.
However, none of the code shown in previous posts seems to work. (Yes cache(s) cleared appropriately.)

Set up with original fileset supplied, as soon as someone votes the poll displays the actual number of votes.
Clicking on 'All Polls' then reveals the percentages.
Then clicking on back button holds the display as 'Percentages'.

But I don't want actual number to be shown at any time.

Anyone got the magic code to achieve this pls?

NB Still using 4.1.5.2 - it's all pretty stable so not game to upgrade until all the plugins etc work.


TIA