1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Duplicate Poll results percentage incorrect if multiple votes allowed

Discussion in 'Resolved Bug Reports' started by MtoR, Sep 25, 2016.

  1. MtoR

    MtoR Well-Known Member


    When the option to allow more than 1 vote per user is set, the poll results in percentage are wrong.

    This is due to the fact that you make the following computation in templates:
    {xen:number {xen:calc "100 * {$response.response_vote_count} / {$poll.voter_count}"}, 1}%
    while your voter_count is using uniquer users.

    I did a quick not optimized fix by adding the following to the preparePoll function before the return:
    if ($poll['max_votes'] > 1)
    $votesCount 0;
    $poll['responses'] AS $response)
    $votesCount += $response['response_vote_count'];
    $poll['voter_count'] = $votesCount;
    But I am pretty sure you'll have a cleaner way ;)

  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. MtoR

    MtoR Well-Known Member

    Ah ok, thats' a bit confusing though but well.

Share This Page