Skip to content

Commit 81b60ec

Browse files
committed
Add emails to point lists
1 parent c0bf22d commit 81b60ec

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

app/controllers/points_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def summary_hash(course, visible_exercises, sheets, only_for_user = nil)
101101
end
102102

103103
include_admins = current_user.administrator?
104-
users = User.select('login, users.id, administrator').where(login: per_user_and_sheet.keys.sort_by(&:downcase)).includes(:organizations).includes(:user_field_values).order('login ASC')
104+
users = User.select('login, email, users.id, administrator').where(login: per_user_and_sheet.keys.sort_by(&:downcase)).includes(:organizations).includes(:user_field_values).order('login ASC')
105105

106106
users = users.where(administrator: false) unless include_admins
107107

app/views/points/index.csv.erb

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<%= PortableCSV.generate(:force_quotes => true) do |csv|
33
arr = []
44
arr += @user_fields.map(&:label) if @user_fields
5+
arr << :email if can?(:teach, @course)
56
arr += @summary[:sheets].map {|sheet| sheet[:name] } + ["Total"]
67
csv << arr
78

@@ -17,6 +18,7 @@
1718
arr << (user_field_value ? user_field_value.value : '')
1819
end
1920
end
21+
arr << user.email if can?(:teach, @course)
2022
arr += points + [total]
2123
csv << arr
2224
end

app/views/points/index.html.erb

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<th><%= field.label %></th>
5151
<% end %>
5252
<% end %>
53+
<% if can?(:teach, @course) %>
54+
<th>Email</th>
55+
<% end %>
5356
<% @summary[:sheets].map{|s| s[:name]}.each do |sheet| %>
5457
<th>
5558
<%= sheet %><br />
@@ -93,6 +96,9 @@
9396
<td><%= field_record.value if field_record %></td>
9497
<% end %>
9598
<% end %>
99+
<% if can?(:teach, @course) %>
100+
<td><%= user.email %></td>
101+
<% end %>
96102
<% @summary[:sheets].each do |sheet| %>
97103
<% user_points_for_this_sheet = @summary[:awarded_for_user_and_sheet][username][sheet[:name]].to_i %>
98104
<td>

app/views/points/show.html.erb

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<th><%= field.label %></th>
3333
<% end %>
3434
<% end %>
35+
<% if can?(:teach, @course) %>
36+
<th>Email</th>
37+
<% end %>
3538
<% @exercises.each do |exercise| %>
3639
<% points = exercise.available_points.order! %>
3740
<% if points.size > 0 %>
@@ -41,7 +44,7 @@
4144
</tr>
4245
<% end %>
4346
<tr>
44-
<th colspan="<%= 2 + (@user_fields ? @user_fields.length : 0) %>"></th>
47+
<th colspan="<%= 2 + (@user_fields ? @user_fields.length : 0) + (can?(:teach, @course) ? 1 : 0) %>"></th>
4548

4649
<% @exercises.each do |exercise| %>
4750
<% exercise.available_points.sort.each do |point| %>
@@ -71,6 +74,9 @@
7174
<td><%= value.value if value %></td>
7275
<% end %>
7376
<% end %>
77+
<% if can?(:teach, @course) %>
78+
<td><%= user.email %></td>
79+
<% end %>
7480
<% @exercises.each do |exercise| %>
7581
<% exercise.available_points.sort.each do |p| %>
7682
<td class="point-cell">

0 commit comments

Comments
 (0)