Page 1 of 1

serendipity_plugin_pollbox

Posted: Tue Nov 29, 2005 10:15 am
by uptoome
I added the Poll plugin, and created a poll with 'yes' and 'no' as choices. I did a test, selecting the 'no' option. The page was refreshed but both the 'yes' and 'no' percentages and vote counts were displayed as 0% and 0, respectively. I had to refresh the page to see the correct numbers. Is refreshing really required?

browser = firefox 1.0.4

hmmm... after refreshing the page, I now have a total vote count of 2, but yes votes -> 0 and no votes -> 1

Re: serendipity_plugin_pollbox

Posted: Tue Nov 29, 2005 10:44 am
by garvinhicking
Which version of the poll plugin and which serendipity version are you using? Are you using both the event and the sidebar plugin, or only the sidebar plugin?

A URL to your site would also be helpful.

Regards,
Garvin

Posted: Tue Nov 29, 2005 11:02 am
by uptoome
Polls ver -> 2.05
Serendipity ver -> 0.9
Sidebar only
http://www.iamsickandtiredof.com

Posted: Tue Nov 29, 2005 12:12 pm
by garvinhicking
Try to install the event plugin as well, I think this should help

Regards,
Garvin

Posted: Tue Nov 29, 2005 7:29 pm
by uptoome
Both plugins (ver 2.05) are now installed. I cast another 'no' vote. The page was refreshed and the %, totals were displayed. There were 3 no votes, 0 yes votes. The total votes was shown as 4.

Here are the contents of the serendipity_polls and serendipity_polls_options tables;

mysql> select * from serendipity_polls_options;
+----+--------+-------+-------+-----------+
| id | pollid | title | votes | timestamp |
+----+--------+-------+-------+-----------+
| 9 | 4 | Yes | 0 | NULL |
| 10 | 4 | No | 4 | NULL |
+----+--------+-------+-------+-----------+
2 rows in set (0.00 sec)

mysql> select * from serendipity_polls;
+----+-------------------------------------------------------------------------------------+---------+--------+-------+------------+
| id | title | content | active | votes | timestamp |
+----+-------------------------------------------------------------------------------------+---------+--------+-------+------------+
| 4 | Are you satisfied with the job your elected Senators and Representatives are doing? | NULL | 1 | 5 | 1133251683 |
+----+-------------------------------------------------------------------------------------+---------+--------+-------+------------+
1 row in set (0.00 sec)

Posted: Tue Nov 29, 2005 7:41 pm
by garvinhicking
Hm, but the SQL data says there were 4 votes? Can you start with a fresh voting, now that you have both plugins installed?

(I'm sorry, I rarely use that plugin)

Regards,
Garvin

Posted: Tue Nov 29, 2005 7:47 pm
by uptoome
The polls and polls_options tables get out-of-synch when the Go! button is clicked, but no choice has been selected. The polls.votes column is incremented; the polls_options columns aren't.

Posted: Tue Nov 29, 2005 7:49 pm
by garvinhicking
I have noted that down and will look at it somewhen this week, thanks for giving me a pointer!

Regards,
Garvin

Posted: Tue Nov 29, 2005 8:48 pm
by uptoome
How about this change in showPoll() ?

Code: Select all


function showPoll($pollid = null) {
        global $serendipity;

        echo '<strong>' . $this->poll['title'] . '</strong>';
        echo '<form action="' . serendipity_currentURL() . '" method="post">';

        if ($pollid || $_SESSION["pollHasVoted{$this->poll['id']}"] || $serendipity['COOKIE']["p
ollHasVoted{$this->poll['id']}"]) {
            $this->showResults();
        } elseif (isset($serendipity['POST']['goVote'])) {
            $_SESSION["pollHasVoted{$this->poll['id']}"] = true;
            $this->setCookie("pollHasVoted{$this->poll['id']}", 'true');
// ---- bgn ----
            if ( isset($serendipity['POST']['vote']) ) {
                $this->addVote($this->poll['id'], $serendipity['POST']['vote']);
                $this->showResults();
            } else {
                $this->showOptions();
            }
// ---- end ----
        } else {
            $this->showOptions();
        }
        echo '</form>';
    }

[/code]

Posted: Wed Nov 30, 2005 1:26 pm
by garvinhicking
Actually, that's nearly perfect. I just committed the change!

Regards,
Garvin