From a7dbc3e822427db8d34580ced63e91bcc67f37ec Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 13 Apr 2017 13:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E5=B1=80=E9=83=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=EF=BC=9B=E6=B5=8B=E8=AF=84=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA=EF=BC=9B=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 3 +- app/models/test_set.rb | 3 +- app/views/games/_code_actions.html.erb | 107 +++++++++++++----- app/views/games/_game_results.html.erb | 60 ++++------ app/views/games/_game_show.html.erb | 9 +- ...13030447_add_actual_output_to_test_sets.rb | 5 + .../20170413032641_add_hidden_to_test_sets.rb | 6 + 7 files changed, 120 insertions(+), 73 deletions(-) create mode 100644 db/migrate/20170413030447_add_actual_output_to_test_sets.rb create mode 100644 db/migrate/20170413032641_add_hidden_to_test_sets.rb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index d919ac59a..db582c838 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -46,8 +46,7 @@ class GamesController < ApplicationController logger.info("7777************#{@entries} ") end logger.info("88888************#{@entries} ") - @latest_output = @game.latest_output.try(:out_put).to_s - outputs = @game.outputs + @test_cases = @game_challenge.test_sets (@myshixun.games.count == @game_challenge.position && @game.status ==2) ? @had_done = 1 : @had_done = 0 if outputs.count == 0 @results = [] diff --git a/app/models/test_set.rb b/app/models/test_set.rb index b42172970..90627a8db 100644 --- a/app/models/test_set.rb +++ b/app/models/test_set.rb @@ -1,4 +1,5 @@ class TestSet < ActiveRecord::Base - attr_accessible :challenge_id, :input, :output, :game_id + default_scope :order => 'id desc' + attr_accessible :challenge_id, :input, :output, :game_id, :actual_output belongs_to :challenge end diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index f8325d57e..0fd7e1a65 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -1,27 +1,80 @@ -
-
-

操作

-
-
- 保存修改 - <% if @game.status == 0 %> - <%= link_to "提交评测", { :controller => 'games', - :action => "game_build", - :id => @game, - :myshixun_id => @myshixun}, - :class => "task-btn task-btn-green", - :onclick => "training_task_submmit();", - :remote => true %> - <% elsif @game.status == 2 %> - 评测中.. - <% elsif @game.status == 1 %> - <%= link_to "下 一 步 ", {:controller => 'games', - :action => "next_step", - :id => @game, - :myshixun_id => @myshixun}, - :class => "task-btn task-btn-green", - :onclick => "training_task_submmit();", - :remote => true %> - <% end %> -
-
\ No newline at end of file +耗时:<%= game_spend_time(@game.created_at, @game.updated_at) %> +<% if @game.status == 0 %> +评测 +<% elsif @game.status == 1 %> + 评测中.. +<% elsif @game.status == 2 %> + <%= link_to "下 一 步 ", {:controller => 'games',:action => "next_step", :id => @game, + :myshixun_id => @myshixun}, + :class => "task-btn task-btn-blue mr15 mt8", + :onclick => "training_task_submmit();", + :remote => true %> +<% end %> + + \ No newline at end of file diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 382aa9794..50d3fa892 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -15,45 +15,27 @@

0/11 编译错误

-
-
- - 测试集 1 -
-
-
    -
  • 输入:param1:1
  • -
  • 实际输出:
  • -
  • 期望输出:3
  • -
-
-
-
-
- - 测试集 2 -
-
-
-
-
-
- - 测试集 3 - -
-
-
-
-
-
- - 测试集 4 - -
-
-
-
+ <% @test_cases.each_with_index do |test_case, index| %> +
+
+ + 测试集 <%= index + 1 %> + <% unless test_case.is_public? %> + + <% end %> + <% unless test_case.result? %> + + <% end %> +
+
+
    +
  • 输入:<%= test_case.input %>
  • +
  • 实际输出:<%= test_case.actual_output %>
  • +
  • 期望输出:<%= test_case.output %>
  • +
+
+
+ <% end %>
diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index e00ef1e02..d79130136 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -69,11 +69,12 @@ +
-
- 耗时:1天5小时10分钟 - 测评 +
+ <%= render :partial => "games/code_actions" %>
- \ No newline at end of file + + diff --git a/db/migrate/20170413030447_add_actual_output_to_test_sets.rb b/db/migrate/20170413030447_add_actual_output_to_test_sets.rb new file mode 100644 index 000000000..b1838e1d0 --- /dev/null +++ b/db/migrate/20170413030447_add_actual_output_to_test_sets.rb @@ -0,0 +1,5 @@ +class AddActualOutputToTestSets < ActiveRecord::Migration + def change + add_column :test_sets, :actual_output, :string + end +end diff --git a/db/migrate/20170413032641_add_hidden_to_test_sets.rb b/db/migrate/20170413032641_add_hidden_to_test_sets.rb new file mode 100644 index 000000000..69253bf49 --- /dev/null +++ b/db/migrate/20170413032641_add_hidden_to_test_sets.rb @@ -0,0 +1,6 @@ +class AddHiddenToTestSets < ActiveRecord::Migration + def change + add_column :test_sets, :is_public, :boolean, :default => true + add_column :test_sets, :result, :boolean, :default => true + end +end