Description:
add feature check maximum score in submission ranges
available in the [result] admin menu.
A user can enter a range of submissions id and the maximum score per each user,problem
among the submission ranges will be reported
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r397:94216ffe57fe - - 3 files changed: 39 inserted, 6 deleted
@@ -36,198 +36,219 | |||||
|
36 | @users = [] |
|
36 | @users = [] |
|
37 | sessions.each do |session| |
|
37 | sessions.each do |session| |
|
38 | if session.data[:user_id] |
|
38 | if session.data[:user_id] |
|
39 | @users << User.find(session.data[:user_id]) |
|
39 | @users << User.find(session.data[:user_id]) |
|
40 | end |
|
40 | end |
|
41 | end |
|
41 | end |
|
42 | end |
|
42 | end |
|
43 |
|
43 | ||
|
44 | def show |
|
44 | def show |
|
45 | @user = User.find(params[:id]) |
|
45 | @user = User.find(params[:id]) |
|
46 | end |
|
46 | end |
|
47 |
|
47 | ||
|
48 | def new |
|
48 | def new |
|
49 | @user = User.new |
|
49 | @user = User.new |
|
50 | end |
|
50 | end |
|
51 |
|
51 | ||
|
52 | def create |
|
52 | def create |
|
53 | @user = User.new(params[:user]) |
|
53 | @user = User.new(params[:user]) |
|
54 | @user.activated = true |
|
54 | @user.activated = true |
|
55 | if @user.save |
|
55 | if @user.save |
|
56 | flash[:notice] = 'User was successfully created.' |
|
56 | flash[:notice] = 'User was successfully created.' |
|
57 | redirect_to :action => 'list' |
|
57 | redirect_to :action => 'list' |
|
58 | else |
|
58 | else |
|
59 | render :action => 'new' |
|
59 | render :action => 'new' |
|
60 | end |
|
60 | end |
|
61 | end |
|
61 | end |
|
62 |
|
62 | ||
|
63 | def create_from_list |
|
63 | def create_from_list |
|
64 | lines = params[:user_list] |
|
64 | lines = params[:user_list] |
|
65 |
|
65 | ||
|
66 | note = [] |
|
66 | note = [] |
|
67 |
|
67 | ||
|
68 | lines.split("\n").each do |line| |
|
68 | lines.split("\n").each do |line| |
|
69 | items = line.chomp.split(',') |
|
69 | items = line.chomp.split(',') |
|
70 | if items.length>=2 |
|
70 | if items.length>=2 |
|
71 | login = items[0] |
|
71 | login = items[0] |
|
72 | full_name = items[1] |
|
72 | full_name = items[1] |
|
73 |
|
73 | ||
|
74 | added_random_password = false |
|
74 | added_random_password = false |
|
75 | if items.length>=3 |
|
75 | if items.length>=3 |
|
76 | password = items[2].chomp(" ") |
|
76 | password = items[2].chomp(" ") |
|
77 | user_alias = (items.length>=4) ? items[3] : login |
|
77 | user_alias = (items.length>=4) ? items[3] : login |
|
78 | else |
|
78 | else |
|
79 | password = random_password |
|
79 | password = random_password |
|
80 | user_alias = (items.length>=4) ? items[3] : login |
|
80 | user_alias = (items.length>=4) ? items[3] : login |
|
81 | added_random_password = true |
|
81 | added_random_password = true |
|
82 | end |
|
82 | end |
|
83 |
|
83 | ||
|
84 | user = User.new({:login => login, |
|
84 | user = User.new({:login => login, |
|
85 | :full_name => full_name, |
|
85 | :full_name => full_name, |
|
86 | :password => password, |
|
86 | :password => password, |
|
87 | :password_confirmation => password, |
|
87 | :password_confirmation => password, |
|
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 |
- |
|
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 | - else |
|
135 | + else |
|
136 |
- |
|
136 | + ustat << [0,false] |
|
137 | - end |
|
137 | + end |
|
|
138 | + end | ||
|
|
139 | + @scorearray << ustat | ||
|
|
140 | + end | ||
|
|
141 | + end | ||
|
|
142 | + | ||
|
|
143 | + def user_stat_max | ||
|
|
144 | + @problems = Problem.find_available_problems | ||
|
|
145 | + @users = User.find(:all, :include => [:contests, :contest_stat]) | ||
|
|
146 | + @scorearray = Array.new | ||
|
|
147 | + #set up range from param | ||
|
|
148 | + since_id = params.fetch(:since_id, 0).to_i | ||
|
|
149 | + until_id = params.fetch(:until_id, 0).to_i | ||
|
|
150 | + @users.each do |u| | ||
|
|
151 | + ustat = Array.new | ||
|
|
152 | + ustat[0] = u | ||
|
|
153 | + @problems.each do |p| | ||
|
|
154 | + max_points = 0 | ||
|
|
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) | ||
|
|
157 | + end | ||
|
|
158 | + ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] | ||
|
138 | end |
|
159 | end |
|
139 | @scorearray << ustat |
|
160 | @scorearray << ustat |
|
140 | end |
|
161 | end |
|
141 | end |
|
162 | end |
|
142 |
|
163 | ||
|
143 | def import |
|
164 | def import |
|
144 | if params[:file]=='' |
|
165 | if params[:file]=='' |
|
145 | flash[:notice] = 'Error importing no file' |
|
166 | flash[:notice] = 'Error importing no file' |
|
146 | redirect_to :action => 'list' and return |
|
167 | redirect_to :action => 'list' and return |
|
147 | end |
|
168 | end |
|
148 | import_from_file(params[:file]) |
|
169 | import_from_file(params[:file]) |
|
149 | end |
|
170 | end |
|
150 |
|
171 | ||
|
151 | def random_all_passwords |
|
172 | def random_all_passwords |
|
152 | users = User.find(:all) |
|
173 | users = User.find(:all) |
|
153 | @prefix = params[:prefix] || '' |
|
174 | @prefix = params[:prefix] || '' |
|
154 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
175 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
155 | @changed = false |
|
176 | @changed = false |
|
156 | if request.request_method == 'POST' |
|
177 | if request.request_method == 'POST' |
|
157 | @non_admin_users.each do |user| |
|
178 | @non_admin_users.each do |user| |
|
158 | password = random_password |
|
179 | password = random_password |
|
159 | user.password = password |
|
180 | user.password = password |
|
160 | user.password_confirmation = password |
|
181 | user.password_confirmation = password |
|
161 | user.save |
|
182 | user.save |
|
162 | end |
|
183 | end |
|
163 | @changed = true |
|
184 | @changed = true |
|
164 | end |
|
185 | end |
|
165 | end |
|
186 | end |
|
166 |
|
187 | ||
|
167 | # contest management |
|
188 | # contest management |
|
168 |
|
189 | ||
|
169 | def contests |
|
190 | def contests |
|
170 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
191 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
171 | @contests = Contest.enabled |
|
192 | @contests = Contest.enabled |
|
172 | end |
|
193 | end |
|
173 |
|
194 | ||
|
174 | def assign_from_list |
|
195 | def assign_from_list |
|
175 | contest_id = params[:users_contest_id] |
|
196 | contest_id = params[:users_contest_id] |
|
176 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
197 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
177 | contest = Contest.find(params[:new_contest][:id]) |
|
198 | contest = Contest.find(params[:new_contest][:id]) |
|
178 | if !contest |
|
199 | if !contest |
|
179 | flash[:notice] = 'Error: no contest' |
|
200 | flash[:notice] = 'Error: no contest' |
|
180 | redirect_to :action => 'contests', :id =>contest_id |
|
201 | redirect_to :action => 'contests', :id =>contest_id |
|
181 | end |
|
202 | end |
|
182 |
|
203 | ||
|
183 | note = [] |
|
204 | note = [] |
|
184 | users.each do |u| |
|
205 | users.each do |u| |
|
185 | u.contests = [contest] |
|
206 | u.contests = [contest] |
|
186 | note << u.login |
|
207 | note << u.login |
|
187 | end |
|
208 | end |
|
188 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
209 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
189 | " were successfully reassigned to #{contest.title}." |
|
210 | " were successfully reassigned to #{contest.title}." |
|
190 | redirect_to :action => 'contests', :id =>contest.id |
|
211 | redirect_to :action => 'contests', :id =>contest.id |
|
191 | end |
|
212 | end |
|
192 |
|
213 | ||
|
193 | def add_to_contest |
|
214 | def add_to_contest |
|
194 | user = User.find(params[:id]) |
|
215 | user = User.find(params[:id]) |
|
195 | contest = Contest.find(params[:contest_id]) |
|
216 | contest = Contest.find(params[:contest_id]) |
|
196 | if user and contest |
|
217 | if user and contest |
|
197 | user.contests << contest |
|
218 | user.contests << contest |
|
198 | end |
|
219 | end |
|
199 | redirect_to :action => 'list' |
|
220 | redirect_to :action => 'list' |
|
200 | end |
|
221 | end |
|
201 |
|
222 | ||
|
202 | def remove_from_contest |
|
223 | def remove_from_contest |
|
203 | user = User.find(params[:id]) |
|
224 | user = User.find(params[:id]) |
|
204 | contest = Contest.find(params[:contest_id]) |
|
225 | contest = Contest.find(params[:contest_id]) |
|
205 | if user and contest |
|
226 | if user and contest |
|
206 | user.contests.delete(contest) |
|
227 | user.contests.delete(contest) |
|
207 | end |
|
228 | end |
|
208 | redirect_to :action => 'list' |
|
229 | redirect_to :action => 'list' |
|
209 | end |
|
230 | end |
|
210 |
|
231 | ||
|
211 | def contest_management |
|
232 | def contest_management |
|
212 | end |
|
233 | end |
|
213 |
|
234 | ||
|
214 | def manage_contest |
|
235 | def manage_contest |
|
215 | contest = Contest.find(params[:contest][:id]) |
|
236 | contest = Contest.find(params[:contest][:id]) |
|
216 | if !contest |
|
237 | if !contest |
|
217 | flash[:notice] = 'You did not choose the contest.' |
|
238 | flash[:notice] = 'You did not choose the contest.' |
|
218 | redirect_to :action => 'contest_management' and return |
|
239 | redirect_to :action => 'contest_management' and return |
|
219 | end |
|
240 | end |
|
220 |
|
241 | ||
|
221 | operation = params[:operation] |
|
242 | operation = params[:operation] |
|
222 |
|
243 | ||
|
223 | if not ['add','remove','assign'].include? operation |
|
244 | if not ['add','remove','assign'].include? operation |
|
224 | flash[:notice] = 'You did not choose the operation to perform.' |
|
245 | flash[:notice] = 'You did not choose the operation to perform.' |
|
225 | redirect_to :action => 'contest_management' and return |
|
246 | redirect_to :action => 'contest_management' and return |
|
226 | end |
|
247 | end |
|
227 |
|
248 | ||
|
228 | lines = params[:login_list] |
|
249 | lines = params[:login_list] |
|
229 | if !lines or lines.blank? |
|
250 | if !lines or lines.blank? |
|
230 | flash[:notice] = 'You entered an empty list.' |
|
251 | flash[:notice] = 'You entered an empty list.' |
|
231 | redirect_to :action => 'contest_management' and return |
|
252 | redirect_to :action => 'contest_management' and return |
|
232 | end |
|
253 | end |
|
233 |
|
254 |
@@ -1,132 +1,139 | |||||
|
1 | class Submission < ActiveRecord::Base |
|
1 | class Submission < ActiveRecord::Base |
|
2 |
|
2 | ||
|
3 | belongs_to :language |
|
3 | belongs_to :language |
|
4 | belongs_to :problem |
|
4 | belongs_to :problem |
|
5 | belongs_to :user |
|
5 | belongs_to :user |
|
6 |
|
6 | ||
|
7 | before_validation :assign_problem |
|
7 | before_validation :assign_problem |
|
8 | before_validation :assign_language |
|
8 | before_validation :assign_language |
|
9 |
|
9 | ||
|
10 | validates_presence_of :source |
|
10 | validates_presence_of :source |
|
11 | validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long' |
|
11 | validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long' |
|
12 | validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short' |
|
12 | validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short' |
|
13 | validate :must_have_valid_problem |
|
13 | validate :must_have_valid_problem |
|
14 | validate :must_specify_language |
|
14 | validate :must_specify_language |
|
15 |
|
15 | ||
|
16 | before_save :assign_latest_number_if_new_recond |
|
16 | before_save :assign_latest_number_if_new_recond |
|
17 |
|
17 | ||
|
18 | def self.find_last_by_user_and_problem(user_id, problem_id) |
|
18 | def self.find_last_by_user_and_problem(user_id, problem_id) |
|
19 | last_sub = find(:first, |
|
19 | last_sub = find(:first, |
|
20 | :conditions => {:user_id => user_id, |
|
20 | :conditions => {:user_id => user_id, |
|
21 | :problem_id => problem_id}, |
|
21 | :problem_id => problem_id}, |
|
22 | :order => 'number DESC') |
|
22 | :order => 'number DESC') |
|
23 | return last_sub |
|
23 | return last_sub |
|
24 | end |
|
24 | end |
|
25 |
|
25 | ||
|
26 | def self.find_all_last_by_problem(problem_id) |
|
26 | def self.find_all_last_by_problem(problem_id) |
|
27 | # need to put in SQL command, maybe there's a better way |
|
27 | # need to put in SQL command, maybe there's a better way |
|
28 | Submission.find_by_sql("SELECT * FROM submissions " + |
|
28 | Submission.find_by_sql("SELECT * FROM submissions " + |
|
29 | "WHERE id = " + |
|
29 | "WHERE id = " + |
|
30 | "(SELECT MAX(id) FROM submissions AS subs " + |
|
30 | "(SELECT MAX(id) FROM submissions AS subs " + |
|
31 | "WHERE subs.user_id = submissions.user_id AND " + |
|
31 | "WHERE subs.user_id = submissions.user_id AND " + |
|
32 | "problem_id = " + problem_id.to_s + " " + |
|
32 | "problem_id = " + problem_id.to_s + " " + |
|
33 | "GROUP BY user_id) " + |
|
33 | "GROUP BY user_id) " + |
|
34 | "ORDER BY user_id") |
|
34 | "ORDER BY user_id") |
|
35 | end |
|
35 | end |
|
36 |
|
36 | ||
|
|
37 | + def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id) | ||
|
|
38 | + records = Submission.where(problem_id: problem_id,user_id: user_id) | ||
|
|
39 | + records = records.where('id >= ?',since_id) if since_id > 0 | ||
|
|
40 | + records = records.where('id <= ?',until_id) if until_id > 0 | ||
|
|
41 | + records.all | ||
|
|
42 | + end | ||
|
|
43 | + | ||
|
37 | def self.find_last_for_all_available_problems(user_id) |
|
44 | def self.find_last_for_all_available_problems(user_id) |
|
38 | submissions = Array.new |
|
45 | submissions = Array.new |
|
39 | problems = Problem.find_available_problems |
|
46 | problems = Problem.find_available_problems |
|
40 | problems.each do |problem| |
|
47 | problems.each do |problem| |
|
41 | sub = Submission.find_last_by_user_and_problem(user_id, problem.id) |
|
48 | sub = Submission.find_last_by_user_and_problem(user_id, problem.id) |
|
42 | submissions << sub if sub!=nil |
|
49 | submissions << sub if sub!=nil |
|
43 | end |
|
50 | end |
|
44 | submissions |
|
51 | submissions |
|
45 | end |
|
52 | end |
|
46 |
|
53 | ||
|
47 | def self.find_by_user_problem_number(user_id, problem_id, number) |
|
54 | def self.find_by_user_problem_number(user_id, problem_id, number) |
|
48 | Submission.find(:first, |
|
55 | Submission.find(:first, |
|
49 | :conditions => { |
|
56 | :conditions => { |
|
50 | :user_id => user_id, |
|
57 | :user_id => user_id, |
|
51 | :problem_id => problem_id, |
|
58 | :problem_id => problem_id, |
|
52 | :number => number |
|
59 | :number => number |
|
53 | }) |
|
60 | }) |
|
54 | end |
|
61 | end |
|
55 |
|
62 | ||
|
56 | def self.find_all_by_user_problem(user_id, problem_id) |
|
63 | def self.find_all_by_user_problem(user_id, problem_id) |
|
57 | Submission.find(:all, |
|
64 | Submission.find(:all, |
|
58 | :conditions => { |
|
65 | :conditions => { |
|
59 | :user_id => user_id, |
|
66 | :user_id => user_id, |
|
60 | :problem_id => problem_id, |
|
67 | :problem_id => problem_id, |
|
61 | }) |
|
68 | }) |
|
62 | end |
|
69 | end |
|
63 |
|
70 | ||
|
64 | def download_filename |
|
71 | def download_filename |
|
65 | if self.problem.output_only |
|
72 | if self.problem.output_only |
|
66 | return self.source_filename |
|
73 | return self.source_filename |
|
67 | else |
|
74 | else |
|
68 | timestamp = self.submitted_at.localtime.strftime("%H%M%S") |
|
75 | timestamp = self.submitted_at.localtime.strftime("%H%M%S") |
|
69 | return "#{self.problem.name}-#{timestamp}.#{self.language.ext}" |
|
76 | return "#{self.problem.name}-#{timestamp}.#{self.language.ext}" |
|
70 | end |
|
77 | end |
|
71 | end |
|
78 | end |
|
72 |
|
79 | ||
|
73 | protected |
|
80 | protected |
|
74 |
|
81 | ||
|
75 | def self.find_option_in_source(option, source) |
|
82 | def self.find_option_in_source(option, source) |
|
76 | if source==nil |
|
83 | if source==nil |
|
77 | return nil |
|
84 | return nil |
|
78 | end |
|
85 | end |
|
79 | i = 0 |
|
86 | i = 0 |
|
80 | source.each_line do |s| |
|
87 | source.each_line do |s| |
|
81 | if s =~ option |
|
88 | if s =~ option |
|
82 | words = s.split |
|
89 | words = s.split |
|
83 | return words[1] |
|
90 | return words[1] |
|
84 | end |
|
91 | end |
|
85 | i = i + 1 |
|
92 | i = i + 1 |
|
86 | if i==10 |
|
93 | if i==10 |
|
87 | return nil |
|
94 | return nil |
|
88 | end |
|
95 | end |
|
89 | end |
|
96 | end |
|
90 | return nil |
|
97 | return nil |
|
91 | end |
|
98 | end |
|
92 |
|
99 | ||
|
93 | def self.find_language_in_source(source, source_filename="") |
|
100 | def self.find_language_in_source(source, source_filename="") |
|
94 | langopt = find_option_in_source(/^LANG:/,source) |
|
101 | langopt = find_option_in_source(/^LANG:/,source) |
|
95 | if langopt |
|
102 | if langopt |
|
96 | return (Language.find_by_name(langopt) || |
|
103 | return (Language.find_by_name(langopt) || |
|
97 | Language.find_by_pretty_name(langopt)) |
|
104 | Language.find_by_pretty_name(langopt)) |
|
98 | else |
|
105 | else |
|
99 | if source_filename |
|
106 | if source_filename |
|
100 | return Language.find_by_extension(source_filename.split('.').last) |
|
107 | return Language.find_by_extension(source_filename.split('.').last) |
|
101 | else |
|
108 | else |
|
102 | return nil |
|
109 | return nil |
|
103 | end |
|
110 | end |
|
104 | end |
|
111 | end |
|
105 | end |
|
112 | end |
|
106 |
|
113 | ||
|
107 | def self.find_problem_in_source(source, source_filename="") |
|
114 | def self.find_problem_in_source(source, source_filename="") |
|
108 | prob_opt = find_option_in_source(/^TASK:/,source) |
|
115 | prob_opt = find_option_in_source(/^TASK:/,source) |
|
109 | if problem = Problem.find_by_name(prob_opt) |
|
116 | if problem = Problem.find_by_name(prob_opt) |
|
110 | return problem |
|
117 | return problem |
|
111 | else |
|
118 | else |
|
112 | if source_filename |
|
119 | if source_filename |
|
113 | return Problem.find_by_name(source_filename.split('.').first) |
|
120 | return Problem.find_by_name(source_filename.split('.').first) |
|
114 | else |
|
121 | else |
|
115 | return nil |
|
122 | return nil |
|
116 | end |
|
123 | end |
|
117 | end |
|
124 | end |
|
118 | end |
|
125 | end |
|
119 |
|
126 | ||
|
120 | def assign_problem |
|
127 | def assign_problem |
|
121 | if self.problem_id!=-1 |
|
128 | if self.problem_id!=-1 |
|
122 | begin |
|
129 | begin |
|
123 | self.problem = Problem.find(self.problem_id) |
|
130 | self.problem = Problem.find(self.problem_id) |
|
124 | rescue ActiveRecord::RecordNotFound |
|
131 | rescue ActiveRecord::RecordNotFound |
|
125 | self.problem = nil |
|
132 | self.problem = nil |
|
126 | end |
|
133 | end |
|
127 | else |
|
134 | else |
|
128 | self.problem = Submission.find_problem_in_source(self.source, |
|
135 | self.problem = Submission.find_problem_in_source(self.source, |
|
129 | self.source_filename) |
|
136 | self.source_filename) |
|
130 | end |
|
137 | end |
|
131 | end |
|
138 | end |
|
132 |
|
139 |
@@ -1,43 +1,48 | |||||
|
1 | <h1>User grading results</h1> |
|
1 | <h1>User grading results</h1> |
|
|
2 | + <h2>Show scores from latest submission</h2> | ||
|
|
3 | + | ||
|
|
4 | + <%= render 'submission_range' %> | ||
|
|
5 | + | ||
|
|
6 | + <p>Latest scores</p> | ||
|
2 |
|
7 | ||
|
3 | <table class="info"> |
|
8 | <table class="info"> |
|
4 | <tr class="info-head"> |
|
9 | <tr class="info-head"> |
|
5 | <th>User</th> |
|
10 | <th>User</th> |
|
6 | <th>Name</th> |
|
11 | <th>Name</th> |
|
7 | <th>Activated?</th> |
|
12 | <th>Activated?</th> |
|
8 | <th>Logged in</th> |
|
13 | <th>Logged in</th> |
|
9 | <th>Contest(s)</th> |
|
14 | <th>Contest(s)</th> |
|
10 | <% @problems.each do |p| %> |
|
15 | <% @problems.each do |p| %> |
|
11 | <th><%= p.name %></th> |
|
16 | <th><%= p.name %></th> |
|
12 | <% end %> |
|
17 | <% end %> |
|
13 | <th>Total</th> |
|
18 | <th>Total</th> |
|
14 | <th>Passed</th> |
|
19 | <th>Passed</th> |
|
15 | </tr> |
|
20 | </tr> |
|
16 | <% counter = 0 %> |
|
21 | <% counter = 0 %> |
|
17 | <% @scorearray.each do |sc| %> |
|
22 | <% @scorearray.each do |sc| %> |
|
18 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
23 | <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>"> |
|
19 | <% total = 0 %> |
|
24 | <% total = 0 %> |
|
20 | <% num_passed = 0 %> |
|
25 | <% num_passed = 0 %> |
|
21 | <% sc.each_index do |i| %> |
|
26 | <% sc.each_index do |i| %> |
|
22 | <% if i==0 %> |
|
27 | <% if i==0 %> |
|
23 | <td><%= sc[i].login %></td> |
|
28 | <td><%= sc[i].login %></td> |
|
24 | <td><%= sc[i].full_name %></td> |
|
29 | <td><%= sc[i].full_name %></td> |
|
25 | <td><%= sc[i].activated %></td> |
|
30 | <td><%= sc[i].activated %></td> |
|
26 | <td> |
|
31 | <td> |
|
27 | <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> |
|
32 | <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> |
|
28 | </td> |
|
33 | </td> |
|
29 | <td> |
|
34 | <td> |
|
30 | <%= sc[i].contests.collect {|c| c.name}.join(', ') %> |
|
35 | <%= sc[i].contests.collect {|c| c.name}.join(', ') %> |
|
31 | </td> |
|
36 | </td> |
|
32 | <% else %> |
|
37 | <% else %> |
|
33 | <td><%= sc[i][0] %></td> |
|
38 | <td><%= sc[i][0] %></td> |
|
34 | <% total += sc[i][0] %> |
|
39 | <% total += sc[i][0] %> |
|
35 | <% num_passed += 1 if sc[i][1] %> |
|
40 | <% num_passed += 1 if sc[i][1] %> |
|
36 | <% end %> |
|
41 | <% end %> |
|
37 | <% end %> |
|
42 | <% end %> |
|
38 | <td><%= total %></td> |
|
43 | <td><%= total %></td> |
|
39 | <td><%= num_passed %></td> |
|
44 | <td><%= num_passed %></td> |
|
40 | </tr> |
|
45 | </tr> |
|
41 | <% counter += 1 %> |
|
46 | <% counter += 1 %> |
|
42 | <% end %> |
|
47 | <% end %> |
|
43 | </table> |
|
48 | </table> |
You need to be logged in to leave comments.
Login now