Display all ratings for a vote
This commit is contained in:
parent
5096134d2e
commit
46c8745a9e
3 changed files with 40 additions and 19 deletions
|
|
@ -13,13 +13,13 @@
|
|||
<p><%= candidate.name %></p>
|
||||
<p><%= candidate.description %></p>
|
||||
<ol>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-7" value="7" <% if @ratings[candidate] and @ratings[candidate].value == 7 %>checked<% end %>><label for="<%= candidate.id %>-7">Excellent</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-6" value="6" <% if @ratings[candidate] and @ratings[candidate].value == 6 %>checked<% end %>><label for="<%= candidate.id %>-6">Very good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-5" value="5" <% if @ratings[candidate] and @ratings[candidate].value == 5 %>checked<% end %>><label for="<%= candidate.id %>-5">Good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-4" value="4" <% if @ratings[candidate] and @ratings[candidate].value == 4 %>checked<% end %>><label for="<%= candidate.id %>-4">Mediocre</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-3" value="3" <% if @ratings[candidate] and @ratings[candidate].value == 3 %>checked<% end %>><label for="<%= candidate.id %>-3">Bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-2" value="2" <% if @ratings[candidate] and @ratings[candidate].value == 2 %>checked<% end %>><label for="<%= candidate.id %>-2">Very bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-1" value="1" <% if @ratings[candidate] and @ratings[candidate].value == 1 %>checked<% end %>><label for="<%= candidate.id %>-1">Awful</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-7" value="7" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 7 } %>checked<% end %>><label for="<%= candidate.id %>-7">Excellent</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-6" value="6" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 6 } %>checked<% end %>><label for="<%= candidate.id %>-6">Very good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-5" value="5" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 5 } %>checked<% end %>><label for="<%= candidate.id %>-5">Good</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-4" value="4" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 4 } %>checked<% end %>><label for="<%= candidate.id %>-4">Mediocre</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-3" value="3" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 3 } %>checked<% end %>><label for="<%= candidate.id %>-3">Bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-2" value="2" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 2 } %>checked<% end %>><label for="<%= candidate.id %>-2">Very bad</label>
|
||||
<input type="radio" name="<%= candidate.id %>" id="<%= candidate.id %>-1" value="1" <% if @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate and rating.value == 1 } %>checked<% end %>><label for="<%= candidate.id %>-1">Awful</label>
|
||||
</ol>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
@ -27,6 +27,27 @@
|
|||
<button type="submit">Save ratings</button>
|
||||
</form>
|
||||
|
||||
<h2>All ratings</h2>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Participant</th>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<th><%= candidate.name %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% @vote.ratings.collect { |rating| rating.user }.uniq.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.email %></td>
|
||||
<% @vote.candidates.each do |candidate| %>
|
||||
<% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %>
|
||||
<td><%= rating.value %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<h2>New candidate</h2>
|
||||
|
||||
<form action="/votes/<%= @vote.secure_id %>/candidates" method="post">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue