Files
grecia/app/views/polls/stats.html.erb
2019-05-21 13:50:16 +02:00

157 lines
5.5 KiB
Plaintext

<% provide :title do %><%= @poll.name %><% end %>
<div class="polls-results-stats">
<%= render "poll_header" %>
<%= render "poll_subnav" %>
<div class="row margin" data-equalizer data-equalize-on="medium">
<div class="small-12 medium-3 column sidebar" data-equalizer-watch>
<ul class="menu">
<li>
<%= link_to t("stats.title"), "#participation_statistics" %>
<ul>
<li>
<%= link_to t("stats.total_participants"), "#total_participants" %>
</li>
<li>
<%= link_to t("stats.by_gender"), "#participants_by_gender" %>
</li>
<li>
<%= link_to t("stats.by_age"), "#participants_by_age" %>
</li>
</ul>
</li>
</ul>
</div>
<div class="small-12 medium-9 column" data-equalizer-watch>
<section id="participation_statistics">
<h2><%= t("stats.title") %></h2>
<section id="total_participants">
<h3><%= t("stats.total_participants") %></h3>
<p class="participants">
<span class="number"><%= @stats[:total_participants] %></span>
<span class="info"><%= t("polls.show.stats.total_votes") %><br></span>
</p>
</section>
<section id="participants_by_gender">
<h3><%= t("stats.by_gender") %></h3>
<p class="gender male participants">
<span class="number"><%= @stats[:total_male_participants] %></span>
<span class="info">
<%= I18n.t("stats.men_percentage",
percentage: number_to_stats_percentage(@stats[:male_percentage])) %>
</span>
</p>
<p class="gender female participants">
<span class="number"><%= @stats[:total_female_participants] %></span>
<span class="info">
<%= I18n.t("stats.women_percentage",
percentage: number_to_stats_percentage(@stats[:female_percentage])) %>
</span>
</p>
</section>
<section id="participants_by_age">
<h3><%= t("stats.by_age") %></h3>
<table>
<thead>
<th><%= t("stats.age") %></th>
<th><%= t("stats.total") %></th>
</thead>
<tbody>
<% @stats[:age_groups].values.each do |group| %>
<tr>
<td><%= group[:range] %></td>
<td>
<%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %>
<meter min="0" max="100" value="<%= group[:percentage] %>"></meter>
</td>
</tr>
<% end %>
</tbody>
</table>
</section>
</section>
<table>
<thead>
<tr>
<th scope="col"><%= t("polls.show.stats.votes") %></th>
<th scope="col"><%= t("polls.show.stats.web") %></th>
<th scope="col"><%= t("polls.show.stats.booth") %></th>
<th scope="col"><%= t("polls.show.stats.total") %></th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><%= t("polls.show.stats.valid") %></th>
<td>
<%= @stats[:total_web_valid] %>
<small><em>(<%= @stats[:valid_percentage_web].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_booth_valid] %>
<small><em>(<%= @stats[:valid_percentage_booth].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_valid_votes] %>
<small><em>(<%= @stats[:total_valid_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.white") %></th>
<td>
<%= @stats[:total_web_white] %>
<small><em>(<%= @stats[:white_percentage_web].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_booth_white] %>
<small><em>(<%= @stats[:white_percentage_booth].round(2) %>%)</em></small>
</td>
<td><%= @stats[:total_white_votes] %>
<small><em>(<%= @stats[:total_white_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.null_votes") %></th>
<td>
<%= @stats[:total_web_null] %>
<small><em>(<%= @stats[:null_percentage_web].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_booth_null] %>
<small><em>(<%= @stats[:null_percentage_booth].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_null_votes] %>
<small><em>(<%= @stats[:total_null_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.total") %></th>
<td>
<%= @stats[:total_participants_web] %>
<small><em>(<%= @stats[:total_participants_web_percentage].round(2) %>%)</em></small>
</td>
<td>
<%= @stats[:total_participants_booth] %>
<small><em>(<%= @stats[:total_participants_booth_percentage].round(2) %>%)</em></small>
</td>
<td><%= @stats[:total_participants] %></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>