Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: mattchewone on June 29, 2009, 04:13:51 PM

Title: Viewing Who voted in polls
Post by: mattchewone on June 29, 2009, 04:13:51 PM
Hi,

Is there a way to view who voted what in a poll?

Many Thanks

Matt
Title: Re: Viewing Who voted in polls
Post by: N3RVE on June 30, 2009, 12:43:53 PM
Run this query in phpMyAdmin (What is phpMyAdmin? (http://www.simplemachines.org/community/index.php?topic=21919.0))

Code (Run) Select
SELECT smf_members.realName, smf_poll_choices.label
FROM smf_log_polls
INNER JOIN smf_members ON smf_log_polls.ID_MEMBER = smf_members.ID_MEMBER
INNER JOIN smf_poll_choices ON smf_log_polls.ID_CHOICE = smf_poll_choices.ID_CHOICE
AND smf_log_polls.ID_POLL = smf_poll_choices.ID_POLL
WHERE smf_log_polls.ID_POLL = 42


Replace ID_POLL = 42 with the ID of the poll you want to check.

-[n3rve]
Title: Re: Viewing Who voted in polls
Post by: Nao 尚 on June 30, 2009, 12:47:14 PM
Or use the search engine ;)

Who voted what? (http://custom.simplemachines.org/mods/index.php?mod=347)
Title: Re: Viewing Who voted in polls
Post by: mattchewone on July 01, 2009, 02:27:55 PM
Quote from: Nao 尚 on June 30, 2009, 12:47:14 PM
Or use the search engine ;)

Who voted what? (http://custom.simplemachines.org/mods/index.php?mod=347)

not compatible with 2.0

Thanks
Title: Re: Viewing Who voted in polls
Post by: Nao 尚 on July 01, 2009, 05:53:53 PM
Hmm I'm using it on Noisen... Which runs the latest SMF2...
Of course if you don't feel like fixing the mod here and there, I can't help much.
Title: Re: Viewing Who voted in polls
Post by: STS on October 16, 2009, 05:23:53 PM
How do you know what poll it is, the number?
Title: Re: Viewing Who voted in polls
Post by: Yahmez on October 16, 2009, 06:55:14 PM
Quote from: STS on October 16, 2009, 05:23:53 PM
How do you know what poll it is, the number?
The topic number that the poll is in. Hover you mouse over a link to a topic to see the number in the url. (e.g. http://www.yoursite.com/community/index.php?topic=384.0)
Title: Re: Viewing Who voted in polls
Post by: Yahmez on October 16, 2009, 06:55:41 PM
Quote from: Nao/Gilles on July 01, 2009, 05:53:53 PM
Hmm I'm using it on Noisen... Which runs the latest SMF2...
Of course if you don't feel like fixing the mod here and there, I can't help much.
Any tips for making the mod work in 2.0?
Title: Re: Viewing Who voted in polls
Post by: STS on October 16, 2009, 09:01:43 PM
Thank you.
Title: Re: Viewing Who voted in polls
Post by: Nao 尚 on October 17, 2009, 07:20:55 AM
Quote from: Yahmez on October 16, 2009, 06:55:41 PM
Any tips for making the mod work in 2.0?
Maybe if you'd asked 2 years ago, back when I converted it?
Right now, I can just tell you it's easy to do...
Title: Re: Viewing Who voted in polls
Post by: Yahmez on October 17, 2009, 09:27:23 AM
Quote from: Nao/Gilles on October 17, 2009, 07:20:55 AM
Quote from: Yahmez on October 16, 2009, 06:55:41 PM
Any tips for making the mod work in 2.0?
Maybe if you'd asked 2 years ago, back when I converted it?
Right now, I can just tell you it's easy to do...
Well I have only been here 9 months... Oh well, maybe when SMF 7 comes out I'll go back to 2007 and ask you then.  ;D
Title: Re: Viewing Who voted in polls
Post by: SgtMic on December 11, 2009, 01:31:40 AM
Quote from: Nao/Gilles on October 17, 2009, 07:20:55 AM
Right now, I can just tell you it's easy to do...
I saw the changes in /sources/managepermissions as easy.
The changes to /default/display.template were out of my realm.

Can you show us the correct way to make those changes?
Title: Re: Viewing Who voted in polls
Post by: Nao 尚 on December 11, 2009, 03:36:54 AM
I only see one thing to replace in the Display template...?

foreach ($context['poll']['options'] as $option)
echo '
   <dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
   <dd class="middletext', $option['voted_this'] ? ' voted' : '', '">', $context['allow_poll_view'] ? '<span class="percent">' . $option['votes'] . ' (' . $option['percent'] . '%)</span>' . $option['bar_ndt'] : '', '</dd>';


Becomes:

foreach ($context['poll']['options'] as $option)
{
echo '
   <dt class="middletext', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
   <dd class="middletext', $option['voted_this'] ? ' voted' : '', '">', $context['allow_poll_view'] ? '<span class="percent">' . $option['votes'] . ' (' . $option['percent'] . '%)</span>' . $option['bar_ndt'] : '';
if ($context['allow_poll_view'] && allowedTo('poll_view_voters') && !empty($context['poll']['options'][$option['id_option']]['voters']))
foreach ($context['poll']['options'][$option['id_option']]['voters'] as $voter)
echo ' <small><a href="', $scripturl, strpos($voter['id_member'], '.') === false ? '?action=profile;u=' . $voter['id_member'] . '">' . $voter['real_name'] : '?action=trackip;searchip=' . $voter['id_member'] . '">' . $voter['id_member'], '</a></small>';
}


Well, at least that's direct from my noisen.com source code.
Title: Re: Viewing Who voted in polls
Post by: SgtMic on December 11, 2009, 03:38:09 AM
I'll give it a shot. Thanks.
Title: Re: Viewing Who voted in polls
Post by: SgtMic on December 11, 2009, 03:46:45 AM
Get this error trying to install via package manager:
Fatal error: Call to undefined function db_query() in /home/wamarin/public_html/wammc/Packages/temp/wvwDB.php on line 9

Lines 1-12
<?php

if ($context['uninstalling'])
{
  
db_query("DELETE IGNORE FROM {$db_prefix}settings WHERE variable='whovotedwhatMode' LIMIT 1"__FILE____LINE__);
}
else
{
  
db_query("INSERT IGNORE INTO {$db_prefix}settings (variable, value) VALUES ('whovotedwhatMode', 'disabled')"__FILE____LINE__);
}

?>
Title: Re: Viewing Who voted in polls
Post by: Nao 尚 on December 11, 2009, 04:37:23 AM
Well... Obviously you're supposed to use $smcFunc['db_query'] in SMF2 or just declare a fake db_query that emulates it.)
Ever made a SMF2 package before?
Title: Re: Viewing Who voted in polls
Post by: SgtMic on December 11, 2009, 12:09:10 PM
No, I have not made an SMF2 package before. That's why I'm here asking for help. :)
Title: Re: Viewing Who voted in polls
Post by: Ray Cardillo on May 07, 2012, 06:00:17 PM
Quote from: mattchewone on June 29, 2009, 04:13:51 PM
Is there a way to view who voted what in a poll?

I know this is an old thread, but check out this new mod that provides voter visibility with several advanced options.

http://custom.simplemachines.org/mods/index.php?mod=3373
Title: Re: Viewing Who voted in polls
Post by: dkpeppard on September 03, 2013, 12:54:40 PM
Quote from: N3RVE on June 30, 2009, 12:43:53 PM
Run this query in phpMyAdmin (What is phpMyAdmin? (http://www.simplemachines.org/community/index.php?topic=21919.0))

Code (Run) Select
SELECT smf_members.realName, smf_poll_choices.label
FROM smf_log_polls
INNER JOIN smf_members ON smf_log_polls.ID_MEMBER = smf_members.ID_MEMBER
INNER JOIN smf_poll_choices ON smf_log_polls.ID_CHOICE = smf_poll_choices.ID_CHOICE
AND smf_log_polls.ID_POLL = smf_poll_choices.ID_POLL
WHERE smf_log_polls.ID_POLL = 42


Replace ID_POLL = 42 with the ID of the poll you want to check.

-[n3rve]

I realize this is an old post, but I think the information is still valid.

I tried running this query in my phpAdmin. I changed to the correct poll ID number but I get the following error:

#1054 - Unknown column 'smf_members.realName' in 'field list'

I am a phpAdmin novice. Can you direct me to what I may be doing wrong, please? I am currently using Simple Machines 2.0.5.
Title: Re: Viewing Who voted in polls
Post by: Arantor on September 03, 2013, 12:56:30 PM
Then apparently it isn't still valid :P

The column names were changed in 2.0.

Try this:
SELECT smf_members.real_name, smf_poll_choices.label
FROM smf_log_polls
INNER JOIN smf_members ON smf_log_polls.id_member = smf_members.id_member
INNER JOIN smf_poll_choices ON smf_log_polls.id_choice = smf_poll_choices.id_choice
AND smf_log_polls.id_poll = smf_poll_choices.id_poll
WHERE smf_log_polls.id_poll = 42
Title: Re: Viewing Who voted in polls
Post by: dkpeppard on September 03, 2013, 01:05:57 PM
Quote from: Arantor on September 03, 2013, 12:56:30 PM
Then apparently it isn't still valid :P

The column names were changed in 2.0.

Try this:
SELECT smf_members.real_name, smf_poll_choices.label
FROM smf_log_polls
INNER JOIN smf_members ON smf_log_polls.id_member = smf_members.id_member
INNER JOIN smf_poll_choices ON smf_log_polls.id_choice = smf_poll_choices.id_choice
AND smf_log_polls.id_poll = smf_poll_choices.id_poll
WHERE smf_log_polls.id_poll = 42


Thanks for the quick reply! :)

Your code worked without any error, but I also didn't get any username results.

When I ran the code you supplied, I was returned this:

'MySQL returned an empty result set (i.e. zero rows). (Query took 0.0004 sec)'

At least two active users have voted in the poll, but I see no usernames returned. What should I try next, please?
Title: Re: Viewing Who voted in polls
Post by: Arantor on September 03, 2013, 01:17:48 PM
Then you could always try installing the Voter Visibility mod...
Title: Re: Viewing Who voted in polls
Post by: dkpeppard on September 03, 2013, 01:25:06 PM
Quote from: Arantor on September 03, 2013, 01:17:48 PM
Then you could always try installing the Voter Visibility mod...

Yeah, I was hoping to use something like this code query. It would not require me to install any modules on my forums, and I only use polls every so often.

Thank you again for your assistance.
Title: Re: Viewing Who voted in polls
Post by: dkpeppard on September 04, 2013, 06:00:43 PM
Quote from: Arantor on September 03, 2013, 01:17:48 PM
Then you could always try installing the Voter Visibility mod...

A little more background why I was hoping the MySQL script would work:

The other reason I don't just install the Voter Visibility mod is because I am one of those users who have issues with the automatic install of mods on my forums. I always have to do manual installs of forum updates, I can never use the automatic package install. The automatic process always fails.

I have my forums on a hosted site. Perhaps if I hosted my forums locally, I wouldn't have any issue, but since I have to work with my hosting provider, I have never been able to get any of the automated processes to work correctly.

I started trying to do the Voter Visibility mod install, but there is so much to edit manually, I was concerned I would either break something on my current forums, or I would break something on my forums when the next version update, such as 2.0.6, came out.
Title: Re: Viewing Who voted in polls
Post by: Bushstar on October 20, 2013, 08:53:08 AM
The information on getting the poll number does not seem correct in this thread. The poll number is not the topic number.

To get the poll number view the source of the page and look for poll=

The number after poll= is your poll number.
Title: Re: Viewing Who voted in polls
Post by: ajberry on January 03, 2014, 09:19:58 AM
If you select the data from smf_polls


SELECT *
FROM smf_polls


You will see the id's of all of your polls to then feed into the above mentioned query