Finished organzing preferential vote tables into one partial. Also changed RubyVote...
[selectricity] / app / views / quickvote / _pref_tables.rhtml
similarity index 50%
rename from app/views/quickvote/_pref_table.rhtml
rename to app/views/quickvote/_pref_tables.rhtml
index 011fcbe8ac2d29aa7b2147797e249f99c3b57389..66e0cbf2df1fbf7870581ca6ed849b66db2c7f21 100644 (file)
@@ -1,17 +1,19 @@
-<% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
+<% candidates = @election.condorcet_result.ranked_candidates.flatten -%>
 <% voters = @election.voters.size %>
 <% matrix = @election.condorcet_result.matrix %>
-<% names = Hash.new -%>
-<% candidates.each do |candidate| -%>
-       <%names[candidate] = Candidate.find(candidate).name -%>
-<% end -%>
+<% victories = @election.condorcet_result.victories_and_ties %>
+<% names = @election.names_by_id %>
+
+
+<!-- This table shows how many times each choice was ranked above the other, 
+       with percentages-->
 <table class="voterbox">
   <tr>
        <td> </td>
        <% candidates.each do |candidate| -%>
          <th><%=h names[candidate] -%></th>
   <% end -%>
-</tr>
+ </tr>
 
 <% candidates.each do |winner| -%>
   <tr>
  </tr>
 <% end -%>
 </table>
+
+<!-- This table generates a margin of victory -->
+<table class="voterbox">
+  <% candidates.each do |victor| %>
+  <tr>
+    <th><%=h names[victor] %></th>
+       <% victories[victor].keys.each do |loser| %>
+       <% margin = victories[victor][loser]%>
+       <td><%=h names[loser] %> 
+           <% if margin == 0%>
+                 Tied!
+               <% else -%>
+                 (<%= margin%>)
+               <% end -%>
+                 </td>
+       <% end -%>
+  </tr>
+  <% end -%>
+</table>
+

Benjamin Mako Hill || Want to submit a patch?