Description:
* multiple ip login fix * fix when points is nil in stat page and user page
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r531:b75c92a947ff - - 6 files changed: 30 inserted, 30 deleted

@@ -7,23 +7,23
7 def index
7 def index
8 @configurations = GraderConfiguration.find(:all,
8 @configurations = GraderConfiguration.find(:all,
9 :order => '`key`')
9 :order => '`key`')
10 end
10 end
11
11
12 def reload
12 def reload
13 GraderConfiguration.reload
13 GraderConfiguration.reload
14 redirect_to :action => 'index'
14 redirect_to :action => 'index'
15 end
15 end
16
16
17 def update
17 def update
18 @config = GraderConfiguration.find(params[:id])
18 @config = GraderConfiguration.find(params[:id])
19 - User.clear_last_login if @config.key = 'multiple_ip_login' and @config.value == 'true' and params[:grader_configuration][:value] == 'false'
19 + User.clear_last_login if @config.key == GraderConfiguration::MULTIPLE_IP_LOGIN_KEY and @config.value == 'true' and params[:grader_configuration][:value] == 'false'
20 respond_to do |format|
20 respond_to do |format|
21 if @config.update_attributes(params[:grader_configuration])
21 if @config.update_attributes(params[:grader_configuration])
22 format.json { head :ok }
22 format.json { head :ok }
23 else
23 else
24 format.json { respond_with_bip(@config) }
24 format.json { respond_with_bip(@config) }
25 end
25 end
26 end
26 end
27 end
27 end
28
28
29 end
29 end
@@ -154,25 +154,25
154 redirect_to :controller => 'main', :action => 'list'
154 redirect_to :controller => 'main', :action => 'list'
155 return
155 return
156 end
156 end
157 @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id)
157 @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id)
158
158
159 #stat summary
159 #stat summary
160 range =65
160 range =65
161 @histogram = { data: Array.new(range,0), summary: {} }
161 @histogram = { data: Array.new(range,0), summary: {} }
162 user = Hash.new(0)
162 user = Hash.new(0)
163 @submissions.find_each do |sub|
163 @submissions.find_each do |sub|
164 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
164 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
165 @histogram[:data][d.to_i] += 1 if d < range
165 @histogram[:data][d.to_i] += 1 if d < range
166 - user[sub.user_id] = [user[sub.user_id], (sub.try(:points) >= @problem.full_score) ? 1 : 0].max
166 + user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
167 end
167 end
168 @histogram[:summary][:max] = [@histogram[:data].max,1].max
168 @histogram[:summary][:max] = [@histogram[:data].max,1].max
169
169
170 @summary = { attempt: user.count, solve: 0 }
170 @summary = { attempt: user.count, solve: 0 }
171 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
171 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
172 end
172 end
173
173
174 def manage
174 def manage
175 @problems = Problem.find(:all, :order => 'date_added DESC')
175 @problems = Problem.find(:all, :order => 'date_added DESC')
176 end
176 end
177
177
178 def do_manage
178 def do_manage
@@ -116,25 +116,25
116 range = 120
116 range = 120
117 @histogram = { data: Array.new(range,0), summary: {} }
117 @histogram = { data: Array.new(range,0), summary: {} }
118 @summary = {count: 0, solve: 0, attempt: 0}
118 @summary = {count: 0, solve: 0, attempt: 0}
119 problem = Hash.new(0)
119 problem = Hash.new(0)
120
120
121 @submission.find_each do |sub|
121 @submission.find_each do |sub|
122 #histogram
122 #histogram
123 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
123 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
124 @histogram[:data][d.to_i] += 1 if d < range
124 @histogram[:data][d.to_i] += 1 if d < range
125
125
126 @summary[:count] += 1
126 @summary[:count] += 1
127 next unless sub.problem
127 next unless sub.problem
128 - problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max
128 + problem[sub.problem] = [problem[sub.problem], ( (sub.try(:points) || 0) >= sub.problem.full_score) ? 1 : 0].max
129 end
129 end
130
130
131 @histogram[:summary][:max] = [@histogram[:data].max,1].max
131 @histogram[:summary][:max] = [@histogram[:data].max,1].max
132 @summary[:attempt] = problem.count
132 @summary[:attempt] = problem.count
133 problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
133 problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
134 end
134 end
135
135
136 protected
136 protected
137
137
138 def verify_online_registration
138 def verify_online_registration
139 if !GraderConfiguration['system.online_registration']
139 if !GraderConfiguration['system.online_registration']
140 redirect_to :controller => 'main', :action => 'login'
140 redirect_to :controller => 'main', :action => 'login'
@@ -1,23 +1,24
1 require 'yaml'
1 require 'yaml'
2
2
3 #
3 #
4 # This class also contains various login of the system.
4 # This class also contains various login of the system.
5 #
5 #
6 class GraderConfiguration < ActiveRecord::Base
6 class GraderConfiguration < ActiveRecord::Base
7
7
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
8 SYSTEM_MODE_CONF_KEY = 'system.mode'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
9 TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
10 MULTICONTESTS_KEY = 'system.multicontests'
10 MULTICONTESTS_KEY = 'system.multicontests'
11 CONTEST_TIME_LIMIT_KEY = 'contest.time_limit'
11 CONTEST_TIME_LIMIT_KEY = 'contest.time_limit'
12 + MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login'
12
13
13 cattr_accessor :config_cache
14 cattr_accessor :config_cache
14 cattr_accessor :task_grading_info_cache
15 cattr_accessor :task_grading_info_cache
15 cattr_accessor :contest_time_str
16 cattr_accessor :contest_time_str
16 cattr_accessor :contest_time
17 cattr_accessor :contest_time
17
18
18 GraderConfiguration.config_cache = nil
19 GraderConfiguration.config_cache = nil
19 GraderConfiguration.task_grading_info_cache = nil
20 GraderConfiguration.task_grading_info_cache = nil
20
21
21 def self.config_cached?
22 def self.config_cached?
22 (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED)
23 (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED)
23 end
24 end
@@ -49,18 +49,18
49 - if session[:admin]
49 - if session[:admin]
50 %th IP
50 %th IP
51 %tbody
51 %tbody
52 - @submission.each do |s|
52 - @submission.each do |s|
53 - next unless s.problem
53 - next unless s.problem
54 %tr
54 %tr
55 %td= link_to "#{s.id}", controller: "graders", action: "submission", id: s.id
55 %td= link_to "#{s.id}", controller: "graders", action: "submission", id: s.id
56 %td= link_to s.problem.name, controller: "problems", action: "stat", id: s.problem
56 %td= link_to s.problem.name, controller: "problems", action: "stat", id: s.problem
57 %td= s.problem.full_name
57 %td= s.problem.full_name
58 %td= s.language.pretty_name
58 %td= s.language.pretty_name
59 %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago)
59 %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago)
60 %td.fix-width= s.grader_comment
60 %td.fix-width= s.grader_comment
61 - %td= (s.points*100)/s.problem.full_score
61 + %td= ( s.try(:points) ? (s.points*100/s.problem.full_score) : '' )
62 - if session[:admin]
62 - if session[:admin]
63 %td= s.ip_address
63 %td= s.ip_address
64
64
65
65
66
66
@@ -6,30 +6,30
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 # It's strongly recommended to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
13
13
14 ActiveRecord::Schema.define(:version => 20150827133841) do
14 ActiveRecord::Schema.define(:version => 20150827133841) do
15
15
16 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
17 t.string "author"
17 t.string "author"
18 - t.text "body", :limit => 16777215
18 + t.text "body"
19 t.boolean "published"
19 t.boolean "published"
20 - t.datetime "created_at", :null => false
20 + t.datetime "created_at", :null => false
21 - t.datetime "updated_at", :null => false
21 + t.datetime "updated_at", :null => false
22 - t.boolean "frontpage", :default => false
22 + t.boolean "frontpage", :default => false
23 - t.boolean "contest_only", :default => false
23 + t.boolean "contest_only", :default => false
24 t.string "title"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 create_table "contests", :force => true do |t|
28 create_table "contests", :force => true do |t|
29 t.string "title"
29 t.string "title"
30 t.boolean "enabled"
30 t.boolean "enabled"
31 t.datetime "created_at", :null => false
31 t.datetime "created_at", :null => false
32 t.datetime "updated_at", :null => false
32 t.datetime "updated_at", :null => false
33 t.string "name"
33 t.string "name"
34 end
34 end
35
35
@@ -41,37 +41,37
41 create_table "contests_users", :id => false, :force => true do |t|
41 create_table "contests_users", :id => false, :force => true do |t|
42 t.integer "contest_id"
42 t.integer "contest_id"
43 t.integer "user_id"
43 t.integer "user_id"
44 end
44 end
45
45
46 create_table "countries", :force => true do |t|
46 create_table "countries", :force => true do |t|
47 t.string "name"
47 t.string "name"
48 t.datetime "created_at", :null => false
48 t.datetime "created_at", :null => false
49 t.datetime "updated_at", :null => false
49 t.datetime "updated_at", :null => false
50 end
50 end
51
51
52 create_table "descriptions", :force => true do |t|
52 create_table "descriptions", :force => true do |t|
53 - t.text "body", :limit => 16777215
53 + t.text "body"
54 t.boolean "markdowned"
54 t.boolean "markdowned"
55 - t.datetime "created_at", :null => false
55 + t.datetime "created_at", :null => false
56 - t.datetime "updated_at", :null => false
56 + t.datetime "updated_at", :null => false
57 end
57 end
58
58
59 create_table "grader_configurations", :force => true do |t|
59 create_table "grader_configurations", :force => true do |t|
60 t.string "key"
60 t.string "key"
61 t.string "value_type"
61 t.string "value_type"
62 t.string "value"
62 t.string "value"
63 - t.datetime "created_at", :null => false
63 + t.datetime "created_at", :null => false
64 - t.datetime "updated_at", :null => false
64 + t.datetime "updated_at", :null => false
65 - t.text "description", :limit => 16777215
65 + t.text "description"
66 end
66 end
67
67
68 create_table "grader_processes", :force => true do |t|
68 create_table "grader_processes", :force => true do |t|
69 t.string "host", :limit => 20
69 t.string "host", :limit => 20
70 t.integer "pid"
70 t.integer "pid"
71 t.string "mode"
71 t.string "mode"
72 t.boolean "active"
72 t.boolean "active"
73 t.datetime "created_at", :null => false
73 t.datetime "created_at", :null => false
74 t.datetime "updated_at", :null => false
74 t.datetime "updated_at", :null => false
75 t.integer "task_id"
75 t.integer "task_id"
76 t.string "task_type"
76 t.string "task_type"
77 t.boolean "terminated"
77 t.boolean "terminated"
@@ -88,28 +88,28
88
88
89 create_table "logins", :force => true do |t|
89 create_table "logins", :force => true do |t|
90 t.integer "user_id"
90 t.integer "user_id"
91 t.string "ip_address"
91 t.string "ip_address"
92 t.datetime "created_at", :null => false
92 t.datetime "created_at", :null => false
93 t.datetime "updated_at", :null => false
93 t.datetime "updated_at", :null => false
94 end
94 end
95
95
96 create_table "messages", :force => true do |t|
96 create_table "messages", :force => true do |t|
97 t.integer "sender_id"
97 t.integer "sender_id"
98 t.integer "receiver_id"
98 t.integer "receiver_id"
99 t.integer "replying_message_id"
99 t.integer "replying_message_id"
100 - t.text "body", :limit => 16777215
100 + t.text "body"
101 t.boolean "replied"
101 t.boolean "replied"
102 - t.datetime "created_at", :null => false
102 + t.datetime "created_at", :null => false
103 - t.datetime "updated_at", :null => false
103 + t.datetime "updated_at", :null => false
104 end
104 end
105
105
106 create_table "problems", :force => true do |t|
106 create_table "problems", :force => true do |t|
107 t.string "name", :limit => 30
107 t.string "name", :limit => 30
108 t.string "full_name"
108 t.string "full_name"
109 t.integer "full_score"
109 t.integer "full_score"
110 t.date "date_added"
110 t.date "date_added"
111 t.boolean "available"
111 t.boolean "available"
112 t.string "url"
112 t.string "url"
113 t.integer "description_id"
113 t.integer "description_id"
114 t.boolean "test_allowed"
114 t.boolean "test_allowed"
115 t.boolean "output_only"
115 t.boolean "output_only"
@@ -133,25 +133,25
133 t.string "name"
133 t.string "name"
134 end
134 end
135
135
136 create_table "roles_users", :id => false, :force => true do |t|
136 create_table "roles_users", :id => false, :force => true do |t|
137 t.integer "role_id"
137 t.integer "role_id"
138 t.integer "user_id"
138 t.integer "user_id"
139 end
139 end
140
140
141 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
141 add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
142
142
143 create_table "sessions", :force => true do |t|
143 create_table "sessions", :force => true do |t|
144 t.string "session_id"
144 t.string "session_id"
145 - t.text "data", :limit => 16777215
145 + t.text "data"
146 t.datetime "updated_at"
146 t.datetime "updated_at"
147 end
147 end
148
148
149 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
149 add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
150 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
150 add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
151
151
152 create_table "sites", :force => true do |t|
152 create_table "sites", :force => true do |t|
153 t.string "name"
153 t.string "name"
154 t.boolean "started"
154 t.boolean "started"
155 t.datetime "start_time"
155 t.datetime "start_time"
156 t.datetime "created_at", :null => false
156 t.datetime "created_at", :null => false
157 t.datetime "updated_at", :null => false
157 t.datetime "updated_at", :null => false
@@ -161,73 +161,73
161
161
162 create_table "submission_view_logs", :force => true do |t|
162 create_table "submission_view_logs", :force => true do |t|
163 t.integer "user_id"
163 t.integer "user_id"
164 t.integer "submission_id"
164 t.integer "submission_id"
165 t.datetime "created_at", :null => false
165 t.datetime "created_at", :null => false
166 t.datetime "updated_at", :null => false
166 t.datetime "updated_at", :null => false
167 end
167 end
168
168
169 create_table "submissions", :force => true do |t|
169 create_table "submissions", :force => true do |t|
170 t.integer "user_id"
170 t.integer "user_id"
171 t.integer "problem_id"
171 t.integer "problem_id"
172 t.integer "language_id"
172 t.integer "language_id"
173 - t.text "source", :limit => 16777215
173 + t.text "source"
174 t.binary "binary"
174 t.binary "binary"
175 t.datetime "submitted_at"
175 t.datetime "submitted_at"
176 t.datetime "compiled_at"
176 t.datetime "compiled_at"
177 - t.text "compiler_message", :limit => 16777215
177 + t.text "compiler_message"
178 t.datetime "graded_at"
178 t.datetime "graded_at"
179 t.integer "points"
179 t.integer "points"
180 - t.text "grader_comment", :limit => 16777215
180 + t.text "grader_comment"
181 t.integer "number"
181 t.integer "number"
182 t.string "source_filename"
182 t.string "source_filename"
183 t.float "max_runtime"
183 t.float "max_runtime"
184 t.integer "peak_memory"
184 t.integer "peak_memory"
185 t.integer "effective_code_length"
185 t.integer "effective_code_length"
186 t.string "ip_address"
186 t.string "ip_address"
187 end
187 end
188
188
189 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
189 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
190 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
190 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
191
191
192 create_table "tasks", :force => true do |t|
192 create_table "tasks", :force => true do |t|
193 t.integer "submission_id"
193 t.integer "submission_id"
194 t.datetime "created_at"
194 t.datetime "created_at"
195 t.integer "status"
195 t.integer "status"
196 t.datetime "updated_at"
196 t.datetime "updated_at"
197 end
197 end
198
198
199 create_table "test_pairs", :force => true do |t|
199 create_table "test_pairs", :force => true do |t|
200 t.integer "problem_id"
200 t.integer "problem_id"
201 - t.text "input", :limit => 2147483647
201 + t.text "input", :limit => 16777215
202 - t.text "solution", :limit => 2147483647
202 + t.text "solution", :limit => 16777215
203 - t.datetime "created_at", :null => false
203 + t.datetime "created_at", :null => false
204 - t.datetime "updated_at", :null => false
204 + t.datetime "updated_at", :null => false
205 end
205 end
206
206
207 create_table "test_requests", :force => true do |t|
207 create_table "test_requests", :force => true do |t|
208 t.integer "user_id"
208 t.integer "user_id"
209 t.integer "problem_id"
209 t.integer "problem_id"
210 t.integer "submission_id"
210 t.integer "submission_id"
211 t.string "input_file_name"
211 t.string "input_file_name"
212 t.string "output_file_name"
212 t.string "output_file_name"
213 t.string "running_stat"
213 t.string "running_stat"
214 t.integer "status"
214 t.integer "status"
215 - t.datetime "updated_at", :null => false
215 + t.datetime "updated_at", :null => false
216 t.datetime "submitted_at"
216 t.datetime "submitted_at"
217 t.datetime "compiled_at"
217 t.datetime "compiled_at"
218 - t.text "compiler_message", :limit => 16777215
218 + t.text "compiler_message"
219 t.datetime "graded_at"
219 t.datetime "graded_at"
220 t.string "grader_comment"
220 t.string "grader_comment"
221 - t.datetime "created_at", :null => false
221 + t.datetime "created_at", :null => false
222 t.float "running_time"
222 t.float "running_time"
223 t.string "exit_status"
223 t.string "exit_status"
224 t.integer "memory_usage"
224 t.integer "memory_usage"
225 end
225 end
226
226
227 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
227 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
228
228
229 create_table "user_contest_stats", :force => true do |t|
229 create_table "user_contest_stats", :force => true do |t|
230 t.integer "user_id"
230 t.integer "user_id"
231 t.datetime "started_at"
231 t.datetime "started_at"
232 t.datetime "created_at", :null => false
232 t.datetime "created_at", :null => false
233 t.datetime "updated_at", :null => false
233 t.datetime "updated_at", :null => false
@@ -237,21 +237,20
237 create_table "users", :force => true do |t|
237 create_table "users", :force => true do |t|
238 t.string "login", :limit => 50
238 t.string "login", :limit => 50
239 t.string "full_name"
239 t.string "full_name"
240 t.string "hashed_password"
240 t.string "hashed_password"
241 t.string "salt", :limit => 5
241 t.string "salt", :limit => 5
242 t.string "alias"
242 t.string "alias"
243 t.string "email"
243 t.string "email"
244 t.integer "site_id"
244 t.integer "site_id"
245 t.integer "country_id"
245 t.integer "country_id"
246 t.boolean "activated", :default => false
246 t.boolean "activated", :default => false
247 t.datetime "created_at"
247 t.datetime "created_at"
248 t.datetime "updated_at"
248 t.datetime "updated_at"
249 - t.string "section"
250 t.boolean "enabled", :default => true
249 t.boolean "enabled", :default => true
251 t.string "remark"
250 t.string "remark"
252 t.string "last_ip"
251 t.string "last_ip"
253 end
252 end
254
253
255 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
254 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
256
255
257 end
256 end
You need to be logged in to leave comments. Login now