Skip to content

Commit e7d370d

Browse files
author
Irene
committed
Improve css
Limit the size of scrollable in points#index and points#show, and move it to the left. Have the whole content in a felxbox. Improve participants#index checkbox styles
1 parent 290a1a9 commit e7d370d

File tree

11 files changed

+236
-193
lines changed

11 files changed

+236
-193
lines changed

Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
FROM testmycode/tmc-server-base:latest
1+
FROM tmc-server-base
22
LABEL name tmc-server
33

44
ADD Gemfile /app/Gemfile
55
ADD Gemfile.lock /app/Gemfile.lock
6-
RUN bundle install --system
6+
RUN bundle install --system --gemfile /app/Gemfile
77
ADD . /app
8-

app/assets/stylesheets/_footer.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
$footer_height: 5rem;
2+
13
.footer {
2-
height: 5rem;
4+
height: $footer_height;
35
background-color: rgb(54, 116, 214);
46
}
57

app/assets/stylesheets/main.scss

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* Submissions status*/
2+
@import "_footer";
3+
24
.error,
35
.failure,
46
.fail {
@@ -144,8 +146,16 @@ div.stack-trace {
144146
font-family: monospace;
145147
}
146148

149+
.scrollable-container {
150+
width: 95vw;
151+
height: 70vh;
152+
align-self: left;
153+
}
154+
147155
.scrollable {
148156
overflow: auto;
157+
max-height: 100%;
158+
max-width: 100%;
149159
}
150160

151161
div.feedback-question {
@@ -460,3 +470,13 @@ td.hljs-ln-code {
460470
margin-right: 1rem;
461471
min-width: 200px;
462472
}
473+
474+
#content-area {
475+
display: flex;
476+
flex-direction: column;
477+
align-content: stretch;
478+
}
479+
480+
#filter-form input[type="checkbox"], select {
481+
margin: 0.2rem;
482+
}

app/assets/stylesheets/points.css

-5
This file was deleted.

app/assets/stylesheets/points.scss

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.course-point-header {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
}
6+
7+
.point-cell {
8+
border: 1px solid black;
9+
text-align: center;
10+
}
11+
12+
.points-container {
13+
align-self: center;
14+
}
15+

app/controllers/points_controller.rb

+1-1
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.minute) do
28+
@summary = Rails.cache.fetch("points_#{@course.id}_admin_#{current_user.administrator?}/", expires_in: 1.second) 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/helpers/extra_field_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def extra_field_checkbox(prefix, field, value)
6565
return '' if field.field_type == :html
6666
field_name = prefix + field.name
6767
field_tag = check_box_tag(field_name, '1', !value.blank?)
68-
bs_labeled_field(raw(field.name.humanize), field_tag, order: :label_last)
68+
labeled_field(raw(field.name.humanize), field_tag, :order => :label_last, :super_class => "checkbox")
6969
end
7070

7171
def extra_field_value(value_record)

app/views/participants/index.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1>List of participants</h1>
22

3-
<%= form_tag(participants_path, :method => :get) do %>
3+
<%= form_tag(participants_path, :method => :get, :id => "filter-form") do %>
44
<div style="float: left">
55
<%= render :partial => 'participants/filter_controls' %>
66
</div>

app/views/points/index.html.erb

+113-106
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,122 @@
1-
<% unless @bare_layout %>
2-
<div class="course-point-header">
3-
<h1>Summary of points for <%= @course.title %></h1>
4-
<% if can?(:teach, @course) %>
5-
<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>
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>
7+
<% end %>
8+
</div>
69
<% end %>
7-
</div>
8-
<% end %>
910

10-
<%
11-
show_total_column = @summary[:sheets].size > 1
12-
%>
11+
<%
12+
show_total_column = @summary[:sheets].size > 1
13+
%>
1314

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

0 commit comments

Comments
 (0)