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

153 lines
5.5 KiB
Plaintext

<% provide :title do %><%= @poll.name %><% end %>
<div class="participation-stats 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>
<%= render "shared/stats/links" %>
<p><strong><%= link_to t("stats.advanced"), "#advanced_statistics" %></strong></p>
<ul class="menu vertical">
<li>
<%= link_to t("stats.polls.by_channel"), "#stats_by_channel" %>
</li>
<li>
<%= link_to t("stats.polls.by_gender_and_channel"), "#stats_by_gender_and_channel" %>
</li>
<li>
<%= link_to t("stats.polls.vote_by_channel"), "#vote_stats_by_channel" %>
</li>
</ul>
</div>
<div class="small-12 medium-9 column" data-equalizer-watch>
<%= render "shared/stats/participation", stats: @stats %>
<div id="advanced_statistics">
<h3 class="section-title"><%= t("stats.advanced") %></h3>
<div id="stats_by_channel" class="stats-group">
<h4><%= t("stats.polls.by_channel") %></h4>
<% Poll::Stats::CHANNELS.each do |channel| %>
<%= number_with_info_tags(
@stats[:"total_participants_#{channel}"],
t("stats.polls.#{channel}_percentage",
percentage: number_to_stats_percentage(@stats[:"total_participants_#{channel}_percentage"])
),
html_class: channel
) %>
<% end %>
</div>
<div id="stats_by_gender_and_channel" class="stats-group">
<h4><%= t("stats.polls.by_gender_and_channel") %></h4>
<table class="gender-and-channel">
<thead>
<tr>
<th class="gender"></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th class="<%= channel %>"><%= t("stats.polls.#{channel}") %></th>
<% end %>
</tr>
</thead>
<tbody>
<% %i[male female].each do |gender| %>
<tr>
<td class="<%= gender %> gender"><%= t("stats.#{gender}") %></td>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= "#{@stats[:"total_#{gender}_#{channel}"]}
(#{number_to_stats_percentage(@stats[:"#{gender}_#{channel}_percentage"])})" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="vote_stats_by_channel" class="stats-group">
<h4><%= t("stats.polls.vote_by_channel") %></h4>
<table class="stack">
<thead>
<tr>
<th scope="col"><%= t("polls.show.stats.votes") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th scope="col"><%= t("polls.show.stats.#{channel}") %></th>
<% end %>
<th scope="col"><%= t("polls.show.stats.total") %></th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><%= t("polls.show.stats.valid") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_valid"] %>
<small><em>(<%= @stats[:"valid_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<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>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_white"] %>
<small><em>(<%= @stats[:"white_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<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>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_null"] %>
<small><em>(<%= @stats[:"null_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<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>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_participants_#{channel}"] %>
<small><em>(<%= @stats[:"total_participants_#{channel}_percentage"].round(2) %>%)</em></small>
</td>
<% end %>
<td><%= @stats[:total_participants] %></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>