Page MenuHomePhabricator

Produce the Tally view output for an STV election [M]
Closed, ResolvedPublic

Description

Motivation

This task is to produce the Tally view output for an STV election. Typically this output is used by election admins and scrutinizers to go over the result data to verify it before it is shared with the community (from an earlier conversation with Joe S). Hence we should make this result easy to understand and corroborate for a non-technical community member.
With this understanding, here's the proposed output for the election:

Screenshot 2021-07-21 at 6.09.56 PM.png (1×1 px, 200 KB)

Acceptance criteria:
  • The results begin with a header for "Elected" which lists of candidates elected in sequential order from first to last. Tied candidates can be represented on the same line.
    • Include a line that shows the number of seats to be filled, the number of candidates and the total number of votes.
  • The second header shows "Eliminated" candidates. The droop quota number is included in the header.
  • The third header is for "Rounds table" which shows the workings of how we arrived at the results.
    • The first column in the table shows the round number we are on.
    • The second column indicates how many votes were obtained by each of the candidates in the running, in that round. If there was a transfer of votes from the previous round, that is indicated with a + to show the new votes the candidate received this round. The elected candidate entry is shown in bold and the eliminated candidate is shown with a strike-through.
      • Old elected candidates remain bold but are grayed out (#72777d).
      • The keep factor is shown in brackets after the transfer calculation
      • The calculation numbers need not be in bold
    • The third column spells out which candidate(s) were elected and which one(s) were eliminated in that round, or if there were only transfers.
      • If no one was elected that line can be omitted. We don't need to show the heading and then the "n/a".
  • In the event of a seat remaining unfilled because of eliminations, we can list that seat and say something like: This seat could not be filled because no candidates fulfill the criteria. The last eliminated candidates were: Alice and Bob.

At the end of this task, getHTMLResult() should return the output and that output should be displayed on TallyPage.php when the tally is completed. (Bonus points but you can route getHTMLResult() to getTextResult() as well like HistogramRangeTallier.php does so that it can get output from cli/tally.php)

Event Timeline

Niharika triaged this task as Medium priority.Jun 8 2021, 5:49 PM
Niharika created this task.
Niharika renamed this task from Craft the Tally view output for an STV election to Produce the Tally view output for an STV election.Jun 9 2021, 4:01 PM
ARamirez_WMF renamed this task from Produce the Tally view output for an STV election to Produce the Tally view output for an STV election [M].Jun 9 2021, 4:31 PM

not sure if this helps, but I can add some data if needed , I have this array that has results so far.

[
  1 => array:5 [
    "A_B_C" => array:3 [
      "count" => 28
      "keep_factor" => 1
      "rank" => array:3 [
        1 => "A"
        2 => "B"
        3 => "C"
      ]
    ]
    "B_A_C" => array:3 [
      "count" => 26
      "keep_factor" => 1
      "rank" => array:3 [
        1 => "B"
        2 => "A"
        3 => "C"
      ]
    ]
    "C" => array:3 [
      "count" => 3
      "keep_factor" => 1
      "rank" => array:1 [
        1 => "C"
      ]
    ]
    "D" => array:3 [
      "count" => 2
      "keep_factor" => 1
      "rank" => array:1 [
        1 => "D"
      ]
    ]
    "E" => array:3 [
      "count" => 1
      "keep_factor" => 1
      "rank" => array:1 [
        1 => "E"
      ]
    ]
  ]
  2 => array:5 [
    "A_B_C" => array:4 [
      "count" => 21.59
      "keep_factor" => 0.57
      "rank" => array:3 [
        1 => "A"
        2 => "B"
        3 => "C"
      ]
      "winner" => true
    ]
    "B_A_C" => array:4 [
      "count" => 23.58
      "keep_factor" => 0.62
      "rank" => array:3 [
        1 => "B"
        2 => "A"
        3 => "C"
      ]
      "winner" => true
    ]
    "C" => array:4 [
      "count" => 11.83
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "C"
      ]
      "winner" => false
    ]
    "D" => array:4 [
      "count" => 2.0
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "D"
      ]
      "winner" => false
    ]
    "E" => array:4 [
      "count" => 1.0
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "E"
      ]
      "winner" => false
    ]
  ]
  3 => array:5 [
    "A_B_C" => array:4 [
      "count" => 18.09
      "keep_factor" => 0.42
      "rank" => array:3 [
        1 => "A"
        2 => "B"
        3 => "C"
      ]
      "winner" => true
    ]
    "B_A_C" => array:4 [
      "count" => 17.74
      "keep_factor" => 0.42
      "rank" => array:3 [
        1 => "B"
        2 => "A"
        3 => "C"
      ]
      "winner" => true
    ]
    "C" => array:4 [
      "count" => 21.17
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "C"
      ]
      "winner" => true
    ]
    "D" => array:4 [
      "count" => 2.0
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "D"
      ]
      "winner" => false
    ]
    "E" => array:4 [
      "count" => 1.0
      "keep_factor" => 1.0
      "rank" => array:1 [
        1 => "E"
      ]
      "winner" => false
    ]
  ]
]

Array indexes/indices are round numbers

Change 704210 had a related patch set uploaded (by STran; author: STran):

[mediawiki/extensions/SecurePoll@master] [WIP] Generate STV tally output page

https://gerrit.wikimedia.org/r/704210

Prtksxna updated the task description. (Show Details)

Change 708260 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/SecurePoll@master] Follow ups for STV tally output

https://gerrit.wikimedia.org/r/708260

Change 708260 abandoned by Phuedx:

[mediawiki/extensions/SecurePoll@master] Follow ups for STV tally output

Reason:

Merged into Id1f8b6a7

https://gerrit.wikimedia.org/r/708260

Change 704210 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@master] Generate STV tally output page

https://gerrit.wikimedia.org/r/704210

Change 708801 had a related patch set uploaded (by Phuedx; author: STran):

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.16] Generate STV tally output page

https://gerrit.wikimedia.org/r/708801

Change 708801 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.16] Generate STV tally output page

https://gerrit.wikimedia.org/r/708801

Mentioned in SAL (#wikimedia-operations) [2021-07-29T18:36:57Z] <urbanecm@deploy1002> Finished scap: 796fe8e: 927763c: SecurePoll backports (T283728, T284585) (duration: 17m 06s)

Verified tally view displays and it matches visual reference on browser(Chrome, Safari, and Firefox) and simulated mobile view. See screenshot sample below:

Screen Shot 2021-08-06 at 4.15.25 PM.png (1×2 px, 401 KB)

Screen Shot 2021-08-06 at 4.16.24 PM.png (1×2 px, 301 KB)