Description:
shows scores only for submitted problems
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r386:aef66acd0ee0 - - 2 files changed: 9 inserted, 5 deleted
@@ -88,97 +88,97 | |||||
|
88 | :alias => user_alias}) |
|
88 | :alias => user_alias}) |
|
89 | user.activated = true |
|
89 | user.activated = true |
|
90 | user.save |
|
90 | user.save |
|
91 |
|
91 | ||
|
92 | if added_random_password |
|
92 | if added_random_password |
|
93 | note << "'#{login}' (+)" |
|
93 | note << "'#{login}' (+)" |
|
94 | else |
|
94 | else |
|
95 | note << login |
|
95 | note << login |
|
96 | end |
|
96 | end |
|
97 | end |
|
97 | end |
|
98 | end |
|
98 | end |
|
99 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
99 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
100 | ' were successfully created. ' + |
|
100 | ' were successfully created. ' + |
|
101 | '( (+) - created with random passwords.)' |
|
101 | '( (+) - created with random passwords.)' |
|
102 | redirect_to :action => 'list' |
|
102 | redirect_to :action => 'list' |
|
103 | end |
|
103 | end |
|
104 |
|
104 | ||
|
105 | def edit |
|
105 | def edit |
|
106 | @user = User.find(params[:id]) |
|
106 | @user = User.find(params[:id]) |
|
107 | end |
|
107 | end |
|
108 |
|
108 | ||
|
109 | def update |
|
109 | def update |
|
110 | @user = User.find(params[:id]) |
|
110 | @user = User.find(params[:id]) |
|
111 | if @user.update_attributes(params[:user]) |
|
111 | if @user.update_attributes(params[:user]) |
|
112 | flash[:notice] = 'User was successfully updated.' |
|
112 | flash[:notice] = 'User was successfully updated.' |
|
113 | redirect_to :action => 'show', :id => @user |
|
113 | redirect_to :action => 'show', :id => @user |
|
114 | else |
|
114 | else |
|
115 | render :action => 'edit' |
|
115 | render :action => 'edit' |
|
116 | end |
|
116 | end |
|
117 | end |
|
117 | end |
|
118 |
|
118 | ||
|
119 | def destroy |
|
119 | def destroy |
|
120 | User.find(params[:id]).destroy |
|
120 | User.find(params[:id]).destroy |
|
121 | redirect_to :action => 'list' |
|
121 | redirect_to :action => 'list' |
|
122 | end |
|
122 | end |
|
123 |
|
123 | ||
|
124 | def user_stat |
|
124 | def user_stat |
|
125 | @problems = Problem.find_available_problems |
|
125 | @problems = Problem.find_available_problems |
|
126 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
126 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
127 | @scorearray = Array.new |
|
127 | @scorearray = Array.new |
|
128 | @users.each do |u| |
|
128 | @users.each do |u| |
|
129 | ustat = Array.new |
|
129 | ustat = Array.new |
|
130 | ustat[0] = u |
|
130 | ustat[0] = u |
|
131 | @problems.each do |p| |
|
131 | @problems.each do |p| |
|
132 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
132 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
133 | if (sub!=nil) and (sub.points!=nil) |
|
133 | if (sub!=nil) and (sub.points!=nil) |
|
134 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
134 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
135 | else |
|
135 | else |
|
136 |
- ustat << [ |
|
136 | + ustat << [nil,false] |
|
137 | end |
|
137 | end |
|
138 | end |
|
138 | end |
|
139 | @scorearray << ustat |
|
139 | @scorearray << ustat |
|
140 | end |
|
140 | end |
|
141 | end |
|
141 | end |
|
142 |
|
142 | ||
|
143 | def user_stat_max |
|
143 | def user_stat_max |
|
144 | @problems = Problem.find_available_problems |
|
144 | @problems = Problem.find_available_problems |
|
145 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
145 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
146 | @scorearray = Array.new |
|
146 | @scorearray = Array.new |
|
147 | #set up range from param |
|
147 | #set up range from param |
|
148 | since_id = params.fetch(:since_id, 0).to_i |
|
148 | since_id = params.fetch(:since_id, 0).to_i |
|
149 | until_id = params.fetch(:until_id, 0).to_i |
|
149 | until_id = params.fetch(:until_id, 0).to_i |
|
150 | @users.each do |u| |
|
150 | @users.each do |u| |
|
151 | ustat = Array.new |
|
151 | ustat = Array.new |
|
152 | ustat[0] = u |
|
152 | ustat[0] = u |
|
153 | @problems.each do |p| |
|
153 | @problems.each do |p| |
|
154 | max_points = 0 |
|
154 | max_points = 0 |
|
155 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
155 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
156 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
156 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
157 | end |
|
157 | end |
|
158 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
158 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
159 | end |
|
159 | end |
|
160 | @scorearray << ustat |
|
160 | @scorearray << ustat |
|
161 | end |
|
161 | end |
|
162 | end |
|
162 | end |
|
163 |
|
163 | ||
|
164 | def import |
|
164 | def import |
|
165 | if params[:file]=='' |
|
165 | if params[:file]=='' |
|
166 | flash[:notice] = 'Error importing no file' |
|
166 | flash[:notice] = 'Error importing no file' |
|
167 | redirect_to :action => 'list' and return |
|
167 | redirect_to :action => 'list' and return |
|
168 | end |
|
168 | end |
|
169 | import_from_file(params[:file]) |
|
169 | import_from_file(params[:file]) |
|
170 | end |
|
170 | end |
|
171 |
|
171 | ||
|
172 | def random_all_passwords |
|
172 | def random_all_passwords |
|
173 | users = User.find(:all) |
|
173 | users = User.find(:all) |
|
174 | @prefix = params[:prefix] || '' |
|
174 | @prefix = params[:prefix] || '' |
|
175 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
175 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
176 | @changed = false |
|
176 | @changed = false |
|
177 | if request.request_method == 'POST' |
|
177 | if request.request_method == 'POST' |
|
178 | @non_admin_users.each do |user| |
|
178 | @non_admin_users.each do |user| |
|
179 | password = random_password |
|
179 | password = random_password |
|
180 | user.password = password |
|
180 | user.password = password |
|
181 | user.password_confirmation = password |
|
181 | user.password_confirmation = password |
|
182 | user.save |
|
182 | user.save |
|
183 | end |
|
183 | end |
|
184 | @changed = true |
|
184 | @changed = true |
@@ -1,48 +1,52 | |||||
|
1 | <h1>User grading results</h1> |
|
1 | <h1>User grading results</h1> |
|
2 | <h2>Show scores from latest submission</h2> |
|
2 | <h2>Show scores from latest submission</h2> |
|
3 |
|
3 | ||
|
4 | <%= render 'submission_range' %> |
|
4 | <%= render 'submission_range' %> |
|
5 |
|
5 | ||
|
6 | <p>Latest scores</p> |
|
6 | <p>Latest scores</p> |
|
7 |
|
7 | ||
|
8 | <table class="info"> |
|
8 | <table class="info"> |
|
9 | <tr class="info-head"> |
|
9 | <tr class="info-head"> |
|
10 | <th>User</th> |
|
10 | <th>User</th> |
|
11 | <th>Name</th> |
|
11 | <th>Name</th> |
|
12 | <th>Activated?</th> |
|
12 | <th>Activated?</th> |
|
13 | <th>Logged in</th> |
|
13 | <th>Logged in</th> |
|
14 | <th>Contest(s)</th> |
|
14 | <th>Contest(s)</th> |
|
15 | <% @problems.each do |p| %> |
|
15 | <% @problems.each do |p| %> |
|
16 | <th><%= p.name %></th> |
|
16 | <th><%= p.name %></th> |
|
17 | <% end %> |
|
17 | <% end %> |
|
18 | <th>Total</th> |
|
18 | <th>Total</th> |
|
19 | <th>Passed</th> |
|
19 | <th>Passed</th> |
|
20 | </tr> |
|
20 | </tr> |
|
21 | <% counter = 0 %> |
|
21 | <% counter = 0 %> |
|
22 | <% @scorearray.each do |sc| %> |
|
22 | <% @scorearray.each do |sc| %> |
|
23 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
23 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
24 | <% total = 0 %> |
|
24 | <% total = 0 %> |
|
25 | <% num_passed = 0 %> |
|
25 | <% num_passed = 0 %> |
|
26 | <% sc.each_index do |i| %> |
|
26 | <% sc.each_index do |i| %> |
|
27 | <% if i==0 %> |
|
27 | <% if i==0 %> |
|
28 | <td><%= sc[i].login %></td> |
|
28 | <td><%= sc[i].login %></td> |
|
29 | <td><%= sc[i].full_name %></td> |
|
29 | <td><%= sc[i].full_name %></td> |
|
30 | <td><%= sc[i].activated %></td> |
|
30 | <td><%= sc[i].activated %></td> |
|
31 | <td> |
|
31 | <td> |
|
32 | <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> |
|
32 | <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> |
|
33 | </td> |
|
33 | </td> |
|
34 | <td> |
|
34 | <td> |
|
35 | <%= sc[i].contests.collect {|c| c.name}.join(', ') %> |
|
35 | <%= sc[i].contests.collect {|c| c.name}.join(', ') %> |
|
36 | </td> |
|
36 | </td> |
|
37 |
- <% else %> |
|
37 | + <% else %> |
|
38 |
- < |
|
38 | + <% if sc[i][0] != nil %> |
|
39 |
- |
|
39 | + <td><%= sc[i][0] %></td> |
|
40 |
- |
|
40 | + <% total += sc[i][0] %> |
|
|
41 | + <% num_passed += 1 if sc[i][1] %> | ||
|
|
42 | + <% else %> | ||
|
|
43 | + <td>-</td> | ||
|
|
44 | + <% end %> | ||
|
41 | <% end %> |
|
45 | <% end %> |
|
42 | <% end %> |
|
46 | <% end %> |
|
43 | <td><%= total %></td> |
|
47 | <td><%= total %></td> |
|
44 | <td><%= num_passed %></td> |
|
48 | <td><%= num_passed %></td> |
|
45 | </tr> |
|
49 | </tr> |
|
46 | <% counter += 1 %> |
|
50 | <% counter += 1 %> |
|
47 | <% end %> |
|
51 | <% end %> |
|
48 | </table> |
|
52 | </table> |
You need to be logged in to leave comments.
Login now