diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index c673a1f38..fcdc53f59 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -41,6 +41,11 @@ class ChallengesController < ApplicationController end end end + if params[:knowledge][:input].length > 0 + params[:knowledge][:input].each do |input| + ChallengeTag.create(:name => input, :challenge_id => @challenge.id) + end + end respond_to do |format| format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)} end @@ -64,7 +69,9 @@ class ChallengesController < ApplicationController end def show - @outputs = GameOutputs.all + @challenge_samples = @challenge.challenge_samples + @test_sets = @challenge.test_sets + @challenge_tags = @challenge.challenge_tags respond_to do |format| format.html format.js @@ -72,10 +79,13 @@ class ChallengesController < ApplicationController end def edit - + @challenge_samples = @challenge.challenge_samples + @test_sets = @challenge.test_sets + @challenge_tags = @challenge.challenge_tags end def update + @challenge = Challenge.new(params[:challenge]) end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 2c8c7e746..d3f754b04 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -22,6 +22,7 @@ class MyshixunsController < ApplicationController game.update_attribute(:status, 0) end game_outputs = GameOutputs.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) + render :json => {:data => "success"} end def show diff --git a/app/models/challenge.rb b/app/models/challenge.rb index e7a16c72d..04d984945 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -4,6 +4,7 @@ class Challenge < ActiveRecord::Base belongs_to :user has_many :challenge_samples, :dependent => :destroy has_many :test_sets, :dependent => :destroy + has_many :challenge_tags, :dependent => :destroy validates_presence_of :subject validates_presence_of :score diff --git a/app/models/challenge_tag.rb b/app/models/challenge_tag.rb new file mode 100644 index 000000000..5f5925f92 --- /dev/null +++ b/app/models/challenge_tag.rb @@ -0,0 +1,4 @@ +class ChallengeTag < ActiveRecord::Base + attr_accessible :challenge_id, :name + belongs_to :challenge +end diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index 7d34b19dc..4b5441590 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -42,7 +42,7 @@
  • <% if params[:action] == "edit" && @challenge.challenge_samples.count > 0 %> - <% @challenge.challenge_samples.each_with_index do |sample, index| %> + <% @challenge.challenge_samples.each_with_index do |sample, index| %> - <% end %> + <% end %> <% else %>