Cleaned up some of the test cases.
[selectricity] / app / views / quickvote / results.rhtml
1 <% %>
2 <%require 'whois/whois' %>
3 <h1>Results</h1>
4
5 <% if @election.shortdesc %>
6   <p><strong>Description:</strong></p>
7   <blockquote><em><%= @election.shortdesc %></em>
8     <% if @election.longdesc -%>
9       <br />
10       <%= h(@election.longdesc) -%>
11     <% end -%>
12   </blockquote>
13 <% end %>
14
15 <p><strong>Candidates/choices:</strong></p>
16
17 <ol>
18   <% for candidate in @election.candidates.sort %>
19     <li><%= candidate.name.capitalize %></li>
20   <% end %>
21 </ol>
22
23 <p><strong>Number of voters:</strong></p>
24    <blockquote>
25      <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) 
26    </blockquote>
27
28 <h2>Winners</h2>
29
30 <div class="mainresultbox">
31 <h3>Schulze Method Results</h3>
32 <%= render :partial => 'result', :object => @election.ssd_result %>
33
34 <div class="rbmoreinfo"
35 <h4>About the Schulze Method</h4>
36
37 <p>The <%= link_to "Schulze method",
38 "http://en.wikipedia.org/wiki/Schulze_method" %> is a preferential
39 voting system. It is based on the Condorcet method but includes a set of
40 methods for resolving "circular" defeats.</p>
41
42 <p>The Schulze method is also known as Schwartz Sequential Dropping
43 (SSD), Cloneproof Schwartz Sequential Dropping (CSSD), Beatpath Method,
44 Beatpath Winner, Path Voting, and Path Winner.</p>
45 </div>
46
47 </div>
48
49 <div class="resultbox">
50 <h3>Plurality Results</h3>
51 <%= render :partial => 'result', :object => @election.plurality_result %>
52
53 <div class="rbmoreinfo"
54 <h4>About Plurality Voting</h4>
55
56 <p><%= link_to "Plurality voting",
57 "http://en.wikipedia.org/wiki/Plurality_electoral_system" %> selects the
58 winner who has received the most "number one" votes, regardless of
59 whether or not he or she has a majority of votes.</p>
60
61 <p>Plurality voting is also variously referred to as, "first past the
62 post," "winner-take-all," "majoritarian" or "simple majority"
63 voting.</p>
64
65 </div>
66 </div>
67
68 <div class="resultbox">
69 <h3>Approval Result</h3>
70 <p><font size="-1">(This algorithm assumes that top two choices are "approved.")</font></p>
71 <%= render :partial => 'result', :object => @election.approval_result %>
72
73 <div class="rbmoreinfo"
74 <h4>About Approval Voting</h4>
75
76 <p><%= link_to "Approval voting",
77 "http://en.wikipedia.org/wiki/Approval_voting" %> is a voting system in
78 which each voter can vote for as many or as few candidates as the voter
79 chooses.  Approval voting is a limited form of range voting, where the
80 range that voters are allowed to express is extremely constrained:
81 accept or not.</p>
82
83 </div>
84
85 </div>
86
87 <div class="resultbox">
88 <h3>Simple Condorcet Results</h3>
89 <%= render :partial => 'result', :object => @election.condorcet_result %>
90
91 <div class="rbmoreinfo"
92 <h4>About Simple Cordorcet Voting</h4>
93
94 <p><%= link_to "Condorcet",
95 "http://en.wikipedia.org/wiki/Condorcet_method" %> allows voters to rank
96 candidates in order of preference.  If there is a choice whom voters
97 prefer to each other choice when compared to one at a time, that choice
98 will be the winner.</p>
99
100 <p>There is a family of Condorcet methods. This method is referred to as
101 "Simple Condorcet" to distinguish it from the Schulze method which is
102 another Condorcet system.</p>
103
104 </div>
105 </div>
106
107 <div class="resultbox">
108 <h3>Borda Count Results</h3>
109 <%= render :partial => 'result', :object => @election.borda_result %>
110
111 <div class="rbmoreinfo"
112 <h4>About Borda Count</h4>
113
114 <p><%= link_to "Borda count",
115 "http://en.wikipedia.org/wiki/Borda_count" %> 
116 is an election method in which voters rank
117 candidates in order of preference. The Borda count determines the winner
118 of an election by giving each candidate a certain number of points
119 corresponding to the position in which he or she is ranked by each
120 voter. Once all votes have been counted the candidate with the most
121 points is the winner.</p>
122 </div>
123 </div>
124
125 <div class="resultbox">
126 <h3>Instant Runoff (IRV) Results</h3>
127
128 <div class="rbmoreinfo"
129 <h4>About Instant Runoff Voting</h4>
130
131 <p><%= link_to "Instant runoff voting",
132 "http://en.wikipedia.org/wiki/Instant_Runoff_Voting" %> is an electoral
133 system in which voters rank candidates in order of preference. In an IRV
134 election, if no candidate receives an overall majority of first
135 preferences the candidates with fewest votes are eliminated one by one,
136 and their votes transferred according to their second and third
137 preferences (and so on), until one candidate achieves a majority.</p>
138
139 <p>Instant-runoff voting (IRV) is also known as the Alternative Vote (AV) and
140 by several other names.</p>
141
142 </div>
143
144 </div>
145
146 <div class="clearbox"></div>
147
148 <h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
149 <table class="voterbox">
150 <tr>
151 <th>IP/Host</th>
152 <th>Origin</th>
153 <th>Vote</th>
154 </tr>
155 <% for voter in @election.voters %>
156   <% next unless voter.voted? %>
157   <tr>
158     <td><% begin %>
159         <% raise ArgumentError.new, "Local Server" if voter.ipaddress == "127.0.0.1" %>
160         <% raise ArgumentError.new, "XML-RPC Voter" if voter.ipaddress == "XMLRPC Request" %>
161         <% w= Whois::Whois.new(IPAddr.new(voter.ipaddress).to_s,true)%>
162         <%=(w.host == nil or w.host.empty?) ? voter.ipaddress : w.host%>
163       </td>
164       <td>
165         <%w.search_whois%>
166         <%= (w.all.grep(/^(OrgName|org-name)/)[0] or "").sub(/^(OrgName|org-name)\:/,'').strip -%> - <%=  (w.all.grep(/^(NetName|netname)/)[0] or "").sub(/^(NetName|netname)\:/,'').strip %>
167     
168     <% rescue ArgumentError => err %>
169       <%= err %>
170     </td>
171     <td><%= err%>
172     <% end %>
173     </td>
174   <td><%= voter.vote.votestring %></td>
175   </tr>
176 <% end %>
177 </table>
178
179 <%= render :partial => 'victories_ties' %>
180 <%= render :partial => 'pref_table' %>
181
182 <%= image_tag( graph_url( :action => 'votes_per_day', :id => @election ) ) %><br />
183 <%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%><br />
184 <%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
185 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>

Benjamin Mako Hill || Want to submit a patch?