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

r382:c141e39c9118 - - 4 files changed: 58 inserted, 23 deleted

@@ -0,0 +1,37
1 + var TOIContest = {
2 + NO_TIMEOUT: -1,
3 +
4 + timeOuts: {},
5 +
6 + problemSelectClick: function() {
7 + $$(".submission-submit-divs").each(function(item) {
8 + item.hide();
9 + });
10 + var problem_id = $('submission_problem_id').value;
11 + if ( problem_id < 0 ) {
12 + return;
13 + }
14 + $("submission_submit_div_" + problem_id + "_id").show();
15 + },
16 +
17 + confirmDownload: function() {
18 + return confirm("แน่ใจ?");
19 + },
20 +
21 + refreshTimeOutMessages: function() {
22 + for ( var pid in TOIContest.timeOuts ) {
23 + var timeOut = TOIContest.timeOuts[ pid ];
24 + if ( timeOut != TOIContest.NO_TIMEOUT ) {
25 + if ( timeOut > 0 ) {
26 + var minLeft = parseInt(timeOut / 60);
27 + var secLeft = parseInt(timeOut % 60);
28 + $('submission_time_left_' + pid + '_id').innerHTML = '| <b>เหลือเวลาอีก ' + minLeft + ':' + secLeft + ' นาที</b>';
29 + } else {
30 + $('submission_time_left_' + pid + '_id').innerHTML = '| <b>หมดเวลาส่ง</a>';
31 + $('submission_form_'+ pid + '_id').hide();
32 + }
33 + }
34 + }
35 + }
36 + };
37 +
@@ -251,56 +251,60
251 flash[:notice] = 'Error: problem is not available'
251 flash[:notice] = 'Error: problem is not available'
252 redirect_to :action => 'list' and return
252 redirect_to :action => 'list' and return
253 end
253 end
254
254
255 test_pair = TestPair.get_for(problem, false)
255 test_pair = TestPair.get_for(problem, false)
256 if (params['output_file']) and (params['output_file']!='')
256 if (params['output_file']) and (params['output_file']!='')
257 output = params['output_file'].read
257 output = params['output_file'].read
258
258
259 @current_problem = problem
259 @current_problem = problem
260 @grading_result = grade(output, test_pair.solution)
260 @grading_result = grade(output, test_pair.solution)
261 prepare_list_information
261 prepare_list_information
262 render :action => 'list' and return
262 render :action => 'list' and return
263 else
263 else
264 flash[:notice] = 'Error: output file errors'
264 flash[:notice] = 'Error: output file errors'
265 redirect_to :action => 'list'
265 redirect_to :action => 'list'
266 end
266 end
267 end
267 end
268
268
269 protected
269 protected
270
270
271 def grade(output, solution)
271 def grade(output, solution)
272 out_items = output.split
272 out_items = output.split
273 sol_items = solution.split
273 sol_items = solution.split
274 res = ''
274 res = ''
275 + f = 0
276 + s = 0
275 sol_items.length.times do |i|
277 sol_items.length.times do |i|
278 + f += 1
276 if out_items[i] == sol_items[i]
279 if out_items[i] == sol_items[i]
277 res = res + 'P'
280 res = res + 'P'
281 + s += 1
278 else
282 else
279 res = res + '-'
283 res = res + '-'
280 end
284 end
281 end
285 end
282 - return res
286 + return { :score => s, :full_score => f, :msg => res }
283 end
287 end
284
288
285 def prepare_announcements(recent=nil)
289 def prepare_announcements(recent=nil)
286 if GraderConfiguration.show_tasks_to?(@user)
290 if GraderConfiguration.show_tasks_to?(@user)
287 @announcements = Announcement.find_published(true)
291 @announcements = Announcement.find_published(true)
288 else
292 else
289 @announcements = Announcement.find_published
293 @announcements = Announcement.find_published
290 end
294 end
291 if recent!=nil
295 if recent!=nil
292 recent_id = recent.to_i
296 recent_id = recent.to_i
293 @announcements = @announcements.find_all { |a| a.id > recent_id }
297 @announcements = @announcements.find_all { |a| a.id > recent_id }
294 end
298 end
295 end
299 end
296
300
297 def prepare_timeout_information(problems)
301 def prepare_timeout_information(problems)
298 @submission_timeouts = {}
302 @submission_timeouts = {}
299 problems.each do |problem|
303 problems.each do |problem|
300 assignment = @user.get_test_pair_assignment_for(problem)
304 assignment = @user.get_test_pair_assignment_for(problem)
301 if assignment == nil
305 if assignment == nil
302 timeout = nil
306 timeout = nil
303 else
307 else
304 if (assignment.expired?) or (assignment.submitted)
308 if (assignment.expired?) or (assignment.submitted)
305 timeout = 0
309 timeout = 0
306 else
310 else
@@ -1,51 +1,36
1 <div class="submitbox">
1 <div class="submitbox">
2 <b>Problem:</b> <%= select 'submission', 'problem_id',
2 <b>Problem:</b> <%= select 'submission', 'problem_id',
3 [['กรุณาเลือกข้อที่ต้องการส่งหรือทดสอบ','-1']] +
3 [['กรุณาเลือกข้อที่ต้องการส่งหรือทดสอบ','-1']] +
4 @problems.collect {|p| [p.full_name, p.id]},
4 @problems.collect {|p| [p.full_name, p.id]},
5 { :selected => '-1' },
5 { :selected => '-1' },
6 - { :onchange => 'select_click()' } %>
6 + { :onchange => 'TOIContest.problemSelectClick()' } %>
7 </div>
7 </div>
8
8
9 <% @problems.each do |problem| %>
9 <% @problems.each do |problem| %>
10 <div class="submission-submit-divs" id="submission_submit_div_<%= problem.id %>_id" style="displanny: none;">
10 <div class="submission-submit-divs" id="submission_submit_div_<%= problem.id %>_id" style="displanny: none;">
11 <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;">
11 <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;">
12 - <b><%= problem.full_name %>: ข้อมูลสำหรับตรวจสอบ</b> (สามารถดาวน์โหลดและส่งกี่ครั้งก็ได้):
12 + <b><%= problem.full_name %>: ข้อมูลสำหรับตรวจสอบ</b> (สามารถดาวน์โหลดและส่งกี่ครั้งก็ได้,ไม่มีคะแนน):
13 <%= link_to 'ดาวน์โหลด input', :action => 'verifying_testcase', :id => problem.id %>
13 <%= link_to 'ดาวน์โหลด input', :action => 'verifying_testcase', :id => problem.id %>
14 - <% if @current_problem.id == problem.id %>
14 + <% if @current_problem and @current_problem.id == problem.id %>
15 <% if @grading_result %>
15 <% if @grading_result %>
16 - | <b>ผลการตรวจ:</b> <%= @grading_result %>
16 + | <b>ผลการตรวจ:</b> <%= "#{@grading_result[:score]}/#{@grading_result[:full_score]} [#{@grading_result[:msg]}]" %>
17 <% end %>
17 <% end %>
18 <% end %>
18 <% end %>
19 - <%= form_tag({:controller => 'main', :action => 'verifying_submit', :id => problem.id}, {:method => 'post', :multipart => true}) do %>
19 + <%= form_tag({:controller => 'main', :action => 'verifying_submit', :id => problem.id}, {:method => 'post', :multipart => true }) do %>
20 ส่งคำตอบของข้อมูลสำหรับตรวจสอบ:
20 ส่งคำตอบของข้อมูลสำหรับตรวจสอบ:
21 <%= file_field_tag 'output_file' %>
21 <%= file_field_tag 'output_file' %>
22 <%= submit_tag 'Submit' %>
22 <%= submit_tag 'Submit' %>
23 <% end %>
23 <% end %>
24 </div>
24 </div>
25 <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;">
25 <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;">
26 <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด):
26 <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด):
27 - <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => 'return confirm_download()' } %>
27 + <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => 'return TOIContest.confirmDownload()' } %>
28 <span id="submission_time_left_<%= problem.id %>_id"></span>
28 <span id="submission_time_left_<%= problem.id %>_id"></span>
29 - <%= form_tag do %>
29 + <%= form_tag({:controller => 'main', :action => 'submit', :id => problem.id}, {:method => 'post', :multipart => true, :id => "submission_form_#{problem.id}_id" }) do %>
30 ข้อมูลส่งออก: <%= file_field_tag 'output_file' %>
30 ข้อมูลส่งออก: <%= file_field_tag 'output_file' %>
31 โปรแกรมคำตอบ: <%= file_field_tag 'source_file' %>
31 โปรแกรมคำตอบ: <%= file_field_tag 'source_file' %>
32 <%= submit_tag 'Submit' %>
32 <%= submit_tag 'Submit' %>
33 <% end %>
33 <% end %>
34 </div>
34 </div>
35 </div>
35 </div>
36 <% end %>
36 <% end %>
37 - <script>
38 - function select_click() {
39 - $$(".submission-submit-divs").each(function(item) {
40 - item.hide();
41 - });
42 - var problem_id = $('submission_problem_id').value;
43 - if ( problem_id < 0 ) {
44 - return;
45 - }
46 - $("submission_submit_div_" + problem_id + "_id").show();
47 - }
48 - function confirm_download() {
49 - return confirm("แน่ใจ?");
50 - }
51 - </script>
@@ -1,50 +1,59
1 - content_for :head do
1 - content_for :head do
2 = javascript_include_tag "announcement_refresh"
2 = javascript_include_tag "announcement_refresh"
3 + = javascript_include_tag "toicontest"
3
4
4 = user_title_bar(@user)
5 = user_title_bar(@user)
5
6
6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 %span{:class => 'title'}
8 %span{:class => 'title'}
8 Announcements
9 Announcements
9 #announcementbox-body
10 #announcementbox-body
10 = render :partial => 'announcement', :collection => @announcements
11 = render :partial => 'announcement', :collection => @announcements
11
12
12 - if GraderConfiguration.show_submitbox_to?(@user)
13 - if GraderConfiguration.show_submitbox_to?(@user)
13 = error_messages_for 'submission'
14 = error_messages_for 'submission'
14 = render :partial => 'submission_box'
15 = render :partial => 'submission_box'
15
16
16
17
17 %hr/
18 %hr/
18
19
19 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
20 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
20 %p=t 'main.start_soon'
21 %p=t 'main.start_soon'
21
22
22 - if GraderConfiguration.show_tasks_to?(@user)
23 - if GraderConfiguration.show_tasks_to?(@user)
23 - if not GraderConfiguration.multicontests?
24 - if not GraderConfiguration.multicontests?
24 %table.info
25 %table.info
25 %tr.info-head
26 %tr.info-head
26 %th
27 %th
27 %th Tasks
28 %th Tasks
28 %th # of sub(s)
29 %th # of sub(s)
29 %th Results
30 %th Results
30 = render :partial => 'problem', :collection => @problems
31 = render :partial => 'problem', :collection => @problems
31 - else
32 - else
32 - @contest_problems.each do |cp|
33 - @contest_problems.each do |cp|
33 - if cp[:problems].length > 0
34 - if cp[:problems].length > 0
34 %h2{:class =>'contest-title'}
35 %h2{:class =>'contest-title'}
35 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
36 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
36 %table.info
37 %table.info
37 %tr.info-head
38 %tr.info-head
38 %th
39 %th
39 %th Tasks
40 %th Tasks
40 %th # of sub(s)
41 %th # of sub(s)
41 %th Results
42 %th Results
42 = render :partial => 'problem', :collection => cp[:problems]
43 = render :partial => 'problem', :collection => cp[:problems]
43
44
44
45
45 %hr/
46 %hr/
46
47
47 %script{:type => 'text/javascript'}
48 %script{:type => 'text/javascript'}
48 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
49 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
49 Announcement.registerRefreshEventTimer();
50 Announcement.registerRefreshEventTimer();
50
51
52 + TOIContest.timeOuts = {};
53 + - @problems.each do |p|
54 + - if (@submission_timeouts.has_key? p.id) and (@submission_timeouts[p.id] != nil)
55 + = "TOIContest.timeOuts[#{p.id}] = #{@submission_timeouts[p.id]};"
56 + - else
57 + = "TOIContest.timeOuts[#{p.id}] = TOIContest.NO_TIMEOUT;"
58 +
59 + TOIContest.refreshTimeOutMessages();
You need to be logged in to leave comments. Login now