我有以下看法:
<table class="fixed">
<tr>
<th>Student Name</th>
<!-- create as many <th> as there are evaluations -->
<% @eval_count.times do |i| %>
<th>Evaluation <%= i+1 %></th>
<% end %>
<th>Student Average <br />(for this goal)</th>
</tr>
<% for eval in @evals %>
<tr class="<%= cycle("odd", "even", name: "evals")%>">
<!-- eval returns { s_id [eval],[eval]} -->
<td><%= eval[1].first.student.name%></td>
<!-- in each student's row, print the score for each consecutive evaluation -->
<% @eval_count.times do |i| %>
<td><%= eval[1][i].score %><% @ss_scores << eval[1][i].score %></td>
<% end %>
<td><%= @ss_scores %></td>
</tr>
<% reset_cycle("evals") %>
<% end %>
</table>
<% @ss_scores.in_groups(@student_count, false) do |group|%>
<%= (group.sum.to_f/group.size).round(2) %>
<% end %>
呈现以下内容:
我想把每个学生的平均值放在最后一列,但@ss_scores
它是一个变量,所以在它上面调用任何东西都不起作用。但是当for
循环完成时,@ss_scores
可以像屏幕截图底部一样很好地使用。知道如何更好地做到这一点吗?