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 +
@@ -272,14 +272,18
272 272 out_items = output.split
273 273 sol_items = solution.split
274 274 res = ''
275 + f = 0
276 + s = 0
275 277 sol_items.length.times do |i|
278 + f += 1
276 279 if out_items[i] == sol_items[i]
277 280 res = res + 'P'
281 + s += 1
278 282 else
279 283 res = res + '-'
280 284 end
281 285 end
282 - return res
286 + return { :score => s, :full_score => f, :msg => res }
283 287 end
284 288
285 289 def prepare_announcements(recent=nil)
@@ -3,20 +3,20
3 3 [['กรุณาเลือกข้อที่ต้องการส่งหรือทดสอบ','-1']] +
4 4 @problems.collect {|p| [p.full_name, p.id]},
5 5 { :selected => '-1' },
6 - { :onchange => 'select_click()' } %>
6 + { :onchange => 'TOIContest.problemSelectClick()' } %>
7 7 </div>
8 8
9 9 <% @problems.each do |problem| %>
10 10 <div class="submission-submit-divs" id="submission_submit_div_<%= problem.id %>_id" style="displanny: none;">
11 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 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 15 <% if @grading_result %>
16 - | <b>ผลการตรวจ:</b> <%= @grading_result %>
16 + | <b>ผลการตรวจ:</b> <%= "#{@grading_result[:score]}/#{@grading_result[:full_score]} [#{@grading_result[:msg]}]" %>
17 17 <% end %>
18 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 21 <%= file_field_tag 'output_file' %>
22 22 <%= submit_tag 'Submit' %>
@@ -24,9 +24,9
24 24 </div>
25 25 <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;">
26 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 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 30 ข้อมูลส่งออก: <%= file_field_tag 'output_file' %>
31 31 โปรแกรมคำตอบ: <%= file_field_tag 'source_file' %>
32 32 <%= submit_tag 'Submit' %>
@@ -34,18 +34,3
34 34 </div>
35 35 </div>
36 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,5 +1,6
1 1 - content_for :head do
2 2 = javascript_include_tag "announcement_refresh"
3 + = javascript_include_tag "toicontest"
3 4
4 5 = user_title_bar(@user)
5 6
@@ -48,3 +49,11
48 49 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
49 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