Res facta quae tamen fingi potuit (pauamma) wrote in suggestions,
Res facta quae tamen fingi potuit
pauamma
suggestions

Add "as percentage of poll-takers" to "select one" or multiple choice questions

Title
Add "as percentage of poll-takers" to "select one" or multiple choice questions

Short, concise description of the idea
What the subject says.

Full description of the idea
Because of how HTML works and how LiveJournal polls are implemented, someone who didn't check any of the boxes in a multiple choice question will be counted as not having answered that question at all, not as having answered no to all options. While this is an interesting statistic to provide in most cases, it sometimes gives nonsensical results, such as when the question comprises a single checkbox, as the percentage is always 100% in that case.

This change would provide an additional percentage, where 100% would be "everyone who answered the poll, including people who didn't answer that question, or whose answer LiveJournal didn't see."

That additional percentage will be present everywhere the current one is, for consistency, even though they would be the same for some question types.

An ordered list of benefits
  • More useful poll statistics.

An ordered list of problems/issues involved
  • May increase server load for rendering polls.
  • May confuse screenscraper programs.

An organized list, or a few short paragraphs detailing suggestions for implementation
  • There's no database field that counts how many people answered a poll. The trade-off between adding that field and counting each time the poll is rendered is unclear to me, so I took the easy way out and used only data already available.
  • In a nutshell, the patch below counts how many answered the poll, then uses that information to compute the extra percentage for all questions that already display a percentage.
  • Warning: not tested, use at your own risk, etc.
  • --- livejournal/cgi-bin/LJ/Poll.pm.rev11109 Sat May 19 10:54:55 2007
    +++ livejournal/cgi-bin/LJ/Poll.pm Sat May 19 12:20:17 2007
    @@ -765,6 +765,18 @@
    $ret .= LJ::Lang::ml('poll.security', { 'whovote' => LJ::Lang::ml('poll.security.'.$self->whovote),
    'whoview' => LJ::Lang::ml('poll.security.'.$self->whoview) });

    + # How many users answered? (XXX memcache?)
    + if ($self->is_clustered) {
    + $sth = $self->journal->prepare("SELECT COUNT(*) FROM pollsubmission2 " .
    + "WHERE pollid=? AND journalid=?");
    + $sth->execute($pollid, $self->journalid);
    + } else {
    + $sth = $dbr->prepare("SELECT COUNT(*) FROM pollsubmission WHERE pollid=?");
    + $sth->execute($pollid);
    + }
    +
    + my ($users_took_poll) = $sth->fetchrow_array;
    +
    ## go through all questions, adding to buffer to return
    foreach my $q (@qs) {
    my $qid = $q->pollqid;
    @@ -945,7 +957,7 @@

    # displaying results
    my $count = $itvotes{$itid}+0;
    - my $percent = sprintf("%.1f", (100 * $count / ($usersvoted||1)));
    + my $percent = sprintf("%.1f %.1f", (100 * $count / ($usersvoted||1)), (100 * $count / ($users_took_poll||1)));
    my $width = 20+int(($count/$maxitvotes)*380);

    if ($do_table) {
Tags: polls, § no status, § patch available
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 18 comments