gdoteof/election

Include Indication of Winners

Closed this issue · 11 comments

Description

Please include an indication of the winner(s) for ballot items at the whole district level where the results are complete.

Steps to Reproduce

curl 'https://example.org/town-meeting-season-2011/town-meeting-day-2011/ward-1/ward-1-city-council' \
-H 'Accept: text/html'

Actual Results

<ul>
  <li class="result">
    <span class="option candidate">Sharon Bushor (I) </span>
    <span class="votes" title="416">416 (100.0%)</span>
  </li>

Expected Results

<ul>
  <li class="result winner">
    <span class="option candidate">Sharon Bushor (I) </span>
    <span class="votes" title="416">416 (100.0%)</span>
  </li>

Additional Comments

Note that if you complete issue #5 first then the results will be in a table instead. Regardless, the winner class goes on the same HTML element that has the result class. I'm assuming that the ballot item in this example is for a whole district where the results are complete, which may be an incorrect assumption. Regardless, this example should illustrate the desired outcome.

This opens up a whole can of worms: how do we determine the winner?

I see two options, and (out of laziness) heavily leaned toward the latter now that we have made some deep-rooted architectural decisions.

The way I would have liked to do this from the beginning is to set up a new hook that lets modules declare ways to win; and actually have those be the 'ballot item type'.

The way I would like to do it now is simply hard code in a the ones we are likely to use: top X, >50%, >67%.. any others?

@gdoteof, I think those are the main ones we'll use (at least for now). We may need both >50% and >=50%, if my memory serves me correctly (same for 2/3rds?). @acrawford, can you think of any other types of winning methods that will come up on Town Meeting Day?

Something like:

  • =50%

  • 50%

  • 2/3

  • =2/3

  • Top N

I am thinking: A drop down with three (for now) options:

  • N

  • =N

  • Top N

A textbox labeled: N

Then we will have three functions something like

function elec_winner_by_top_n(&$results, $n){
...
}

function elec_winner_by_gt_n(&$results, $n){
...
}

function elec_winner_by_gte_n(&$results, $n){
...
}

Makes sense to me. There may be scenarios where two (or maybe more) winning methods are in effect (I don't know if we documented a specific example of this scenario). But, I don't know if that scenario will exist on Town Meeting Day.

Some (most?) referendums have a 50%+1 winning threshold. Is this mathematically the same as >50%? I think so, but something to watch out for depending on how you calculate percentage.

I think that plus 1 may be +1% (as in the dem caucus) or may be +1 vote (for elections except mayor) can we ignore this?

Mayor of Burlington requires a plurality that is also > 40% of the total vote count, otherwise a runoff election will go forward. so in this case N = 40% with ">" selected.

http://en.wikipedia.org/wiki/Instant-runoff_voting_in_the_United_States#2010_Burlington_repeal

as a bolt-on solution for now, I think this will work.

@acrawford you tell us if we can ignore it :)

Should we have a fourth option: IRV >

?

How do we want this to look in the JSON?

Maybe a boolean winner field on each result? If winners aren't being determined (i.e. it's a "Partial District" and/or "Incomplete Results"), then I'd exclude the winner field altogether.

added in a1360ef

you can ignore IRV, as it was repealed. all looks good on this front

Looks good in both HTML and JSON, thanks!