end
def confirm
+
# we need the election to verify that we have the right voter
election = QuickVote.ident_to_quickvote(params[:ident])
@voter = QuickVoter.find(:all,
:conditions => ["session_id = ? and election_id = ?",
session.session_id, election.id])[0]
-
+
if not @voter
# we have not seen this voter before. something is wrong, try
# again
<% voters = @election.voters.size %>
<% matrix = @election.ssd_result.matrix %>
<% victories = @election.ssd_result.victories_and_ties %>
-
<p>Each number in the table below shows how many times the candidate on
the left beat the matching candidate on the top. The winner is on the
top of the left column.</p>
<% candidates.each do |victor| %>
<tr>
<th><%= white_list(@names[victor]) %></th>
- <% victories[victor].keys.each do |loser| %>
- <% margin = victories[victor][loser]%>
- <td><%= white_list(@names[loser]) %>
- <% if margin == 0%>
+<!-- This is a pretty logic heavy section - think about trying to move it to
+ backend eventually. Change the order of first and second to change the order
+ that things are sorted in. -->
+ <% sorted = victories[victor].sort { |first,second| first[1] <=> second[1] }%>
+ <% sorted.each do |loserpair| %>
+ <td><%= white_list(@names[loserpair[0]]) %>
+ <% if loserpair[1] == 0%>
Tied!
<% else -%>
- (<%= margin%>)
+ (<%= loserpair[1] %>)
<% end -%>
</td>
<% end -%>
</table>
</div>
+