Skip to content

Commit

Permalink
added total avg
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Nov 8, 2012
1 parent 01338bf commit 7677767
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/controllers/feedback_votes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def index
# GET /feedback_votes/1.xml
def show
@feedbacks = FeedbackVote.find(:all, :conditions => {:talk_id => params[:id]})

sum = 0.0
FeedbackVote.find(:all).each do |f|
sum += f.vote
end
@total_avg = sum/FeedbackVote.all.count


@talk = Talk.find(params[:id])

respond_to do |format|
Expand Down
10 changes: 8 additions & 2 deletions app/views/feedback_votes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
}
.votes .sum td {
border-top: 1px solid silver;
border-bottom: 2px solid silver;
font-weight: bold;
}
.votes .total td {
border-bottom: 2px solid silver;
}
.votes .title {
padding-top: 20px;
}
Expand All @@ -28,9 +30,13 @@
</tr>
<% end %>
<tr class="sum">
<td>Snitt:</td>
<td>Ditt snitt:</td>
<td class="vote"><%=h sum/count %></td>
</tr>
<tr class="sum total">
<td>Snitt for konferansen:</td>
<td class="vote"><%= @total_avg %></td>
</tr>
</table>
<% else %>
Du har ikke tilgang!
Expand Down

0 comments on commit 7677767

Please sign in to comment.