diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 3ddb3e03d..10c9a66cc 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -98,7 +98,7 @@ class GamesController < ApplicationController testCode.store("testCode_#{index}",test_set.try(:output)) end end - + testCode = testCode.to_json jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] step = @game.stage params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :testCode => "#{testCode}"} diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5249a07e2..e18fbae05 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -35,12 +35,7 @@ class ShixunsController < ApplicationController s = Trustie::Gitlab::Sync.new s.sync_user(User.current) end - if @shixun.gpid - gshixun = g.project(@shixun.gpid) - else - gshixun = g.fork(@shixun.gpid, User.current.gid) - end - + gshixun = g.fork(@shixun.gpid, User.current.gid) if gshixun.id myshixun = copy_myshixun(@shixun, gshixun) challenges = @shixun.challenges diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c8272746e..cbb4bf3a0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,13 +46,13 @@ module ApplicationHelper end # 正在进行中任务 - def shixun_running shixun - Myshixun.where(:parent_id => shixun, :status => 0).count + def shixun_running shixun, position + Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and parent_id =#{shixun.id} and g.stage=#{position} and (g.status=0 or g.status=1);").count end # 已完成任务 - def shixun_done shixun - Myshixun.where(:parent_id => shixun, :status => 1).count + def shixun_done shixun, position + Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and parent_id =#{shixun.id} and g.stage=#{position} and g.status=2;").count end # 测评次数 diff --git a/app/models/game.rb b/app/models/game.rb index 400adddb4..e7bd9b6dc 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,7 +1,7 @@ class Game < ActiveRecord::Base # stauts 0: can exe 1:doing 2:successed 3:locked default_scope :order => 'stage' - attr_accessible :description, :myshixun_id, :stage, :subject, :user_id, :status, :ready_knowledge, :task_pass, :answer, :score, :final_score + attr_accessible :description, :myshixun_id, :stage, :subject, :user_id, :status, :ready_knowledge, :task_pass, :answer, :score, :final_score, :path belongs_to :myshixun,:touch=> true belongs_to :user has_many :outputs, :dependent => :destroy diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index ddebca904..131f87968 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -12,6 +12,7 @@

第<%= challenge.position %>关 <%= link_to challenge.subject, shixun_challenge_path(@shixun.id, challenge), :target => "_blank" %>

+ <% if User.current.manager_of_shixun?(@shixun) %> + <% end %>

- <% if shixun_running(@shixun) != 0 %> - 正在挑战:<%= shixun_running @shixun %> + <% if shixun_running(@shixun, challenge.position) != 0 %> + 正在挑战:<%= shixun_running(@shixun, challenge.position) %> <% end %> - <% if shixun_done(@shixun) != 0 %> - 完成挑战:<%= shixun_done @shixun %> + <% if shixun_done(@shixun, challenge.position) != 0 %> + 完成挑战:<%= shixun_done(@shixun, challenge.position) %> <% end %> <% if top_score(@shixun, challenge.position).score.to_i != 0 %> 最佳表现:<%= top_score(@shixun, challenge.position).score.to_i %>分 diff --git a/app/views/myshixuns/_myshixun_top.html.erb b/app/views/myshixuns/_myshixun_top.html.erb index 21a9a4bfa..2556fd6a6 100644 --- a/app/views/myshixuns/_myshixun_top.html.erb +++ b/app/views/myshixuns/_myshixun_top.html.erb @@ -4,7 +4,7 @@