Description:
added time out check for code jom submissions
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r242:803c8843ad9b - - 3 files changed: 29 inserted, 15 deleted
@@ -135,118 +135,127 | |||
|
135 | 135 | def load_output |
|
136 | 136 | if !Configuration.show_grading_result or params[:num]==nil |
|
137 | 137 | redirect_to :action => 'list' and return |
|
138 | 138 | end |
|
139 | 139 | @user = User.find(session[:user_id]) |
|
140 | 140 | @submission = Submission.find(params[:id]) |
|
141 | 141 | if @submission.user!=@user |
|
142 | 142 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
143 | 143 | redirect_to :action => 'list' and return |
|
144 | 144 | end |
|
145 | 145 | case_num = params[:num].to_i |
|
146 | 146 | out_filename = output_filename(@user.login, |
|
147 | 147 | @submission.problem.name, |
|
148 | 148 | @submission.id, |
|
149 | 149 | case_num) |
|
150 | 150 | if !FileTest.exists?(out_filename) |
|
151 | 151 | flash[:notice] = 'Output not found.' |
|
152 | 152 | redirect_to :action => 'list' and return |
|
153 | 153 | end |
|
154 | 154 | |
|
155 | 155 | response.headers['Content-Type'] = "application/force-download" |
|
156 | 156 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
157 | 157 | response.headers["X-Sendfile"] = out_filename |
|
158 | 158 | response.headers['Content-length'] = File.size(out_filename) |
|
159 | 159 | render :nothing => true |
|
160 | 160 | end |
|
161 | 161 | |
|
162 | 162 | def error |
|
163 | 163 | @user = User.find(session[:user_id]) |
|
164 | 164 | end |
|
165 | 165 | |
|
166 | 166 | # announcement refreshing and hiding methods |
|
167 | 167 | |
|
168 | 168 | def announcements |
|
169 | 169 | if params.has_key? 'recent' |
|
170 | 170 | prepare_announcements(params[:recent]) |
|
171 | 171 | else |
|
172 | 172 | prepare_announcements |
|
173 | 173 | end |
|
174 | 174 | render(:partial => 'announcement', |
|
175 | 175 | :collection => @announcements, |
|
176 | 176 | :locals => {:announcement_effect => true}) |
|
177 | 177 | end |
|
178 | 178 | |
|
179 | 179 | # |
|
180 | 180 | # actions for Code Jom |
|
181 | 181 | # |
|
182 | 182 | def download_input |
|
183 | + user = User.find(session[:user_id]) | |
|
184 | + | |
|
185 | + if Configuration.time_limit_mode? and user.contest_finished? | |
|
186 | + redirect_to :action => 'list' and return | |
|
187 | + end | |
|
188 | + | |
|
183 | 189 | problem = Problem.find(params[:id]) |
|
184 | - user = User.find(session[:user_id]) | |
|
185 | 190 | if user.can_request_new_test_pair_for? problem |
|
186 | 191 | assignment = user.get_new_test_pair_assignment_for problem |
|
187 | 192 | assignment.save |
|
188 | 193 | |
|
189 | 194 | send_data(assignment.test_pair.input, |
|
190 | 195 | { :filename => "#{problem.name}-#{assignment.request_number}.in", |
|
191 | 196 | :type => 'text/plain' }) |
|
192 | 197 | else |
|
193 | 198 | recent_assignment = user.get_recent_test_pair_assignment_for problem |
|
194 | 199 | send_data(recent_assignment.test_pair.input, |
|
195 | 200 | { :filename => "#{problem.name}-#{recent_assignment.request_number}.in", |
|
196 | 201 | :type => 'text/plain' }) |
|
197 | 202 | end |
|
198 | 203 | end |
|
199 | 204 | |
|
200 | 205 | def submit_solution |
|
201 | 206 | problem = Problem.find(params[:id]) |
|
202 | 207 | user = User.find(session[:user_id]) |
|
203 | 208 | recent_assignment = user.get_recent_test_pair_assignment_for problem |
|
204 | 209 | |
|
210 | + if Configuration.time_limit_mode? and user.contest_finished? | |
|
211 | + redirect_to :action => 'list' and return | |
|
212 | + end | |
|
213 | + | |
|
205 | 214 | if recent_assignment == nil |
|
206 | 215 | flash[:notice] = 'You have not requested for any input data for this problem. Please download an input first.' |
|
207 | 216 | session[:current_problem_id] = problem.id |
|
208 | 217 | redirect_to :action => 'list' and return |
|
209 | 218 | end |
|
210 | 219 | |
|
211 | 220 | if recent_assignment.expired? |
|
212 | 221 | flash[:notice] = 'The current input is expired. Please download a new input data.' |
|
213 | 222 | session[:current_problem_id] = problem.id |
|
214 | 223 | redirect_to :action => 'list' and return |
|
215 | 224 | end |
|
216 | 225 | |
|
217 | 226 | if recent_assignment.submitted |
|
218 | 227 | flash[:notice] = 'You have already submitted an incorrect solution for this input. Please download a new input data.' |
|
219 | 228 | session[:current_problem_id] = problem.id |
|
220 | 229 | redirect_to :action => 'list' and return |
|
221 | 230 | end |
|
222 | 231 | |
|
223 | 232 | if params[:file] == nil |
|
224 | 233 | flash[:notice] = 'You have not submitted any output.' |
|
225 | 234 | session[:current_problem_id] = problem.id |
|
226 | 235 | redirect_to :action => 'list' and return |
|
227 | 236 | end |
|
228 | 237 | |
|
229 | 238 | submitted_solution = params[:file].read |
|
230 | 239 | test_pair = recent_assignment.test_pair |
|
231 | 240 | passed = test_pair.grade(submitted_solution) |
|
232 | 241 | points = passed ? 100 : 0 |
|
233 | 242 | submission = Submission.new(:user => user, |
|
234 | 243 | :problem => problem, |
|
235 | 244 | :source => submitted_solution, |
|
236 | 245 | :source_filename => params['file'].original_filename, |
|
237 | 246 | :language_id => 0, |
|
238 | 247 | :submitted_at => Time.new.gmtime, |
|
239 | 248 | :graded_at => Time.new.gmtime, |
|
240 | 249 | :points => points) |
|
241 | 250 | submission.save |
|
242 | 251 | recent_assignment.submitted = true |
|
243 | 252 | recent_assignment.save |
|
244 | 253 | |
|
245 | 254 | status = user.get_submission_status_for(problem) |
|
246 | 255 | if status == nil |
|
247 | 256 | status = SubmissionStatus.new :user => user, :problem => problem, :submission_count => 0 |
|
248 | 257 | end |
|
249 | 258 | |
|
250 | 259 | status.submission_count += 1 |
|
251 | 260 | status.passed = passed |
|
252 | 261 | status.save |
@@ -1,21 +1,26 | |||
|
1 | 1 | .problem-panel{:id => "problem-panel-#{problem.id}", :style => "#{(problem.id != @current_problem_id) ? "display:none" : ""}"} |
|
2 | - .problem-form{:id => "problem-form-#{problem.id}"} | |
|
3 | - - form_tag({ :action => 'download_input', :id => problem.id }, :method => :post) do | |
|
4 | - %b Input: | |
|
5 | - %input{:type => "submit", :value => "Download input", :onclick => "CodejomTimeout.updateTimeoutAfterDownloadClick(#{problem.id}); return true;"} | |
|
6 | - %span{:id => "problem-timing-message-#{problem.id}"} | |
|
7 | - = "After downloading, you have #{TEST_ASSIGNMENT_EXPIRATION_DURATION/60} minutes to submit." | |
|
8 | - %div{:id => "problem-submission-form-#{problem.id}"} | |
|
9 | - - form_tag({ :action => 'submit_solution', :id => problem.id }, :method => :post, :multipart => true) do | |
|
10 | - %b Submit output: | |
|
11 | - %input{:type => "file", :name => "file"} | |
|
12 |
- %input{:type => " |
|
|
2 | + - if (not Configuration.time_limit_mode?) or (not @user.contest_finished?) | |
|
3 | + .problem-form{:id => "problem-form-#{problem.id}"} | |
|
4 | + - form_tag({ :action => 'download_input', :id => problem.id }, :method => :post) do | |
|
5 | + %b Input: | |
|
6 | + %input{:type => "submit", :value => "Download input", :onclick => "CodejomTimeout.updateTimeoutAfterDownloadClick(#{problem.id}); return true;"} | |
|
7 | + %span{:id => "problem-timing-message-#{problem.id}"} | |
|
8 | + = "After downloading, you have #{TEST_ASSIGNMENT_EXPIRATION_DURATION/60} minutes to submit." | |
|
9 | + %div{:id => "problem-submission-form-#{problem.id}"} | |
|
10 | + - form_tag({ :action => 'submit_solution', :id => problem.id }, :method => :post, :multipart => true) do | |
|
11 | + %b Submit output: | |
|
12 | + %input{:type => "file", :name => "file"} | |
|
13 | + %input{:type => "submit", :value => "Submit solution"} | |
|
14 | + - else | |
|
15 | + .problem-form | |
|
16 | + %p | |
|
17 | + The contest is over, you can view the tasks, but you can no longer submit. | |
|
13 | 18 | |
|
14 | 19 | .problem-description |
|
15 | 20 | - if problem.description!=nil |
|
16 | 21 | - if problem.description.markdowned |
|
17 | 22 | ~ markdown(problem.description.body) |
|
18 | 23 | - else |
|
19 | 24 | = problem.description.body |
|
20 | 25 | - else |
|
21 | 26 | (not available) |
@@ -1,60 +1,60 | |||
|
1 | 1 | # This file is auto-generated from the current state of the database. Instead of editing this file, |
|
2 | 2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
|
3 | 3 | # then regenerate this schema definition. |
|
4 | 4 | # |
|
5 | 5 | # Note that this schema.rb definition is the authoritative source for your database schema. If you need |
|
6 | 6 | # to create the application database on another system, you should be using db:schema:load, not running |
|
7 | 7 | # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
8 | 8 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
9 | 9 | # |
|
10 | 10 | # It's strongly recommended to check this file into your version control system. |
|
11 | 11 | |
|
12 |
- ActiveRecord::Schema.define(:version => 2010012 |
|
|
12 | + ActiveRecord::Schema.define(:version => 20100129041917) do | |
|
13 | 13 | |
|
14 | 14 | create_table "announcements", :force => true do |t| |
|
15 | 15 | t.string "author" |
|
16 | 16 | t.text "body" |
|
17 | 17 | t.boolean "published" |
|
18 | 18 | t.datetime "created_at" |
|
19 | 19 | t.datetime "updated_at" |
|
20 | 20 | t.boolean "frontpage", :default => false |
|
21 | 21 | t.boolean "contest_only", :default => false |
|
22 | 22 | t.string "title" |
|
23 | 23 | end |
|
24 | 24 | |
|
25 | 25 | create_table "codejom_statuses", :force => true do |t| |
|
26 | 26 | t.integer "user_id" |
|
27 | 27 | t.boolean "alive" |
|
28 | 28 | t.integer "num_problems_passed" |
|
29 | 29 | t.datetime "created_at" |
|
30 | 30 | t.datetime "updated_at" |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | create_table "configurations", :force => true do |t| |
|
34 | 34 | t.string "key" |
|
35 | 35 | t.string "value_type" |
|
36 | 36 | t.string "value" |
|
37 | 37 | t.datetime "created_at" |
|
38 | 38 | t.datetime "updated_at" |
|
39 | 39 | t.text "description" |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | 42 | create_table "countries", :force => true do |t| |
|
43 | 43 | t.string "name" |
|
44 | 44 | t.datetime "created_at" |
|
45 | 45 | t.datetime "updated_at" |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | create_table "descriptions", :force => true do |t| |
|
49 | 49 | t.text "body" |
|
50 | 50 | t.boolean "markdowned" |
|
51 | 51 | t.datetime "created_at" |
|
52 | 52 | t.datetime "updated_at" |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | create_table "grader_processes", :force => true do |t| |
|
56 | 56 | t.string "host", :limit => 20 |
|
57 | 57 | t.integer "pid" |
|
58 | 58 | t.string "mode" |
|
59 | 59 | t.boolean "active" |
|
60 | 60 | t.datetime "created_at" |
@@ -141,98 +141,98 | |||
|
141 | 141 | create_table "submission_statuses", :force => true do |t| |
|
142 | 142 | t.integer "user_id" |
|
143 | 143 | t.integer "problem_id" |
|
144 | 144 | t.boolean "passed" |
|
145 | 145 | t.integer "submission_count" |
|
146 | 146 | t.datetime "created_at" |
|
147 | 147 | t.datetime "updated_at" |
|
148 | 148 | end |
|
149 | 149 | |
|
150 | 150 | create_table "submissions", :force => true do |t| |
|
151 | 151 | t.integer "user_id" |
|
152 | 152 | t.integer "problem_id" |
|
153 | 153 | t.integer "language_id" |
|
154 | 154 | t.text "source" |
|
155 | 155 | t.binary "binary" |
|
156 | 156 | t.datetime "submitted_at" |
|
157 | 157 | t.datetime "compiled_at" |
|
158 | 158 | t.text "compiler_message" |
|
159 | 159 | t.datetime "graded_at" |
|
160 | 160 | t.integer "points" |
|
161 | 161 | t.text "grader_comment" |
|
162 | 162 | t.integer "number" |
|
163 | 163 | t.string "source_filename" |
|
164 | 164 | end |
|
165 | 165 | |
|
166 | 166 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
167 | 167 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
168 | 168 | |
|
169 | 169 | create_table "tasks", :force => true do |t| |
|
170 | 170 | t.integer "submission_id" |
|
171 | 171 | t.datetime "created_at" |
|
172 | 172 | t.integer "status" |
|
173 | 173 | t.datetime "updated_at" |
|
174 | 174 | end |
|
175 | 175 | |
|
176 | 176 | create_table "test_pair_assignments", :force => true do |t| |
|
177 | 177 | t.integer "user_id" |
|
178 | 178 | t.integer "problem_id" |
|
179 | 179 | t.integer "test_pair_id" |
|
180 | 180 | t.integer "test_pair_number" |
|
181 | 181 | t.integer "request_number" |
|
182 | 182 | t.datetime "created_at" |
|
183 | 183 | t.datetime "updated_at" |
|
184 | 184 | t.boolean "submitted" |
|
185 | 185 | end |
|
186 | 186 | |
|
187 | 187 | create_table "test_pairs", :force => true do |t| |
|
188 | 188 | t.integer "problem_id" |
|
189 | - t.text "input" | |
|
190 | - t.text "solution" | |
|
189 | + t.text "input", :limit => 16777215 | |
|
190 | + t.text "solution", :limit => 16777215 | |
|
191 | 191 | t.datetime "created_at" |
|
192 | 192 | t.datetime "updated_at" |
|
193 | 193 | t.integer "number" |
|
194 | 194 | end |
|
195 | 195 | |
|
196 | 196 | create_table "test_requests", :force => true do |t| |
|
197 | 197 | t.integer "user_id" |
|
198 | 198 | t.integer "problem_id" |
|
199 | 199 | t.integer "submission_id" |
|
200 | 200 | t.string "input_file_name" |
|
201 | 201 | t.string "output_file_name" |
|
202 | 202 | t.string "running_stat" |
|
203 | 203 | t.integer "status" |
|
204 | 204 | t.datetime "updated_at" |
|
205 | 205 | t.datetime "submitted_at" |
|
206 | 206 | t.datetime "compiled_at" |
|
207 | 207 | t.text "compiler_message" |
|
208 | 208 | t.datetime "graded_at" |
|
209 | 209 | t.string "grader_comment" |
|
210 | 210 | t.datetime "created_at" |
|
211 | 211 | t.float "running_time" |
|
212 | 212 | t.string "exit_status" |
|
213 | 213 | t.integer "memory_usage" |
|
214 | 214 | end |
|
215 | 215 | |
|
216 | 216 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
217 | 217 | |
|
218 | 218 | create_table "user_contest_stats", :force => true do |t| |
|
219 | 219 | t.integer "user_id" |
|
220 | 220 | t.datetime "started_at" |
|
221 | 221 | t.datetime "created_at" |
|
222 | 222 | t.datetime "updated_at" |
|
223 | 223 | end |
|
224 | 224 | |
|
225 | 225 | create_table "users", :force => true do |t| |
|
226 | 226 | t.string "login", :limit => 50 |
|
227 | 227 | t.string "full_name" |
|
228 | 228 | t.string "hashed_password" |
|
229 | 229 | t.string "salt", :limit => 5 |
|
230 | 230 | t.string "alias" |
|
231 | 231 | t.string "email" |
|
232 | 232 | t.integer "site_id" |
|
233 | 233 | t.integer "country_id" |
|
234 | 234 | t.boolean "activated", :default => false |
|
235 | 235 | t.datetime "created_at" |
|
236 | 236 | t.datetime "updated_at" |
|
237 | 237 | t.string "member1_full_name" |
|
238 | 238 | t.string "member2_full_name" |
You need to be logged in to leave comments.
Login now