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
@@ -40,193 +40,193 | |||
|
40 | 40 | end |
|
41 | 41 | end |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | def show |
|
45 | 45 | @user = User.find(params[:id]) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def new |
|
49 | 49 | @user = User.new |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def create |
|
53 | 53 | @user = User.new(params[:user]) |
|
54 | 54 | @user.activated = true |
|
55 | 55 | if @user.save |
|
56 | 56 | flash[:notice] = 'User was successfully created.' |
|
57 | 57 | redirect_to :action => 'list' |
|
58 | 58 | else |
|
59 | 59 | render :action => 'new' |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | def create_from_list |
|
64 | 64 | lines = params[:user_list] |
|
65 | 65 | |
|
66 | 66 | note = [] |
|
67 | 67 | |
|
68 | 68 | lines.split("\n").each do |line| |
|
69 | 69 | items = line.chomp.split(',') |
|
70 | 70 | if items.length>=2 |
|
71 | 71 | login = items[0] |
|
72 | 72 | full_name = items[1] |
|
73 | 73 | |
|
74 | 74 | added_random_password = false |
|
75 | 75 | if items.length>=3 |
|
76 | 76 | password = items[2].chomp(" ") |
|
77 | 77 | user_alias = (items.length>=4) ? items[3] : login |
|
78 | 78 | else |
|
79 | 79 | password = random_password |
|
80 | 80 | user_alias = (items.length>=4) ? items[3] : login |
|
81 | 81 | added_random_password = true |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | user = User.new({:login => login, |
|
85 | 85 | :full_name => full_name, |
|
86 | 86 | :password => password, |
|
87 | 87 | :password_confirmation => password, |
|
88 | 88 | :alias => user_alias}) |
|
89 | 89 | user.activated = true |
|
90 | 90 | user.save |
|
91 | 91 | |
|
92 | 92 | if added_random_password |
|
93 | 93 | note << "'#{login}' (+)" |
|
94 | 94 | else |
|
95 | 95 | note << login |
|
96 | 96 | end |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
100 | 100 | ' were successfully created. ' + |
|
101 | 101 | '( (+) - created with random passwords.)' |
|
102 | 102 | redirect_to :action => 'list' |
|
103 | 103 | end |
|
104 | 104 | |
|
105 | 105 | def edit |
|
106 | 106 | @user = User.find(params[:id]) |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | def update |
|
110 | 110 | @user = User.find(params[:id]) |
|
111 | 111 | if @user.update_attributes(params[:user]) |
|
112 | 112 | flash[:notice] = 'User was successfully updated.' |
|
113 | 113 | redirect_to :action => 'show', :id => @user |
|
114 | 114 | else |
|
115 | 115 | render :action => 'edit' |
|
116 | 116 | end |
|
117 | 117 | end |
|
118 | 118 | |
|
119 | 119 | def destroy |
|
120 | 120 | User.find(params[:id]).destroy |
|
121 | 121 | redirect_to :action => 'list' |
|
122 | 122 | end |
|
123 | 123 | |
|
124 | 124 | def user_stat |
|
125 | 125 | @problems = Problem.find_available_problems |
|
126 | 126 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
127 | 127 | @scorearray = Array.new |
|
128 | 128 | @users.each do |u| |
|
129 | 129 | ustat = Array.new |
|
130 | 130 | ustat[0] = u |
|
131 | 131 | @problems.each do |p| |
|
132 | 132 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
133 | 133 | if (sub!=nil) and (sub.points!=nil) |
|
134 | 134 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
135 | 135 | else |
|
136 |
- ustat << [ |
|
|
136 | + ustat << [nil,false] | |
|
137 | 137 | end |
|
138 | 138 | end |
|
139 | 139 | @scorearray << ustat |
|
140 | 140 | end |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | def user_stat_max |
|
144 | 144 | @problems = Problem.find_available_problems |
|
145 | 145 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
146 | 146 | @scorearray = Array.new |
|
147 | 147 | #set up range from param |
|
148 | 148 | since_id = params.fetch(:since_id, 0).to_i |
|
149 | 149 | until_id = params.fetch(:until_id, 0).to_i |
|
150 | 150 | @users.each do |u| |
|
151 | 151 | ustat = Array.new |
|
152 | 152 | ustat[0] = u |
|
153 | 153 | @problems.each do |p| |
|
154 | 154 | max_points = 0 |
|
155 | 155 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
156 | 156 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
157 | 157 | end |
|
158 | 158 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
159 | 159 | end |
|
160 | 160 | @scorearray << ustat |
|
161 | 161 | end |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | def import |
|
165 | 165 | if params[:file]=='' |
|
166 | 166 | flash[:notice] = 'Error importing no file' |
|
167 | 167 | redirect_to :action => 'list' and return |
|
168 | 168 | end |
|
169 | 169 | import_from_file(params[:file]) |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | def random_all_passwords |
|
173 | 173 | users = User.find(:all) |
|
174 | 174 | @prefix = params[:prefix] || '' |
|
175 | 175 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
176 | 176 | @changed = false |
|
177 | 177 | if request.request_method == 'POST' |
|
178 | 178 | @non_admin_users.each do |user| |
|
179 | 179 | password = random_password |
|
180 | 180 | user.password = password |
|
181 | 181 | user.password_confirmation = password |
|
182 | 182 | user.save |
|
183 | 183 | end |
|
184 | 184 | @changed = true |
|
185 | 185 | end |
|
186 | 186 | end |
|
187 | 187 | |
|
188 | 188 | # contest management |
|
189 | 189 | |
|
190 | 190 | def contests |
|
191 | 191 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
192 | 192 | @contests = Contest.enabled |
|
193 | 193 | end |
|
194 | 194 | |
|
195 | 195 | def assign_from_list |
|
196 | 196 | contest_id = params[:users_contest_id] |
|
197 | 197 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
198 | 198 | contest = Contest.find(params[:new_contest][:id]) |
|
199 | 199 | if !contest |
|
200 | 200 | flash[:notice] = 'Error: no contest' |
|
201 | 201 | redirect_to :action => 'contests', :id =>contest_id |
|
202 | 202 | end |
|
203 | 203 | |
|
204 | 204 | note = [] |
|
205 | 205 | users.each do |u| |
|
206 | 206 | u.contests = [contest] |
|
207 | 207 | note << u.login |
|
208 | 208 | end |
|
209 | 209 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
210 | 210 | " were successfully reassigned to #{contest.title}." |
|
211 | 211 | redirect_to :action => 'contests', :id =>contest.id |
|
212 | 212 | end |
|
213 | 213 | |
|
214 | 214 | def add_to_contest |
|
215 | 215 | user = User.find(params[:id]) |
|
216 | 216 | contest = Contest.find(params[:contest_id]) |
|
217 | 217 | if user and contest |
|
218 | 218 | user.contests << contest |
|
219 | 219 | end |
|
220 | 220 | redirect_to :action => 'list' |
|
221 | 221 | end |
|
222 | 222 | |
|
223 | 223 | def remove_from_contest |
|
224 | 224 | user = User.find(params[:id]) |
|
225 | 225 | contest = Contest.find(params[:contest_id]) |
|
226 | 226 | if user and contest |
|
227 | 227 | user.contests.delete(contest) |
|
228 | 228 | end |
|
229 | 229 | redirect_to :action => 'list' |
|
230 | 230 | end |
|
231 | 231 | |
|
232 | 232 | def contest_management |
@@ -1,48 +1,52 | |||
|
1 | 1 | <h1>User grading results</h1> |
|
2 | 2 | <h2>Show scores from latest submission</h2> |
|
3 | 3 | |
|
4 | 4 | <%= render 'submission_range' %> |
|
5 | 5 | |
|
6 | 6 | <p>Latest scores</p> |
|
7 | 7 | |
|
8 | 8 | <table class="info"> |
|
9 | 9 | <tr class="info-head"> |
|
10 | 10 | <th>User</th> |
|
11 | 11 | <th>Name</th> |
|
12 | 12 | <th>Activated?</th> |
|
13 | 13 | <th>Logged in</th> |
|
14 | 14 | <th>Contest(s)</th> |
|
15 | 15 | <% @problems.each do |p| %> |
|
16 | 16 | <th><%= p.name %></th> |
|
17 | 17 | <% end %> |
|
18 | 18 | <th>Total</th> |
|
19 | 19 | <th>Passed</th> |
|
20 | 20 | </tr> |
|
21 | 21 | <% counter = 0 %> |
|
22 | 22 | <% @scorearray.each do |sc| %> |
|
23 | 23 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
24 | 24 | <% total = 0 %> |
|
25 | 25 | <% num_passed = 0 %> |
|
26 | 26 | <% sc.each_index do |i| %> |
|
27 | 27 | <% if i==0 %> |
|
28 | 28 | <td><%= sc[i].login %></td> |
|
29 | 29 | <td><%= sc[i].full_name %></td> |
|
30 | 30 | <td><%= sc[i].activated %></td> |
|
31 | 31 | <td> |
|
32 | 32 | <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> |
|
33 | 33 | </td> |
|
34 | 34 | <td> |
|
35 | 35 | <%= sc[i].contests.collect {|c| c.name}.join(', ') %> |
|
36 | 36 | </td> |
|
37 |
- <% else %> |
|
|
38 |
- < |
|
|
39 |
- |
|
|
40 |
- |
|
|
37 | + <% else %> | |
|
38 | + <% if sc[i][0] != nil %> | |
|
39 | + <td><%= sc[i][0] %></td> | |
|
40 | + <% total += sc[i][0] %> | |
|
41 | + <% num_passed += 1 if sc[i][1] %> | |
|
42 | + <% else %> | |
|
43 | + <td>-</td> | |
|
44 | + <% end %> | |
|
41 | 45 | <% end %> |
|
42 | 46 | <% end %> |
|
43 | 47 | <td><%= total %></td> |
|
44 | 48 | <td><%= num_passed %></td> |
|
45 | 49 | </tr> |
|
46 | 50 | <% counter += 1 %> |
|
47 | 51 | <% end %> |
|
48 | 52 | </table> |
You need to be logged in to leave comments.
Login now