Description:
saves and grades submission in standard mode
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r388:b5766b7ed3ec - - 2 files changed: 18 inserted, 6 deleted

@@ -74,13 +74,13
74 74 assignment = user.get_test_pair_assignment_for(@current_problem)
75 75 if !assignment
76 76 flash[:notice] = 'Error: คุณยังไม่ได้ดาวน์โหลดข้อมูลทดสอบ'
77 77 prepare_list_information
78 78 render :action => 'list' and return
79 79 end
80 - if assignment.expired?
80 + if (assignment.expired?) and (!GraderConfiguration.standard_mode?)
81 81 flash[:notice] = 'Error: หมดเวลาส่งสำหรับข้อนี้'
82 82 prepare_list_information
83 83 render :action => 'list' and return
84 84 end
85 85
86 86 @submission.problem = @current_problem
@@ -98,12 +98,20
98 98 if GraderConfiguration.time_limit_mode? and user.contest_finished?
99 99 @submission.errors.add(:base,"The contest is over.")
100 100 prepare_list_information
101 101 render :action => 'list' and return
102 102 end
103 103
104 + if GraderConfiguration.standard_mode?
105 + test_pair = assignment.test_pair
106 + result = test_pair.grade(@submission.output)
107 + @submission.points = result[:score]*100 / result[:full_score]
108 + @submission.grader_comment = result[:msg]
109 + @submission.graded_at = Time.now.gmtime
110 + end
111 +
104 112 if @submission.valid?
105 113 if @submission.save == false
106 114 flash[:notice] = 'Error saving your submission'
107 115 elsif Task.create(:submission_id => @submission.id,
108 116 :status => Task::STATUS_INQUEUE) == false
109 117 flash[:notice] = 'Error adding your submission to task queue'
@@ -311,19 +319,23
311 319 end
312 320
313 321 def prepare_timeout_information(problems)
314 322 @submission_timeouts = {}
315 323 problems.each do |problem|
316 324 assignment = @user.get_test_pair_assignment_for(problem)
317 - if assignment == nil
325 + if GraderConfiguration.standard_mode?
318 326 timeout = nil
319 327 else
320 - if (assignment.expired?) or (assignment.submitted)
321 - timeout = 0
328 + if assignment == nil
329 + timeout = nil
322 330 else
323 - timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
331 + if (assignment.expired?) or (assignment.submitted)
332 + timeout = 0
333 + else
334 + timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
335 + end
324 336 end
325 337 end
326 338 @submission_timeouts[problem.id] = timeout
327 339 end
328 340 end
329 341
@@ -27,12 +27,12
27 27 <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด):
28 28 <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => "return TOIContest.confirmDownload(#{problem.id})" } %>
29 29 <span id="submission_time_left_<%= problem.id %>_id"></span>
30 30 <%= form_tag({:controller => 'main', :action => 'submit'}, {:method => 'post', :multipart => true, :id => "submission_form_#{problem.id}_id" }) do %>
31 31 <%= hidden_field_tag 'submission[problem_id]', problem.id %>
32 32 ข้อมูลส่งออก: <%= file_field_tag 'output_file' %>
33 - โปรแกรมคำตอบ: <%= file_field_tag 'file' %>
33 + โปรแกรมของคุณ: <%= file_field_tag 'file' %>
34 34 <%= submit_tag 'Submit' %>
35 35 <% end %>
36 36 </div>
37 37 </div>
38 38 <% end %>
You need to be logged in to leave comments. Login now