Description:
merge
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r466:b99651140f6d - - 3 files changed: 2 inserted, 2 deleted

@@ -73,96 +73,97
73 73 if @submissions[s.user_id]
74 74 if not @submissions[s.user_id][:sub].has_key?(s.problem_id)
75 75 a = nil
76 76 begin
77 77 a = Problem.find(s.problem_id)
78 78 rescue
79 79 a = nil
80 80 end
81 81 @submissions[s.user_id][:sub][s.problem_id] =
82 82 { prob_name: (a ? a.full_name : '(NULL)'),
83 83 sub_ids: [s.id] }
84 84 else
85 85 @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id
86 86 end
87 87 @submissions[s.user_id][:count] += 1
88 88 end
89 89 end
90 90 end
91 91
92 92 def problem_hof
93 93 # gen problem list
94 94 @user = User.find(session[:user_id])
95 95 @problems = @user.available_problems
96 96
97 97 # get selected problems or the default
98 98 if params[:id]
99 99 begin
100 100 @problem = Problem.available.find(params[:id])
101 101 rescue
102 102 redirect_to action: :problem_hof
103 103 flash[:notice] = 'Error: submissions for that problem are not viewable.'
104 104 return
105 105 end
106 106 end
107 107
108 108 return unless @problem
109 109
110 110 @by_lang = {} #aggregrate by language
111 111
112 112 range =65
113 113 @histogram = { data: Array.new(range,0), summary: {} }
114 114 @summary = {count: 0, solve: 0, attempt: 0}
115 115 user = Hash.new(0)
116 116 Submission.where(problem_id: @problem.id).find_each do |sub|
117 117 #histogram
118 118 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
119 119 @histogram[:data][d.to_i] += 1 if d < range
120 120
121 + next unless sub.points
121 122 @summary[:count] += 1
122 123 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
123 124
124 125 lang = Language.find_by_id(sub.language_id)
125 126 next unless lang
126 127 next unless sub.points >= @problem.full_score
127 128
128 129 #initialize
129 130 unless @by_lang.has_key?(lang.pretty_name)
130 131 @by_lang[lang.pretty_name] = {
131 132 runtime: { avail: false, value: 2**30-1 },
132 133 memory: { avail: false, value: 2**30-1 },
133 134 length: { avail: false, value: 2**30-1 },
134 135 first: { avail: false, value: DateTime.new(3000,1,1) }
135 136 }
136 137 end
137 138
138 139 if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value]
139 140 @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id }
140 141 end
141 142
142 143 if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value]
143 144 @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id }
144 145 end
145 146
146 147 if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and
147 148 !sub.user.admin?
148 149 @by_lang[lang.pretty_name][:first] = { avail: true, user_id: sub.user_id, value: sub.submitted_at, sub_id: sub.id }
149 150 end
150 151
151 152 if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length
152 153 @by_lang[lang.pretty_name][:length] = { avail: true, user_id: sub.user_id, value: sub.effective_code_length, sub_id: sub.id }
153 154 end
154 155 end
155 156
156 157 #process user_id
157 158 @by_lang.each do |lang,prop|
158 159 prop.each do |k,v|
159 160 v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)"
160 161 end
161 162 end
162 163
163 164 #sum into best
164 165 if @by_lang and @by_lang.first
165 166 @best = @by_lang.first[1].clone
166 167 @by_lang.each do |lang,prop|
167 168 if @best[:runtime][:value] >= prop[:runtime][:value]
168 169 @best[:runtime] = prop[:runtime]
@@ -194,54 +194,53
194 194 t.text "input", :limit => 16777215
195 195 t.text "solution", :limit => 16777215
196 196 t.datetime "created_at", :null => false
197 197 t.datetime "updated_at", :null => false
198 198 end
199 199
200 200 create_table "test_requests", :force => true do |t|
201 201 t.integer "user_id"
202 202 t.integer "problem_id"
203 203 t.integer "submission_id"
204 204 t.string "input_file_name"
205 205 t.string "output_file_name"
206 206 t.string "running_stat"
207 207 t.integer "status"
208 208 t.datetime "updated_at", :null => false
209 209 t.datetime "submitted_at"
210 210 t.datetime "compiled_at"
211 211 t.text "compiler_message"
212 212 t.datetime "graded_at"
213 213 t.string "grader_comment"
214 214 t.datetime "created_at", :null => false
215 215 t.float "running_time"
216 216 t.string "exit_status"
217 217 t.integer "memory_usage"
218 218 end
219 219
220 220 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
221 221
222 222 create_table "user_contest_stats", :force => true do |t|
223 223 t.integer "user_id"
224 224 t.datetime "started_at"
225 225 t.datetime "created_at", :null => false
226 226 t.datetime "updated_at", :null => false
227 227 t.boolean "forced_logout"
228 228 end
229 229
230 230 create_table "users", :force => true do |t|
231 231 t.string "login", :limit => 50
232 232 t.string "full_name"
233 233 t.string "hashed_password"
234 234 t.string "salt", :limit => 5
235 235 t.string "alias"
236 236 t.string "email"
237 237 t.integer "site_id"
238 238 t.integer "country_id"
239 239 t.boolean "activated", :default => false
240 240 t.datetime "created_at"
241 241 t.datetime "updated_at"
242 - t.string "section"
243 242 end
244 243
245 244 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
246 245
247 246 end
@@ -55,97 +55,97
55 55
56 56 {
57 57 :key => 'right.user_hall_of_fame',
58 58 :value_type => 'boolean',
59 59 :default_value => 'false',
60 60 :description => 'If true, any user can access hall of fame page.'
61 61 },
62 62
63 63 {
64 64 :key => 'right.user_view_submission',
65 65 :value_type => 'boolean',
66 66 :default_value => 'false',
67 67 :description => 'If true, any user can view submissions of every one.'
68 68 },
69 69
70 70 # If Configuration['system.online_registration'] is true, the
71 71 # system allows online registration, and will use these
72 72 # information for sending confirmation emails.
73 73 {
74 74 :key => 'system.online_registration.smtp',
75 75 :value_type => 'string',
76 76 :default_value => 'smtp.somehost.com'
77 77 },
78 78
79 79 {
80 80 :key => 'system.online_registration.from',
81 81 :value_type => 'string',
82 82 :default_value => 'your.email@address'
83 83 },
84 84
85 85 {
86 86 :key => 'system.admin_email',
87 87 :value_type => 'string',
88 88 :default_value => 'admin@admin.email'
89 89 },
90 90
91 91 {
92 92 :key => 'system.user_setting_enabled',
93 93 :value_type => 'boolean',
94 94 :default_value => 'true',
95 95 :description => 'If this option is true, users can change their settings'
96 96 },
97 97
98 98 {
99 99 :key => 'system.user_setting_enabled',
100 100 :value_type => 'boolean',
101 101 :default_value => 'true',
102 102 :description => 'If this option is true, users can change their settings'
103 - }
103 + },
104 104
105 105 # If Configuration['contest.test_request.early_timeout'] is true
106 106 # the user will not be able to use test request at 30 minutes
107 107 # before the contest ends.
108 108 {
109 109 :key => 'contest.test_request.early_timeout',
110 110 :value_type => 'boolean',
111 111 :default_value => 'false'
112 112 },
113 113
114 114 {
115 115 :key => 'system.multicontests',
116 116 :value_type => 'boolean',
117 117 :default_value => 'false'
118 118 },
119 119
120 120 {
121 121 :key => 'contest.confirm_indv_contest_start',
122 122 :value_type => 'boolean',
123 123 :default_value => 'false'
124 124 },
125 125
126 126 {
127 127 :key => 'contest.default_contest_name',
128 128 :value_type => 'string',
129 129 :default_value => 'none',
130 130 :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest."
131 131 }
132 132
133 133 ]
134 134
135 135
136 136 def create_configuration_key(key,
137 137 value_type,
138 138 default_value,
139 139 description='')
140 140 conf = (GraderConfiguration.find_by_key(key) ||
141 141 GraderConfiguration.new(:key => key,
142 142 :value_type => value_type,
143 143 :value => default_value))
144 144 conf.description = description
145 145 conf.save
146 146 end
147 147
148 148 def seed_config
149 149 CONFIGURATIONS.each do |conf|
150 150 if conf.has_key? :description
151 151 desc = conf[:description]
You need to be logged in to leave comments. Login now