Test:Poll

From EcoReality

Proposal for implementing a poll system.

Contents

Operation:

  1. A poll-taker starts a new page
    1. Any amount of text before and after the <poll></poll> is treated as normal Wikitext.
    2. Inside the <poll></poll> is the following XML:
      1. exactly one expiration date (wrapped in <expires></expires>), after which the poll stops taking entries, and only displays results
      2. exactly one <title>, which is shown at the top of the poll
      3. any number of poll <item> items
      4. zero or one <other />, which results in a fill-in field
    3. upon saving, it would be nice if the poll could be write-protected
  2. A person visits the page
    1. If the visitor's username or IP address has already voted, that fact is noted and the poll results are displayed.
    2. If the expiration time has passed, the poll results are displayed.
    3. Otherwise, a form is generated with the items previously entered.
      1. Upon accepting the form, the poll results are displayed.

Implementation:

  1. raw database access using PHP/MySQL calls for now
    1. possibly use MediaWiki's generalized database interface later
  2. POLL table holds per-poll data, keyed by <expires>
    1. AUTHOR username of author
    2. TITLE text
  3. ITEM table holds items, foreign key <expires>
  4. RESULTS table holds results, key <expires> and username or IP
  5. display histograms using ImageMagick or GD

Issues/Problems:

  • how to scrape the screen after fill-in (target of <form>?)
  • should items be kept in entered order, or alphabetized (both create bias), or randomized? (Authoring option?)
  • should stuff entered as <other /> be dynamically added to the ITEM table, and displayed on future views? (Authoring option?)
  • allow wikitext or HTML in title and items for some simple formatting?
  • menu syntax sounds like a lot of work for a tiny bit of user comfort. Don't design it out -- maybe V2.

Example Code:

<poll><br>
    <expires>200502152200</expires> <!-- After this date/time, no new data is collected, but results are shown. /><br>
    <title>Where should we make our home?</title><br>
    <menu>In a<br>
        <menuitem>boat</menuitem><br>
        <menuitem>car</menuitem><br>
        <menuitem>closet</menuitem><br>
    </menu><br>
    <item>In the zoo.</item><br>
    <item>In the school.</item><br>
    <item>In a tree.</item><br>
    <other /> <!-- Allows an "other" choice, with a blank to collect additional choices /><br>
</poll>

Example Output:

<poll>

<expires>200502152200</expires> <!-- After this date/time, no new data is collected, but results are shown. />
<title>Where should we make our home?</title>
<menu>In a
<menuitem>boat</menuitem>
<menuitem>car</menuitem>
<menuitem>closet</menuitem>
.</menu>
<item>In the zoo.</item>
<item>In the school.</item>
<item>In a tree.</item>
<other /> <!-- Allows an "other" choice, with a blank to collect additional choices />

</poll>

entry points