|
12 | 12 | show_total_column = @summary[:sheets].size > 1
|
13 | 13 | %>
|
14 | 14 |
|
15 |
| - <div class="scrollable-container"> |
16 |
| - <%= content_tag('div', :class => if @bare_layout then nil else 'scrollable' end) do %> |
17 |
| - <% @user_fields_length = @user_fields ? @user_fields.length : 0 %> |
18 |
| - <% @exercises_length = @summary[:sheets] ? @summary[:sheets].length : 0 %> |
19 |
| - <table class="points" > |
20 |
| - <thead> |
21 |
| - <tr> |
22 |
| - <th></th> |
23 |
| - <th colspan="<%= (@user_fields ? @user_fields.length : 0) + 1 %>">Number of students</th> |
24 |
| - <% if !@summary[:sheets].empty? %> |
25 |
| - <th colspan="<%= @summary[:sheets].count %>">Total points/possible</th> |
26 |
| - <% end %> |
27 |
| - <% if show_total_column %> |
28 |
| - <th>Total</th> |
| 15 | + <%= content_tag('div', :class => if @bare_layout then nil else 'scrollable' end) do %> |
| 16 | + <% @user_fields_length = @user_fields ? @user_fields.length : 0 %> |
| 17 | + <% @exercises_length = @summary[:sheets] ? @summary[:sheets].length : 0 %> |
| 18 | + <table class="points" > |
| 19 | + <thead> |
| 20 | + <tr> |
| 21 | + <th></th> |
| 22 | + <th colspan="<%= (@user_fields ? @user_fields.length : 0) + 1 %>">Number of students</th> |
| 23 | + <% if !@summary[:sheets].empty? %> |
| 24 | + <th colspan="<%= @summary[:sheets].count %>">Total points/possible</th> |
| 25 | + <% end %> |
| 26 | + <% if show_total_column %> |
| 27 | + <th>Total</th> |
| 28 | + <% end %> |
| 29 | + </tr> |
| 30 | + <tr class="table-totals"> |
| 31 | + <td>-</td> |
| 32 | + <% nstudents = @summary[:users].length %> |
| 33 | + <td><%= nstudents %></td> |
| 34 | + <% if @user_fields %> |
| 35 | + <td colspan="<%= @user_fields.length %>"></td> |
| 36 | + <% end %> |
| 37 | + <% @summary[:sheets].each do |sheet| %> |
| 38 | + <td> |
| 39 | + <%= "#{sheet[:total_awarded]}/#{sheet[:total_available]*nstudents}" %> |
| 40 | + </td> |
| 41 | + <% end %> |
| 42 | + <% if show_total_column %> |
| 43 | + <td> |
| 44 | + <%= "#{@summary[:total_awarded]}/#{@summary[:total_available]*nstudents}" %> |
| 45 | + </td> |
| 46 | + <% end %> |
| 47 | + </tr> |
| 48 | + <tr> |
| 49 | + <th></th> |
| 50 | + <th> |
| 51 | + Student<br /> |
| 52 | + <% unless params[:sort_by].blank? %> |
| 53 | + [<%= link_to 'sort', organization_course_points_path(@organization, @course) %>] |
| 54 | + <% else %> |
| 55 | + [sort] |
29 | 56 | <% end %>
|
30 |
| - </tr> |
31 |
| - <tr class="table-totals"> |
32 |
| - <td>-</td> |
33 |
| - <% nstudents = @summary[:users].length %> |
34 |
| - <td><%= nstudents %></td> |
| 57 | + </th> |
35 | 58 | <% if @user_fields %>
|
36 |
| - <td colspan="<%= @user_fields.length %>"></td> |
37 |
| - <% end %> |
38 |
| - <% @summary[:sheets].each do |sheet| %> |
39 |
| - <td> |
40 |
| - <%= "#{sheet[:total_awarded]}/#{sheet[:total_available]*nstudents}" %> |
41 |
| - </td> |
42 |
| - <% end %> |
43 |
| - <% if show_total_column %> |
44 |
| - <td> |
45 |
| - <%= "#{@summary[:total_awarded]}/#{@summary[:total_available]*nstudents}" %> |
46 |
| - </td> |
| 59 | + <% @user_fields.each do |field| %> |
| 60 | + <th><%= field.label %></th> |
| 61 | + <% end %> |
47 | 62 | <% end %>
|
48 |
| - </tr> |
49 |
| - <tr> |
50 |
| - <th></th> |
| 63 | + <% @summary[:sheets].map{|s| s[:name]}.each do |sheet| %> |
| 64 | + <th> |
| 65 | + <%= sheet %><br /> |
| 66 | + [<%= link_to 'open', organization_course_point_path(@organization, @course, sheet) %>] |
| 67 | + <br/> |
| 68 | + <% unless params[:sort_by] == "#{sheet}_points" %> |
| 69 | + [<%= link_to 'sort', organization_course_points_path(@organization, @course, :sort_by => "#{sheet}_points") %>] |
| 70 | + <% else %> |
| 71 | + [sort] |
| 72 | + <% end %> |
| 73 | + </th> |
| 74 | + <% end %> |
| 75 | + <% if show_total_column %> |
51 | 76 | <th>
|
52 |
| - Student<br /> |
53 |
| - <% unless params[:sort_by].blank? %> |
54 |
| - [<%= link_to 'sort', organization_course_points_path(@organization, @course) %>] |
| 77 | + Total<br /> |
| 78 | + <% unless params[:sort_by] == 'total_points' %> |
| 79 | + [<%= link_to 'sort', organization_course_points_path(@organization, @course, :sort_by => "total_points") %>] |
55 | 80 | <% else %>
|
56 | 81 | [sort]
|
57 | 82 | <% end %>
|
58 | 83 | </th>
|
59 |
| - <% if @user_fields %> |
60 |
| - <% @user_fields.each do |field| %> |
61 |
| - <th><%= field.label %></th> |
62 |
| - <% end %> |
| 84 | + <% end %> |
| 85 | + </tr> |
| 86 | + </thead> |
| 87 | + <tbody> |
| 88 | + <% @summary[:users].each_with_index do |user, index| %> |
| 89 | + <% username = user.login %> |
| 90 | + <% row_class = if user.administrator? || user.teacher?(@organization) then "admin" else "student" end %> |
| 91 | + <tr class="<%= row_class %>"> |
| 92 | + <td><%= index + 1 %></td> |
| 93 | + <td> |
| 94 | + <% if current_user.id == user.id || can?(:teach, @course) %> |
| 95 | + <%= link_to username, participant_path(user) %> |
| 96 | + <% else %> |
| 97 | + <%= username %> |
| 98 | + <% end %> |
| 99 | + </td> |
| 100 | + <% if @user_fields %> |
| 101 | + <% @user_fields.each do |field| %> |
| 102 | + <% field_record = user.user_field_values.find { |o| o.field_name == field.name } %> |
| 103 | + <td><%= field_record.value if field_record %></td> |
63 | 104 | <% end %>
|
64 |
| - <% @summary[:sheets].map{|s| s[:name]}.each do |sheet| %> |
65 |
| - <th> |
66 |
| - <%= sheet %><br /> |
67 |
| - [<%= link_to 'open', organization_course_point_path(@organization, @course, sheet) %>] |
68 |
| - <br/> |
69 |
| - <% unless params[:sort_by] == "#{sheet}_points" %> |
70 |
| - [<%= link_to 'sort', organization_course_points_path(@organization, @course, :sort_by => "#{sheet}_points") %>] |
71 |
| - <% else %> |
72 |
| - [sort] |
73 |
| - <% end %> |
74 |
| - </th> |
| 105 | + <% end %> |
| 106 | + <% @summary[:sheets].each do |sheet| %> |
| 107 | + <% user_points_for_this_sheet = @summary[:awarded_for_user_and_sheet][username][sheet[:name]].to_i %> |
| 108 | + <td> |
| 109 | + <%= "#{user_points_for_this_sheet}/#{sheet[:total_available]}" %> |
| 110 | + </td> |
75 | 111 | <% end %>
|
76 | 112 | <% if show_total_column %>
|
77 |
| - <th> |
78 |
| - Total<br /> |
79 |
| - <% unless params[:sort_by] == 'total_points' %> |
80 |
| - [<%= link_to 'sort', organization_course_points_path(@organization, @course, :sort_by => "total_points") %>] |
81 |
| - <% else %> |
82 |
| - [sort] |
83 |
| - <% end %> |
84 |
| - </th> |
| 113 | + <td><%= "#{@summary[:total_for_user][username].to_i}/#{@summary[:total_available]}" %></td> |
85 | 114 | <% end %>
|
86 | 115 | </tr>
|
87 |
| - </thead> |
88 |
| - <tbody> |
89 |
| - <% @summary[:users].each_with_index do |user, index| %> |
90 |
| - <% username = user.login %> |
91 |
| - <% row_class = if user.administrator? || user.teacher?(@organization) then "admin" else "student" end %> |
92 |
| - <tr class="<%= row_class %>"> |
93 |
| - <td><%= index + 1 %></td> |
94 |
| - <td> |
95 |
| - <% if current_user.id == user.id || can?(:teach, @course) %> |
96 |
| - <%= link_to username, participant_path(user) %> |
97 |
| - <% else %> |
98 |
| - <%= username %> |
99 |
| - <% end %> |
100 |
| - </td> |
101 |
| - <% if @user_fields %> |
102 |
| - <% @user_fields.each do |field| %> |
103 |
| - <% field_record = user.user_field_values.find { |o| o.field_name == field.name } %> |
104 |
| - <td><%= field_record.value if field_record %></td> |
105 |
| - <% end %> |
106 |
| - <% end %> |
107 |
| - <% @summary[:sheets].each do |sheet| %> |
108 |
| - <% user_points_for_this_sheet = @summary[:awarded_for_user_and_sheet][username][sheet[:name]].to_i %> |
109 |
| - <td> |
110 |
| - <%= "#{user_points_for_this_sheet}/#{sheet[:total_available]}" %> |
111 |
| - </td> |
112 |
| - <% end %> |
113 |
| - <% if show_total_column %> |
114 |
| - <td><%= "#{@summary[:total_for_user][username].to_i}/#{@summary[:total_available]}" %></td> |
115 |
| - <% end %> |
116 |
| - </tr> |
117 |
| - <% end %> |
118 |
| - </tbody> |
119 |
| - </table> |
120 |
| - <% end %> |
121 |
| - </div> |
| 116 | + <% end %> |
| 117 | + </tbody> |
| 118 | + </table> |
| 119 | + <% end %> |
122 | 120 | </div>
|
0 commit comments