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/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 1f2e8b974..131f87968 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -27,11 +27,11 @@ <% 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 %>分