Skip to content

Commit 36dd765

Browse files
author
Irene
committed
Use flexbox more sensibly
1 parent 4a45d09 commit 36dd765

File tree

6 files changed

+182
-185
lines changed

6 files changed

+182
-185
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tmc-server-base
1+
FROM testmycode/tmc-server-base:latest
22
LABEL name tmc-server
33

44
ADD Gemfile /app/Gemfile

app/assets/stylesheets/main.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* Submissions status*/
2-
@import "_footer";
3-
@import "_breadcrumb";
2+
@import "breadcrumb";
43

54
.error,
65
.failure,
@@ -150,7 +149,7 @@ div.stack-trace {
150149
.scrollable {
151150
width: 95vw;
152151
height: 70vh;
153-
align-self: left;
152+
align-self: center;
154153
overflow: auto;
155154
}
156155

@@ -481,7 +480,7 @@ td.hljs-ln-code {
481480
min-width: 200px;
482481
}
483482

484-
#content-area {
483+
.points-container {
485484
display: flex;
486485
flex-direction: column;
487486
align-content: stretch;

app/assets/stylesheets/points.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
.course-point-header {
44
display: flex;
5-
justify-content: space-around;
6-
align-content: center;
75
align-items: center;
6+
justify-content: space-between;
87
}
98

109
.point-cell {
1110
border: 1px solid darken($breadcrumb-grey, 5%);
1211
}
13-
14-
.points-container {
15-
align-self: center;
16-
}

app/controllers/points_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def index
2525
sort_summary(@summary, params[:sort_by]) if params[:sort_by]
2626
@summary
2727
else
28-
@summary = Rails.cache.fetch("points_#{@course.id}_admin_#{current_user.administrator?}/", expires_in: 1.second) do
28+
@summary = Rails.cache.fetch("points_#{@course.id}_admin_#{current_user.administrator?}/", expires_in: 1.minute) do
2929
exercises = @course.exercises.enabled.where(exercises: { hidden: false })
3030
exercises = exercises.where(hide_submission_results: false) unless current_user.administrator?
3131
sheets = @course.gdocs_sheets(exercises).natsort

app/views/points/index.html.erb

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
11
<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>
7-
<% end %>
8-
</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>
97
<% end %>
8+
</div>
9+
<% end %>
1010

11-
<%
12-
show_total_column = @summary[:sheets].size > 1
13-
%>
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 %>
1416

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 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>
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]
3853
<% end %>
39-
<% if show_total_column %>
40-
<td>
41-
<%= "#{@summary[:total_awarded]}/#{@summary[:total_available]*nstudents}" %>
42-
</td>
54+
</th>
55+
<% if @user_fields %>
56+
<% @user_fields.each do |field| %>
57+
<th><%= field.label %></th>
58+
<% end %>
4359
<% end %>
44-
</tr>
45-
<tr>
46-
<th></th>
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 %>
4773
<th>
48-
Student<br />
49-
<% unless params[:sort_by].blank? %>
50-
[<%= link_to 'sort', organization_course_points_path(@organization, @course) %>]
74+
Total<br />
75+
<% unless params[:sort_by] == 'total_points' %>
76+
[<%= link_to 'sort', organization_course_points_path(@organization, @course, :sort_by => "total_points") %>]
5177
<% else %>
5278
[sort]
5379
<% end %>
5480
</th>
55-
<% if @user_fields %>
56-
<% @user_fields.each do |field| %>
57-
<th><%= field.label %></th>
58-
<% end %>
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>
59101
<% 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>
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>
71108
<% end %>
72109
<% if show_total_column %>
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>
110+
<td><%= "#{@summary[:total_for_user][username].to_i}/#{@summary[:total_available]}" %></td>
81111
<% end %>
82112
</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>
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>
113+
<% end %>
114+
</tbody>
115+
</table>
116+
<% end %>
117+
<div>

0 commit comments

Comments
 (0)