Description:
shows more login/contest info on result page
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r304:a6eab16005af - - 2 files changed: 9 inserted, 1 deleted
@@ -75,97 +75,97 | |||
|
75 | 75 | else |
|
76 | 76 | password = random_password |
|
77 | 77 | user_alias = (items.length>=4) ? items[3] : login |
|
78 | 78 | added_random_password = true |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | user = User.new({:login => login, |
|
82 | 82 | :full_name => full_name, |
|
83 | 83 | :password => password, |
|
84 | 84 | :password_confirmation => password, |
|
85 | 85 | :alias => user_alias}) |
|
86 | 86 | user.activated = true |
|
87 | 87 | user.save |
|
88 | 88 | |
|
89 | 89 | if added_random_password |
|
90 | 90 | note << "'#{login}' (+)" |
|
91 | 91 | else |
|
92 | 92 | note << login |
|
93 | 93 | end |
|
94 | 94 | end |
|
95 | 95 | end |
|
96 | 96 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
97 | 97 | ' were successfully created. ' + |
|
98 | 98 | '( (+) - created with random passwords.)' |
|
99 | 99 | redirect_to :action => 'list' |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def edit |
|
103 | 103 | @user = User.find(params[:id]) |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | def update |
|
107 | 107 | @user = User.find(params[:id]) |
|
108 | 108 | if @user.update_attributes(params[:user]) |
|
109 | 109 | flash[:notice] = 'User was successfully updated.' |
|
110 | 110 | redirect_to :action => 'show', :id => @user |
|
111 | 111 | else |
|
112 | 112 | render :action => 'edit' |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | def destroy |
|
117 | 117 | User.find(params[:id]).destroy |
|
118 | 118 | redirect_to :action => 'list' |
|
119 | 119 | end |
|
120 | 120 | |
|
121 | 121 | def user_stat |
|
122 | 122 | @problems = Problem.find_available_problems |
|
123 | - @users = User.find(:all) | |
|
123 | + @users = User.find(:all, :include => [:contests, :contest_stat]) | |
|
124 | 124 | @scorearray = Array.new |
|
125 | 125 | @users.each do |u| |
|
126 | 126 | ustat = Array.new |
|
127 | 127 | ustat[0] = u |
|
128 | 128 | @problems.each do |p| |
|
129 | 129 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
130 | 130 | if (sub!=nil) and (sub.points!=nil) |
|
131 | 131 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
132 | 132 | else |
|
133 | 133 | ustat << [0,false] |
|
134 | 134 | end |
|
135 | 135 | end |
|
136 | 136 | @scorearray << ustat |
|
137 | 137 | end |
|
138 | 138 | end |
|
139 | 139 | |
|
140 | 140 | def import |
|
141 | 141 | if params[:file]=='' |
|
142 | 142 | flash[:notice] = 'Error importing no file' |
|
143 | 143 | redirect_to :action => 'list' and return |
|
144 | 144 | end |
|
145 | 145 | import_from_file(params[:file]) |
|
146 | 146 | end |
|
147 | 147 | |
|
148 | 148 | def random_all_passwords |
|
149 | 149 | users = User.find(:all) |
|
150 | 150 | @prefix = params[:prefix] || '' |
|
151 | 151 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
152 | 152 | @changed = false |
|
153 | 153 | if request.request_method == :post |
|
154 | 154 | @non_admin_users.each do |user| |
|
155 | 155 | password = random_password |
|
156 | 156 | user.password = password |
|
157 | 157 | user.password_confirmation = password |
|
158 | 158 | user.save |
|
159 | 159 | end |
|
160 | 160 | @changed = true |
|
161 | 161 | end |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | # contest management |
|
165 | 165 | |
|
166 | 166 | def contests |
|
167 | 167 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
168 | 168 | @contests = Contest.enabled |
|
169 | 169 | end |
|
170 | 170 | |
|
171 | 171 | def assign_from_list |
@@ -1,35 +1,43 | |||
|
1 | 1 | <h1>User grading results</h1> |
|
2 | 2 | |
|
3 | 3 | <table class="info"> |
|
4 | 4 | <tr class="info-head"> |
|
5 | 5 | <th>User</th> |
|
6 | 6 | <th>Name</th> |
|
7 | 7 | <th>Activated?</th> |
|
8 | + <th>Logged in</th> | |
|
9 | + <th>Contest(s)</th> | |
|
8 | 10 | <% @problems.each do |p| %> |
|
9 | 11 | <th><%= p.name %></th> |
|
10 | 12 | <% end %> |
|
11 | 13 | <th>Total</th> |
|
12 | 14 | <th>Passed</th> |
|
13 | 15 | </tr> |
|
14 | 16 | <% counter = 0 %> |
|
15 | 17 | <% @scorearray.each do |sc| %> |
|
16 | 18 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
17 | 19 | <% total = 0 %> |
|
18 | 20 | <% num_passed = 0 %> |
|
19 | 21 | <% sc.each_index do |i| %> |
|
20 | 22 | <% if i==0 %> |
|
21 | 23 | <td><%= sc[i].login %></td> |
|
22 | 24 | <td><%= sc[i].full_name %></td> |
|
23 | 25 | <td><%= sc[i].activated %></td> |
|
26 | + <td> | |
|
27 | + <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> | |
|
28 | + </td> | |
|
29 | + <td> | |
|
30 | + <%= sc[i].contests.collect {|c| c.name}.join(', ') %> | |
|
31 | + </td> | |
|
24 | 32 | <% else %> |
|
25 | 33 | <td><%= sc[i][0] %></td> |
|
26 | 34 | <% total += sc[i][0] %> |
|
27 | 35 | <% num_passed += 1 if sc[i][1] %> |
|
28 | 36 | <% end %> |
|
29 | 37 | <% end %> |
|
30 | 38 | <td><%= total %></td> |
|
31 | 39 | <td><%= num_passed %></td> |
|
32 | 40 | </tr> |
|
33 | 41 | <% counter += 1 %> |
|
34 | 42 | <% end %> |
|
35 | 43 | </table> |
You need to be logged in to leave comments.
Login now