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