game列表的一些统计
This commit is contained in:
parent
2891943cf5
commit
6a77410d80
|
@ -109,7 +109,11 @@ module ApplicationHelper
|
|||
min = time % (24*60*60) % (60*60) / 60
|
||||
if day < 1
|
||||
if hour < 1
|
||||
time = "#{min} 分钟"
|
||||
if time < 1
|
||||
time = time == 0 ? "--" : "小于1分钟"
|
||||
else
|
||||
time = "#{min} 分钟"
|
||||
end
|
||||
else
|
||||
time = "#{hour}小时 : #{min}分"
|
||||
end
|
||||
|
@ -119,9 +123,13 @@ module ApplicationHelper
|
|||
return time
|
||||
end
|
||||
|
||||
def avg_spend_time shixun_id, position
|
||||
Game.find_by_sql("SELECT avg(g.updated_at - g.created_at) as avg_time FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position = #{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id= #{shixun_id});").first.try(:avg_time).to_i
|
||||
end
|
||||
|
||||
# 已闯关
|
||||
def had_pass myshixun
|
||||
Game.find_by_sql("SELECT * FROM `games` where status =2 and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{myshixun.parent_id});").count
|
||||
def had_pass shixun_id, position
|
||||
Game.find_by_sql("SELECT count(*) as count FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position =#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id=#{shixun_id});").first.try(:count)
|
||||
end
|
||||
|
||||
# 单个game测评次数
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
|
||||
<%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
|
||||
<p class="ml15 mt15 color-grey">
|
||||
<span class=" mr10">已闯关:<%= had_pass(@myshixun) %>人</span>
|
||||
<span class=" mr10">平均耗时:0小时28分</span>
|
||||
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
|
||||
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
|
||||
</p>
|
||||
</div>
|
||||
<a href="#" class=" task-btn task-btn-green fr">马上开启</a>
|
||||
|
@ -22,8 +22,8 @@
|
|||
<h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
|
||||
<%= game.challenge.try(:subject) %></h4>
|
||||
<p class="ml15 mt15 color-grey">
|
||||
<span class=" mr10">已闯关:<%#= had_pass(@myshixun) %>人</span>
|
||||
<span class=" mr10">平均耗时:0小时28分</span>
|
||||
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
|
||||
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
|
||||
</p>
|
||||
</div>
|
||||
<a href="#" class=" fr link-color-green">正在解决中</a>
|
||||
|
@ -31,22 +31,22 @@
|
|||
<% elsif game.status == 2 %>
|
||||
<h4 class="fl panel-inner-title "><i class="fa fa-check-circle font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
|
||||
<%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4>
|
||||
<p class="fr "><i class="fa fa-trophy color-yellow font-16 mr5 "></i><span class=" color-grey">NO.120</span></p>
|
||||
<!--<p class="fr "><i class="fa fa-trophy color-yellow font-16 mr5 "></i><span class=" color-grey">NO.120</span></p>-->
|
||||
<div class="cl"></div>
|
||||
<p class="ml15 mt15 color-grey">
|
||||
<span class=" mr10">开始时间:<%= format_time(game.created_at) %></span>
|
||||
<span class=" mr10">完成时间:<%= format_time(game.updated_at) %></span>
|
||||
<span class=" mr10">耗时:<%#= game_avg_hour(game.created_at, game.updated_at) %>小时<%= game_avg_min(game.created_at, game.updated_at) %>分</span>
|
||||
<span class=" mr10">测评次数:<%#= avg_my_pass game %>次</span>
|
||||
<span class=" mr10">得分:<%#= game.final_score %>分</span>
|
||||
<span class=" mr10">耗时:<%= game_spend_time(game.created_at, game.updated_at) %>分</span>
|
||||
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
|
||||
<span class=" mr10">得分:<%= game.final_score %>分</span>
|
||||
</p>
|
||||
<% elsif game.status == 3 %>
|
||||
<div class="fl">
|
||||
<h4 class=" panel-inner-title "><i class="fa fa-lock font-18 color-grey mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span>
|
||||
<%= game.challenge.try(:subject) %></h4>
|
||||
<p class="ml15 mt15 color-grey">
|
||||
<span class=" mr10">已闯关:<%#= had_pass(@myshixun) %>人</span>
|
||||
<span class=" mr10">平均耗时:0小时28分</span>
|
||||
<span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span>
|
||||
<span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span>
|
||||
</p>
|
||||
</div>
|
||||
<a href="#" class=" task-btn fr"> 已锁定 </a>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!--<li><i class="fa fa-signal font-14 mr5"></i>排名:<a href="#" class="">123</a></li>-->
|
||||
<li><i class="fa fa-trophy font-14 mr5"></i>积分:<%= shixun_final_score(@myshixun) %></li>
|
||||
<% if (Time.now - @game.created_at) > 60 %>
|
||||
<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<%= @game.status == 2 ? game_spend_time(@game.created_at, Time.now) : game_spend_time(@game.created_at, @game.updated_at) %></li>
|
||||
<li><i class="fa fa-clock-o font-14 mr5"></i>耗时:<%= @game.status != 2 ? game_spend_time(@game.created_at, Time.now) : game_spend_time(@game.created_at, @game.updated_at) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue