challenge列表的一些统计
This commit is contained in:
parent
ddf7a6e4a0
commit
15872d0da5
|
@ -22,22 +22,17 @@ class GamesController < ApplicationController
|
||||||
# path:"" && path: @game.path
|
# path:"" && path: @game.path
|
||||||
def show
|
def show
|
||||||
@game_challenge = @game.challenge
|
@game_challenge = @game.challenge
|
||||||
logger.info("*** ###############")
|
|
||||||
game_path = (@game_challenge.path.blank? ? @path : @game_challenge.path.strip)
|
game_path = (@game_challenge.path.blank? ? @path : @game_challenge.path.strip)
|
||||||
@rev = @rev.nil? ? "master" : @rev
|
@rev = @rev.nil? ? "master" : @rev
|
||||||
@git_url = git_repository_url(@myshixun, "Myshixun")
|
@git_url = git_repository_url(@myshixun, "Myshixun")
|
||||||
logger.info("*** git_url is###{@git_url}")
|
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
logger.info("*** ###{@rev}#######{@path}")
|
|
||||||
# 默认打开文件
|
# 默认打开文件
|
||||||
if @path == "" && !game_path.nil? && !@repository.cat(game_path, @rev).blank? && @type != "root"
|
if @path == "" && !game_path.nil? && !@repository.cat(game_path, @rev).blank? && @type != "root"
|
||||||
@path = game_path
|
@path = game_path
|
||||||
@file_open = true
|
@file_open = true
|
||||||
@content = @repository.cat(@path, @rev)
|
@content = @repository.cat(@path, @rev)
|
||||||
logger.info("content result is ###############{@content}")
|
|
||||||
else
|
else
|
||||||
@entries = @repository.entries(@path, @rev)
|
@entries = @repository.entries(@path, @rev)
|
||||||
logger.info("result is ###############{@entries.first.try(:path)}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@latest_output = @game.latest_output.try(:out_put)
|
@latest_output = @game.latest_output.try(:out_put)
|
||||||
|
|
|
@ -37,22 +37,22 @@ module ApplicationHelper
|
||||||
# 定义实训相关方法
|
# 定义实训相关方法
|
||||||
# myshixun 最高分
|
# myshixun 最高分
|
||||||
def top_score shixun, position
|
def top_score shixun, position
|
||||||
Game.find_by_sql("SELECT max(final_score) as score FROM `games` where stage=#{position} and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{shixun.id})").first
|
Game.find_by_sql("SELECT max(final_score) as top_score FROM `games` g, `challenges` c where g.challenge_id = c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:top_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 实训平均分
|
# 实训平均分
|
||||||
def shixun_avg_score shixun, position
|
def shixun_avg_score shixun, position
|
||||||
Game.find_by_sql("SELECT avg(final_score) as avg_score FROM `games` where stage=#{position} and myshixun_id in (SELECT id FROM `myshixuns` where parent_id=#{shixun.id})")
|
Game.find_by_sql("SELECT avg(g.final_score) as avg_score FROM `games` g, `challenges` c where g.challenge_id=c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:avg_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 正在进行中任务
|
# 正在进行中任务
|
||||||
def shixun_running shixun, position
|
def shixun_running shixun, position
|
||||||
Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and shixun_id =#{shixun.id} and g.stage=#{position} and (g.status=0 or g.status=1);").count
|
Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status in ('0','1');").first.try(:count)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 已完成任务
|
# 已完成任务
|
||||||
def shixun_done shixun, position
|
def shixun_done shixun, position
|
||||||
Myshixun.find_by_sql("SELECT * FROM `myshixuns` ms, `games` g where g.myshixun_id = ms.id and shixun_id =#{shixun.id} and g.stage=#{position} and g.status=2;").count
|
Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status=2;").first.try(:count)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 测评次数
|
# 测评次数
|
||||||
|
|
|
@ -21,14 +21,16 @@
|
||||||
<a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="下移" data-remote="true"><i class="fa fa-long-arrow-down color-grey font-16 mr5" ></i></a>
|
<a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="下移" data-remote="true"><i class="fa fa-long-arrow-down color-grey font-16 mr5" ></i></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="编辑" ><i class="fa fa-pencil-square-o color-grey font-16 mr5" ></i></a>
|
<a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="编辑" ><i class="fa fa-pencil-square-o color-grey font-16 mr5" ></i></a>
|
||||||
<!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>-->
|
<!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>-->
|
||||||
<!--<a href="#" title="排名" ><i class="fa fa-signal color-grey font-16 mr5 " ></i></a>-->
|
<!--<a href="#" title="排名" ><i class="fa fa-signal color-grey font-16 mr5 " ></i></a>-->
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<p class="ml15 mt15 color-grey">
|
<p class="ml15 mt15 color-grey">
|
||||||
|
<span class=" mr10">正在挑战:<%= shixun_running(@shixun, challenge.position) %></span>
|
||||||
<!--<span class=" mr10">平均表现:<%#= shixun_avg_score(@shixun, challenge.position).avg_score.to_i %>分 </span>-->
|
<span class=" mr10">完成挑战:<%= shixun_done(@shixun, challenge.position) %></span>
|
||||||
|
<span class=" mr10">最佳表现:<%= top_score(@shixun, challenge.position) %>分</span>
|
||||||
|
<span class=" mr10">平均表现:<%= shixun_avg_score(@shixun, challenge.position).to_i %>分 </span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in New Issue