Jump to content

Wikipedia:Wikipedia Signpost/Templates/Voter/Documentation: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
→‎Test cases: {{clear}}
moved
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{important|1=Do not transclude this template directly! Use {{tl|Signpost filler poll}} instead; for documentation see [[Wikipedia:Wikipedia_Signpost/Newsroom/Style#More on layout|our style guidelines]].}}
{{important|Do not transclude this template directly! Instead please use the set-up procedure outlined below. This is because one of the poll elements—expiry time—is coded in a time-sensitive way. Transcluding directly will likely result in your poll closing automatically! }}
{{Lua|Module:Signpost poll}}


== Parameters ==
== Parameters ==
Line 8: Line 9:
| image = <!-- An image for the top-right corner of the sidebar; defaults to the Signpost logo. -->
| image = <!-- An image for the top-right corner of the sidebar; defaults to the Signpost logo. -->
| question = <!-- Question under consideration in the poll. -->
| question = <!-- Question under consideration in the poll. -->
| option_one = <!-- Name of the first option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option1 = <!-- Name of the first option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option_one_color = <!-- Color of the first option choice; defaults to #006699, Foundation blue. -->
| option1color = <!-- Color of the first option choice; defaults to #006699, Foundation blue. -->
| option_one_vote_collection_page = <!-- Where the votes for option one will be collected. Defaults to the test poll. -->
| option2 = <!-- Name of the second option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option_two = <!-- Name of the second option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option2color = <!-- Color of the first option choice; defaults to #339966, Foundation green. -->
| option_two_color = <!-- Color of the first option choice; defaults to #339966, Foundation green. -->
| option3 = <!-- Optional. Where the votes for option two will be collected. Defaults to the test poll. -->
| option_two_vote_collection_page = <!-- Where the votes for option two will be collected. Defaults to the test poll. -->
| option3color = <!-- Color of the first option choice; defaults to #990000, Foundation red. -->
| option_three = <!-- Optional. Where the votes for option two will be collected. Defaults to the test poll. -->
| votepage = <!-- The page at which all of the votes will be accrued. -->
| option_three_color = <!-- Color of the first option choice; defaults to #990000, Foundation red. -->
| option_three_vote_collection_page = <!-- Optional: where the votes for option three will be collected. -->
| min_votes = <!-- The minimum number of votes that must accrue before the template begins to display results. Defaults to 10. -->
| min_votes = <!-- The minimum number of votes that must accrue before the template begins to display results. Defaults to 10. -->
| break = <!-- If this parameter is non-empty the votebar is split into two to better accommodate lengthier poll options. -->
| break = <!-- If this parameter is non-empty the votebar is split into two to better accommodate lengthier poll options. -->
| break_on_one = <!-- Breaks after the first votebutton, only. -->
| break_on_two = <!-- Breaks after the second votebutton, only. -->
| overlay = <!-- overlay image; defaults to File:Foundation Logo Transparent.svg. -->
| overlay = <!-- overlay image; defaults to File:Foundation Logo Transparent.svg. -->
| expiry = <!-- The number of days after which the poll is closed; defaults to 14 days. -->
| expiry = <!-- The number of days after which the poll is closed; defaults to 14 days. -->
Line 26: Line 23:
</pre>
</pre>


* '''question''': Question under consideration in the poll. (required)
* '''image''': Changes the image that is displayed in the top-right corner of the poll. As used in the ''Signpost'' other images are not recommended.
* '''votepage''': Page that the votes will be stored on (required). If in doubt, choose <code>''poll location''/Votes</code>.
* '''question''': Question under consideration in the poll.
* '''option_one''': Name of the first option, as reported in the legend and in the vote button. Defaults to <code>Yes</code>.
* '''option1''': Name of the first option, as reported in the legend and in the vote button. Defaults to <code>Yes</code>.
* '''option_one_color''' = Color of the first option choice; defaults to {{legend inline|#006699}}, Foundation blue.
* '''option1color''' = Color of the first option choice; defaults to {{legend inline|#006699}}, Foundation blue.
* '''option2''': Name of the second options, as reported in the legend and in the vote button. Defaults to <code>No</code>.
* '''option_one_vote_collection_page''' = Where the votes for option one will be collected. Defaults to [[Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/Test Poll/Yes]].
* '''option_two''': Name of the second options, as reported in the legend and in the vote button. Defaults to <code>No</code>.
* '''option2color''': Color of the second option choice; defaults to {{legend inline|#339966}}, Foundation green.
* '''option_two_color''': Color of the second option choice; defaults to {{legend inline|#339966}}, Foundation green.
* '''option3''': Optional. Name of the third options, as reported in the legend and in the vote button. No default.
* '''option3color''': Optional. Color of the third option choice; defaults to {{legend inline|#990000}}, Foundation red (if the third option is enabled at all).
* '''option_two_vote_collection_page''': Where the votes for option two will be collected. Defaults to [[Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/Test Poll/No]].
* '''minimum''': Minimum number of votes that must accrue before the poll will display the visualization; before this many votes are made the poll will tell readers that X more votes are needed based on the size of the deficit. Defaults to 10.
* '''option_three''': Optional. Name of the third options, as reported in the legend and in the vote button. No default.
* '''break''': Set to "yes" to break columns between the buttons to allow longer button names. If this is not set, the template will try and auto-detect a sensible value.
* '''option_three_color''': Optional. Color of the third option choice; defaults to {{legend inline|#990000}}, Foundation red (if the third option is enabled at all).
* '''option_three_vote_collection_page''': Optional. Where the votes for option two will be collected. Defaults to [[Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/Test Poll/Maybe]] (if the third option is enabled at all).
* '''min_votes''': Minimum number of votes that must accrue before the poll will display the visualization; before this many votes are made the poll will tell readers that X more votes are needed based on the size of the deficit. Defaults to 10.
* '''break''': Breaks the columns between the buttons to allow longer button names.
* '''break_on_one''': Same as break but only after the first button.
* '''break_on_two''': Same as break but only after the second button
* '''expiry''': The number of days after which the poll is closed; defaults to 14 days (two publication cycles). Note that is this defined from the day that you create the template ''not'' from the day that you actually publish the article!
* '''expiry''': The number of days after which the poll is closed; defaults to 14 days (two publication cycles). Note that is this defined from the day that you create the template ''not'' from the day that you actually publish the article!
* '''header''': Text that goes in the poll header. The default is "''Signpost'' poll".
* '''icon''': Changes the image that is displayed in the top-right corner of the poll. As used in the ''Signpost'' other images are not recommended.
* '''overlay''': Overlay on the stacked bar chart which produces the template's fancy visualization. By default this is [[:File:Foundation Logo Transparent.svg]], a transparent version of the Wikimedia Foundation's logo. With some basic vector editing skills such images are easy to make; requirements for a working overlay are:
* '''overlay''': Overlay on the stacked bar chart which produces the template's fancy visualization. By default this is [[:File:Foundation Logo Transparent.svg]], a transparent version of the Wikimedia Foundation's logo. With some basic vector editing skills such images are easy to make; requirements for a working overlay are:
::*Square image; the transparent Foundation logo is a vector <code>SVG</code> with native resolution of <code>1050x1050</code>.
**Square image; the transparent Foundation logo is a vector <code>SVG</code> with native resolution of <code>1050x1050</code>.
::*Canvas whitespace; The bar chart is not displayed wherever the image canvas is explicitly white.
**Canvas whitespace; The bar chart is not displayed wherever the image canvas is explicitly white.
::*Transparent logo; this is where the chart ''will'' be displayed.
**Transparent logo; this is where the chart ''will'' be displayed.
* '''expiry_subst''': This is a hidden parameter that is automatically substituted in when a poll is tool-assist generated. Do not change it! To change the poll timeline use the '''expiry''' parameter instead.
* '''expiry_year_subst''': This is a hidden parameter that is automatically substituted in when a poll is tool-assist generated. Do not change it! To change the poll timeline use the '''expiry''' parameter instead.

== Setting up a poll ==

Setting up a poll requires two additional pages be created (in addition to wherever you choose to host the template): one for collecting <code>option_one</code> votes and the other for collecting <code>option_two</code> votes, the pages in question in parameters <code>option_one_vote_collection_page</code> and <code>option_two_vote_collection_page</code>.

To simplify the process a tool-assisted procedure has been created for this purpose, as follows:

# First of all come up with a succinct title for your poll. For instance if your poll question is "Jimbo Wales: yay or nay?", you might want to title your poll "Jimbo Wales". If it is instead the example question used here, "Do you believe that pending changes are the future when it comes to Wikipedia version control?", you could title it "Pending Changes".
# Second, think of what your poll options should be. Which one should go first? Which one should go second? In the case of simple Yes/No polls, that orientation is standard, but otherwise the choice is yours.
# To create the <code>option_one_vote_collection_page</code>, type the name of the page you are creating into the box below, replacing <code>{POLL TITLE}</code> with your poll title from step one and <code>{OPTION_ONE}</code> with the name of your first vote option from question two, and follow the instruction displayed once you hit the "Create" button. You may want to open this page in a second tab as hitting the button will take you away from this page.<br/><inputbox>
type=create
break=no
width=100
default=Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/{POLL TITLE}/{OPTION_ONE}
buttonlabel=Create option one vote gathering page
editintro=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Counter EditIntro
preload=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Counter Preload
</inputbox>
# To create the <code>option_two_vote_collection_page</code>, follow the same procedure but with reference to your second poll option this time:<br/><inputbox>
type=create
break=no
width=100
default=Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/{POLL TITLE}/{OPTION_TWO}
buttonlabel=Create option two vote gathering page
editintro=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Counter EditIntro
preload=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Counter Preload
</inputbox>
# '''Non-step''': The templates will automatically configure the page for the text that will be preloaded into users' input when they vote. For instance, if I am a reader voting in the poll and I hit the <code>Yes</code> vote button, I naturally expect a corresponding text input to be created for me to save. In order to reduce the workload on pollsters and to reduce the amount of subpages that uses of the poll template will generate, this text input has been reduced to a simple reused string: <code>Voting for option 1.</code>, <code>Voting for option 2.</code>, and so on. <!-- http://en.wikipedia.org/w/{PAGE_LINK}?action=edit&section=new&nosummary=true&preload=User:Resident_Mario/Voter/Setup/Preload2&preloadparams%5b%5d={VOTE_VALUE} -->
# Finally it is time to set up a page for the poll itself. To do so use the following input to create the template, preferably at the same {POLL_TITLE} you used in steps 3 and 4:<br/><inputbox>
type=create
break=no
width=100
default=Wikipedia:Wikipedia Signpost/Templates/Voter/Issues/{POLL TITLE}
buttonlabel=Create poll template
editintro=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Poll EditIntro
preload=Wikipedia:Wikipedia Signpost/Templates/Voter/Setup/Poll Preload
</inputbox>
# '''Optional''': Try voting to make sure that everything works!

Once all of this done, no further action is required: the templates handles vote counting, inputting, and display automatically.


== Test cases ==
== Test cases ==
For test-cases see [[Wikipedia:Wikipedia Signpost/Templates/Voter/testcases|here]].
The following are a series of test cases for this template, both for bug-checking and to demonstrate intended behavior.


Poll without the required number of responses <code>n < 100</code>, forced via <code>min_votes=100</code>:
{{Wikipedia:Wikipedia Signpost/Templates/Voter|min_votes=100}}
{{clear}}
{{clear}}
Poll with an overwritten minimum number of cases, forced via <code>min_votes=1</code>:
{{Wikipedia:Wikipedia Signpost/Templates/Voter|min_votes=0}}
{{clear}}
Poll which has been closed (manually forced via <code>expiry=0</code>, <code>min_votes</code> trigger overwritten via <code>min_votes=1</code>):
{{Wikipedia:Wikipedia Signpost/Templates/Voter|expiry=0|min_votes=1}}
{{clear}}
Poll with three options instead of two.
{{Wikipedia:Wikipedia Signpost/Templates/Voter|min_votes=1|option_three=Maybe}}
{{clear}}
Use of <code>color</code> parameters.
{{Wikipedia:Wikipedia Signpost/Templates/Voter|min_votes=1|option_one_color=ccc|option_two_color=666|option_three_color=000|option_three=Maybe}}
{{clear}}

== Technical implementation ==
From a technical perspective this is made possible through two key technical bits:
* The use of a Lua script to track the number of times a specific string has been inputted into a page: credit on this front to [[User:Mr. Stradivarius|Mr. Stradivarius]].
* The use of a <code>CommentTitle</code> input box and preloaded text to present the user with ready-made input that only needs to be saved in an aesthetically appealing way.
Other technical invocations:
* The use of parser functions to turn vote numbers into percentages, and from there into a stacked bar chart.
* The use of absolute positioning and image transparency to overlay a visually appealing graphic onto said chart.
* The use of absolute positioning to quietly hide the section title bar included in the <code>CommentTitle</code> input form.

== To do ==
* <s>Add built-ins and preloads for semi-automating the poll setup procedures, particularly when it comes to vote counting.</s>
* <s>Add a capacity to return to the previous page after voting.</s>
* <s>Rigorous testing and bug-fixing.</s>
* <s>Add a capacity for closing the poll after a certain amount of time has elapsed.</s>
* <s>Add a capacity for not visualizing poll results until a certain minimum number of votes have accrued.</s>
* <s>Add a capacity for a third polling option.</s>

Latest revision as of 16:13, 9 January 2021

Parameters

[edit]

This template is a proposal for an in-wiki polling apparatus for weekly use by the Signpost. The parameters are as follows:

{{Wikipedia:Wikipedia Signpost/Templates/Voter
| image = <!-- An image for the top-right corner of the sidebar; defaults to the Signpost logo. -->
| question = <!-- Question under consideration in the poll. -->
| option1 = <!-- Name of the first option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option1color = <!-- Color of the first option choice; defaults to #006699, Foundation blue. -->
| option2 = <!-- Name of the second option, as reported in the legend and in the vote button. Defaults to the test poll. -->
| option2color = <!-- Color of the first option choice; defaults to #339966, Foundation green. -->
| option3 = <!-- Optional. Where the votes for option two will be collected. Defaults to the test poll. -->
| option3color = <!-- Color of the first option choice; defaults to #990000, Foundation red. -->
| votepage = <!-- The page at which all of the votes will be accrued. -->
| min_votes = <!-- The minimum number of votes that must accrue before the template begins to display results. Defaults to 10. -->
| break = <!-- If this parameter is non-empty the votebar is split into two to better accommodate lengthier poll options. -->
| overlay = <!-- overlay image; defaults to File:Foundation Logo Transparent.svg. -->
| expiry = <!-- The number of days after which the poll is closed; defaults to 14 days. -->
}}
  • question: Question under consideration in the poll. (required)
  • votepage: Page that the votes will be stored on (required). If in doubt, choose poll location/Votes.
  • option1: Name of the first option, as reported in the legend and in the vote button. Defaults to Yes.
  • option1color = Color of the first option choice; defaults to   , Foundation blue.
  • option2: Name of the second options, as reported in the legend and in the vote button. Defaults to No.
  • option2color: Color of the second option choice; defaults to   , Foundation green.
  • option3: Optional. Name of the third options, as reported in the legend and in the vote button. No default.
  • option3color: Optional. Color of the third option choice; defaults to   , Foundation red (if the third option is enabled at all).
  • minimum: Minimum number of votes that must accrue before the poll will display the visualization; before this many votes are made the poll will tell readers that X more votes are needed based on the size of the deficit. Defaults to 10.
  • break: Set to "yes" to break columns between the buttons to allow longer button names. If this is not set, the template will try and auto-detect a sensible value.
  • expiry: The number of days after which the poll is closed; defaults to 14 days (two publication cycles). Note that is this defined from the day that you create the template not from the day that you actually publish the article!
  • header: Text that goes in the poll header. The default is "Signpost poll".
  • icon: Changes the image that is displayed in the top-right corner of the poll. As used in the Signpost other images are not recommended.
  • overlay: Overlay on the stacked bar chart which produces the template's fancy visualization. By default this is File:Foundation Logo Transparent.svg, a transparent version of the Wikimedia Foundation's logo. With some basic vector editing skills such images are easy to make; requirements for a working overlay are:
    • Square image; the transparent Foundation logo is a vector SVG with native resolution of 1050x1050.
    • Canvas whitespace; The bar chart is not displayed wherever the image canvas is explicitly white.
    • Transparent logo; this is where the chart will be displayed.

Test cases

[edit]

For test-cases see here.