Description:
saves and grades submission in standard mode
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r388:b5766b7ed3ec - - 2 files changed: 18 inserted, 6 deleted
@@ -68,48 +68,56 | |||||
|
68 |
|
68 | ||
|
69 | if !@current_problem |
|
69 | if !@current_problem |
|
70 | flash[:notice] = 'Error: คุณยังไม่ได้ระบุข้อที่ต้องการส่ง' |
|
70 | flash[:notice] = 'Error: คุณยังไม่ได้ระบุข้อที่ต้องการส่ง' |
|
71 | redirect_to :action => 'list' |
|
71 | redirect_to :action => 'list' |
|
72 | end |
|
72 | end |
|
73 |
|
73 | ||
|
74 | assignment = user.get_test_pair_assignment_for(@current_problem) |
|
74 | assignment = user.get_test_pair_assignment_for(@current_problem) |
|
75 | if !assignment |
|
75 | if !assignment |
|
76 | flash[:notice] = 'Error: คุณยังไม่ได้ดาวน์โหลดข้อมูลทดสอบ' |
|
76 | flash[:notice] = 'Error: คุณยังไม่ได้ดาวน์โหลดข้อมูลทดสอบ' |
|
77 | prepare_list_information |
|
77 | prepare_list_information |
|
78 | render :action => 'list' and return |
|
78 | render :action => 'list' and return |
|
79 | end |
|
79 | end |
|
80 | - if assignment.expired? |
|
80 | + if (assignment.expired?) and (!GraderConfiguration.standard_mode?) |
|
81 | flash[:notice] = 'Error: หมดเวลาส่งสำหรับข้อนี้' |
|
81 | flash[:notice] = 'Error: หมดเวลาส่งสำหรับข้อนี้' |
|
82 | prepare_list_information |
|
82 | prepare_list_information |
|
83 | render :action => 'list' and return |
|
83 | render :action => 'list' and return |
|
84 | end |
|
84 | end |
|
85 |
|
85 | ||
|
86 | @submission.problem = @current_problem |
|
86 | @submission.problem = @current_problem |
|
87 | @submission.user = user |
|
87 | @submission.user = user |
|
88 | @submission.language_id = 0 |
|
88 | @submission.language_id = 0 |
|
89 | if (params['file']) and (params['file']!='') |
|
89 | if (params['file']) and (params['file']!='') |
|
90 | @submission.source = params['file'].read |
|
90 | @submission.source = params['file'].read |
|
91 | @submission.source_filename = params['file'].original_filename |
|
91 | @submission.source_filename = params['file'].original_filename |
|
92 | end |
|
92 | end |
|
93 | if (params['output_file']) and (params['output_file']!='') |
|
93 | if (params['output_file']) and (params['output_file']!='') |
|
94 | @submission.output = params['output_file'].read |
|
94 | @submission.output = params['output_file'].read |
|
95 | end |
|
95 | end |
|
96 | @submission.submitted_at = Time.new.gmtime |
|
96 | @submission.submitted_at = Time.new.gmtime |
|
97 |
|
97 | ||
|
98 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
98 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
99 | @submission.errors.add(:base,"The contest is over.") |
|
99 | @submission.errors.add(:base,"The contest is over.") |
|
100 | prepare_list_information |
|
100 | prepare_list_information |
|
101 | render :action => 'list' and return |
|
101 | render :action => 'list' and return |
|
102 | end |
|
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 | if @submission.valid? |
|
112 | if @submission.valid? |
|
105 | if @submission.save == false |
|
113 | if @submission.save == false |
|
106 | flash[:notice] = 'Error saving your submission' |
|
114 | flash[:notice] = 'Error saving your submission' |
|
107 | elsif Task.create(:submission_id => @submission.id, |
|
115 | elsif Task.create(:submission_id => @submission.id, |
|
108 | :status => Task::STATUS_INQUEUE) == false |
|
116 | :status => Task::STATUS_INQUEUE) == false |
|
109 | flash[:notice] = 'Error adding your submission to task queue' |
|
117 | flash[:notice] = 'Error adding your submission to task queue' |
|
110 | else |
|
118 | else |
|
111 | flash[:notice] = 'จัดเก็บคำตอบและโปรแกรมที่คุณส่งเรียบร้อย' |
|
119 | flash[:notice] = 'จัดเก็บคำตอบและโปรแกรมที่คุณส่งเรียบร้อย' |
|
112 | end |
|
120 | end |
|
113 | else |
|
121 | else |
|
114 | prepare_list_information |
|
122 | prepare_list_information |
|
115 | render :action => 'list' and return |
|
123 | render :action => 'list' and return |
@@ -305,31 +313,35 | |||||
|
305 | @announcements = Announcement.find_published |
|
313 | @announcements = Announcement.find_published |
|
306 | end |
|
314 | end |
|
307 | if recent!=nil |
|
315 | if recent!=nil |
|
308 | recent_id = recent.to_i |
|
316 | recent_id = recent.to_i |
|
309 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
317 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
310 | end |
|
318 | end |
|
311 | end |
|
319 | end |
|
312 |
|
320 | ||
|
313 | def prepare_timeout_information(problems) |
|
321 | def prepare_timeout_information(problems) |
|
314 | @submission_timeouts = {} |
|
322 | @submission_timeouts = {} |
|
315 | problems.each do |problem| |
|
323 | problems.each do |problem| |
|
316 | assignment = @user.get_test_pair_assignment_for(problem) |
|
324 | assignment = @user.get_test_pair_assignment_for(problem) |
|
317 | - if assignment == nil |
|
325 | + if GraderConfiguration.standard_mode? |
|
318 | timeout = nil |
|
326 | timeout = nil |
|
319 | else |
|
327 | else |
|
320 | - if (assignment.expired?) or (assignment.submitted) |
|
328 | + if assignment == nil |
|
321 |
- timeout = |
|
329 | + timeout = nil |
|
322 | else |
|
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 | end |
|
336 | end |
|
325 | end |
|
337 | end |
|
326 | @submission_timeouts[problem.id] = timeout |
|
338 | @submission_timeouts[problem.id] = timeout |
|
327 | end |
|
339 | end |
|
328 | end |
|
340 | end |
|
329 |
|
341 | ||
|
330 | def prepare_list_information |
|
342 | def prepare_list_information |
|
331 | @user = User.find(session[:user_id]) |
|
343 | @user = User.find(session[:user_id]) |
|
332 | if not GraderConfiguration.multicontests? |
|
344 | if not GraderConfiguration.multicontests? |
|
333 | @problems = @user.available_problems |
|
345 | @problems = @user.available_problems |
|
334 | else |
|
346 | else |
|
335 | @contest_problems = @user.available_problems_group_by_contests |
|
347 | @contest_problems = @user.available_problems_group_by_contests |
@@ -21,18 +21,18 | |||||
|
21 | ส่งคำตอบของข้อมูลสำหรับตรวจสอบ: |
|
21 | ส่งคำตอบของข้อมูลสำหรับตรวจสอบ: |
|
22 | <%= file_field_tag 'output_file' %> |
|
22 | <%= file_field_tag 'output_file' %> |
|
23 | <%= submit_tag 'Submit' %> |
|
23 | <%= submit_tag 'Submit' %> |
|
24 | <% end %> |
|
24 | <% end %> |
|
25 | </div> |
|
25 | </div> |
|
26 | <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;"> |
|
26 | <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;"> |
|
27 | <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด): |
|
27 | <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด): |
|
28 | <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => "return TOIContest.confirmDownload(#{problem.id})" } %> |
|
28 | <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => "return TOIContest.confirmDownload(#{problem.id})" } %> |
|
29 | <span id="submission_time_left_<%= problem.id %>_id"></span> |
|
29 | <span id="submission_time_left_<%= problem.id %>_id"></span> |
|
30 | <%= form_tag({:controller => 'main', :action => 'submit'}, {:method => 'post', :multipart => true, :id => "submission_form_#{problem.id}_id" }) do %> |
|
30 | <%= form_tag({:controller => 'main', :action => 'submit'}, {:method => 'post', :multipart => true, :id => "submission_form_#{problem.id}_id" }) do %> |
|
31 | <%= hidden_field_tag 'submission[problem_id]', problem.id %> |
|
31 | <%= hidden_field_tag 'submission[problem_id]', problem.id %> |
|
32 | ข้อมูลส่งออก: <%= file_field_tag 'output_file' %> |
|
32 | ข้อมูลส่งออก: <%= file_field_tag 'output_file' %> |
|
33 |
- โปรแกรม |
|
33 | + โปรแกรมของคุณ: <%= file_field_tag 'file' %> |
|
34 | <%= submit_tag 'Submit' %> |
|
34 | <%= submit_tag 'Submit' %> |
|
35 | <% end %> |
|
35 | <% end %> |
|
36 | </div> |
|
36 | </div> |
|
37 | </div> |
|
37 | </div> |
|
38 | <% end %> |
|
38 | <% end %> |
You need to be logged in to leave comments.
Login now