Jump to content

Polls not working correctly (random)


Recommended Posts

We use a lot of polls, with a simply Yes or No vote. Most of the time, they work perfectly. However, over the last month we've had two separate polls. When a person places their vote, it shows to that person that their vote has been cast, but it does not tally it in the results.

Using phpMyAdmin, and after researching inside the core_polls database table, I see the following:

choices field

{"1":{"question":"Please place your vote.","multi":0,"choice":["Yes","No"],"votes":[0,1]}}

votes field:

5

As you can see, these do not equate in terms of number of votes. There should be a sum total of 5 votes in the choices field. In other words, it should look something like the following in order for the tally to be be shown correctly in the poll on the forum.

{"1":{"question":"Please place your vote.","multi":0,"choice":["Yes","No"],"votes":[4,1]}}

This has happened twice now, but it is random. Most polls work, but now, two have not, and have had this problem occur in both instances. Seems like it could be a bug. Please help. 

Thank you.

Link to comment
Share on other sites

30 minutes ago, NAWAC said:

However, over the last month we've had two separate polls.

Sorry, the above should have said, "However, over the last month we've had two separate polls that have not work correctly."

Link to comment
Share on other sites

Not having access to the poll or your community. My suggestion then would be to isolate any third party applications/plugins to see if they are related. Unfortunately, we have not heard any reports of polls not working correctly elsewhere.

Link to comment
Share on other sites

The first time I found this happening was March 15, 2023. Was there an update near this date that could have caused it?

I looked in the Admin logs and I found I did a Community Update on March 08, 2023.

Link to comment
Share on other sites

After further research, I noticed that it seems like "Yes" votes are not getting recorded or tallied, but "No" votes are. In the database "Yes" votes are recorded as "0" and "No" votes are recorded as "1", simply because the "Yes" is the first choice and "No" is the second choice. It seems these "0" aren't getting counted and added properly in the database. 

Please refer back to my original post in this thread...

{"1":{"question":"Please place your vote.","multi":0,"choice":["Yes","No"],"votes":[0,1]}}
Edited by NAWAC
Link to comment
Share on other sites

I've ran a test poll (v4.7.9 beta 1 as that's what my test site is at) and it was fine.  Simple yes/no question, 3 people voted, 2 for yes and 1 for no.  However, what has been recorded in core_polls.choices is different to what you posted above.

{"1":{"question":"Choose ","multi":0,"choice":{"1":"Yes","2":"No"},"votes":{"1":2,"2":1}}}

 

Link to comment
Share on other sites

  • 2 weeks later...

So, I really don't know what to do from here.  This is no longer random, but every instance on a simple Yes/No poll, the Yes votes are no longer getting tallied. I'm a paying customer but I don't know why I can't get support from the developer of this software. I'm a little frustrated at this point. I've done everything told I should do, yet the bug exists.

Link to comment
Share on other sites

This is an issue that cannot be duplicated in a new stock/default installation. That means there is something unique to your setup or installation. That could be a plugin or something else, but without access to troubleshoot, how do you expect them to be able to help you?

Simply saying it doesn’t work does not help them to help you. 

Edited by Randy Calvert
Link to comment
Share on other sites

11 hours ago, Randy Calvert said:

That could be a plugin or something else, but without access to troubleshoot, how do you expect them to be able to help you?

 

I've disabled all plugins and 3rd party customizations during the testing and it still happens. 

I can create a separate Admin account for them giving them access to the points of interest...I've done it before. 

Link to comment
Share on other sites

On 3/26/2023 at 2:30 PM, Richard Arch said:

I've ran a test poll (v4.7.9 beta 1 as that's what my test site is at) and it was fine.  Simple yes/no question, 3 people voted, 2 for yes and 1 for no.  However, what has been recorded in core_polls.choices is different to what you posted above.

{"1":{"question":"Choose ","multi":0,"choice":{"1":"Yes","2":"No"},"votes":{"1":2,"2":1}}}

 

I don't know why, but your string inside the database is different than mine. And your choices are not the same as mine. Note, you have 1 for Yes, and 2 for No.

{"1":{"question":"Choose ","multi":0,"choice":{"1":"Yes","2":"No"},"votes":{"1":2,"2":1}}}

Mine is a simple Yes, No. 

On 3/26/2023 at 9:24 AM, NAWAC said:

{"1":{"question":"Please place your vote.","multi":0,"choice":["Yes","No"],"votes":[0,1]}}

It was configured this way due to a post submitted, here. Where @Stuart Silvester explains how to create Yes/No polls using API. And in his post he states, 

/* poll variables below */
,'poll_title'    => 'Cast your vote'
	// poll_options: Array of objects with keys 'title' (string), 'answers' (array of objects with key 'value' set to the choice) and 'multichoice' (bool)
,'poll_options[1][title]' => urlencode('Make your choice, either Yes or No:')
	,'poll_options[1][answers][0][value]'        => 'Yes'
	,'poll_options[1][answers][1][value]'        => 'No'
	,'poll_options[1][multichoice]'     => '0'

,'poll_public'    => '0' // bool     Make the poll public
,'poll_only'    => '0' // bool     Make this a poll-only topic

 

Note the answers are configured with the answer array starting with 0 for Yes, and 1 for the No answer. 

'poll_options[1][answers][0][value]' => 'Yes' 

'poll_options[1][answers][1][value]' => 'No'

Is it possible that if someone votes Yes (which is sent as a "0" to the system to process), the system doesn't know what to do with the "0"?  Should the poll be set up like this in order to count the vote?

'poll_options[1][answers][1][value]' => 'Yes' 

'poll_options[1][answers][2][value]' => 'No'

 

 

 

 

 

Link to comment
Share on other sites

I just confirmed and this is indeed the case. I reconfigured the string, using phpMyAdmin, in the core_polls table to the following for this poll:

{"1":{"question":"Choose ","multi":0,"choice":{"1":"Yes","2":"No"},"votes":{"1":0,"2":1}}}

And it worked successfully and tallied the votes correctly.

However, when the core_polls table field is set to this...

{"1":{"question":"Please place your vote.","multi":0,"choice":["Yes","No"],"votes":[0,1]}}

it does not work!

So, @Stuart Silvester's example, no longer works as of about February 2023. 

When creating a poll via API, you cannot put this below (note the 'answers' array keys)...

/* poll variables below */
,'poll_title'    => 'Cast your vote'
	// poll_options: Array of objects with keys 'title' (string), 'answers' (array of objects with key 'value' set to the choice) and 'multichoice' (bool)
,'poll_options[1][title]' => urlencode('Make your choice, either Yes or No:')
	,'poll_options[1][answers][0][value]'        => 'Yes'
	,'poll_options[1][answers][1][value]'        => 'No'
	,'poll_options[1][multichoice]'     => '0'

,'poll_public'    => '0' // bool     Make the poll public
,'poll_only'    => '0' // bool     Make this a poll-only topic

You must put this below (again, note the 'answers' array keys)...

/* poll variables below */
,'poll_title'    => 'Cast your vote'
	// poll_options: Array of objects with keys 'title' (string), 'answers' (array of objects with key 'value' set to the choice) and 'multichoice' (bool)
,'poll_options[1][title]' => urlencode('Make your choice, either Yes or No:')
	,'poll_options[1][answers][1][value]'        => 'Yes'
	,'poll_options[1][answers][2][value]'        => 'No'
	,'poll_options[1][multichoice]'     => '0'

,'poll_public'    => '0' // bool     Make the poll public
,'poll_only'    => '0' // bool     Make this a poll-only topic

This appears to be a bug with the code as it worked before, and now it doesn't unless it is configured as I've shown. You cannot have the array key starting with poll_options[1][answers][0][value] because the '0' is submitted to the system and it doesn't know how to handle or count the the '0' as a legitimate value or response when someone votes.

Edited by NAWAC
Link to comment
Share on other sites

2 hours ago, Stuart Silvester said:

I have created a bug report, I'll look into this.

Did something change at all regarding the 0 (zero) value in this version?

Although it shows in the table definition:

5xxxBYI.jpg

 

I don't see it when I see the column definition:

NhxvfZ2.jpg

 

The field seems ok:

$return['posts'] = new \IPS\Helpers\Form\Number( 'sas_app_restriction_posts', $item ? $item->restriction_posts : 0, FALSE, array( 'min' => 0, 'unlimited' => 0, 'unlimitedLang' => 'no_restriction' ), NULL, NULL, NULL );

Saving:

		if( isset( $values['sas_app_restriction_posts'] ) )
		{
			$this->restriction_posts = $values['sas_app_restriction_posts'];
		}

 

I have several columns throwing errors when saving the default value, which is 0:

Quote

IPS\Db\Exception thrown with message "Incorrect integer value: '' for column `47x`.`staffappsystem_applications`.`sas_app_restriction_posts` at row 1"

Stacktrace:
#9 IPS\Db\Exception in C:\wamp64\www\47x\system\Db\Db.php:679
#8 IPS\_Db:preparedQuery in C:\wamp64\www\47x\system\Db\Db.php:1159
#7 IPS\_Db:update in C:\wamp64\www\47x\system\Patterns\ActiveRecord.php:520
#6 IPS\Patterns\_ActiveRecord:save in C:\wamp64\www\47x\applications\staffappsystem\sources\Applicationrecord\Applicationrecord.php:595
#5 IPS\staffappsystem\_Applicationrecord:processForm in C:\wamp64\www\47x\applications\staffappsystem\modules\front\general\view.php:573
#4 IPS\staffappsystem\modules\front\general\_view:edit in C:\wamp64\www\47x\system\Dispatcher\Controller.php:107
#3 IPS\Dispatcher\_Controller:execute in C:\wamp64\www\47x\system\Content\Controller.php:50
#2 IPS\Content\_Controller:execute in C:\wamp64\www\47x\applications\staffappsystem\modules\front\general\view.php:36
#1 IPS\staffappsystem\modules\front\general\_view:execute in C:\wamp64\www\47x\system\Dispatcher\Dispatcher.php:153
#0 IPS\_Dispatcher:run in C:\wamp64\www\47x\index.php:13

As you can see, it is trying to save '' instead of 0.

Feel free to split my post into a new topic if you think it's necessary.

Thank you.

Edited by Adriano Faria
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...