实训是否可以开启的调整

This commit is contained in:
cxt 2017-08-28 09:30:43 +08:00
parent 6b42fa6d15
commit 8a1585476a
2 changed files with 7 additions and 3 deletions

View File

@ -665,10 +665,14 @@ module ApplicationHelper
Myshixun.where(:user_id => User.current.id, :shixun_id => shixun.id).count > 0 ? true : false
end
# 用户必须登录;必须创建了关卡;必须提交了版本库代码
# 用户必须登录;必须创建了关卡;有实践任务的必须提交了版本库代码
def allow_shixun_exec shixun
g = Gitlab.client
(User.current.logged? && shixun.challenges.count > 0 && g.trees(shixun.gpid).count.to_i > 0)
result = User.current.logged? && shixun.challenges.count > 0
if shixun.challenges.where(:st => 0).count > 0
result = result && g.trees(shixun.gpid).count.to_i > 0
end
result
end
# 判断当前用户是否可以开始实战

View File

@ -33,7 +33,7 @@
<% stage.stage_shixuns.each_with_index do |stage_shixun, index| %>
<% shixun = stage_shixun.shixun %>
<div class="clearfix pt10 pb10 ml20 pl10 mb10 paragraph" id="stage_shixun_<%= shixun.id %>"
style="<%= shixun.status > 1 ? "" : "cursor: pointer" %>;" onclick="<%= shixun.status > 1 ? "" : "shixun_link('#{shixun.identifier}')" %>">
style="<%= allow_shixun_exec(shixun) ? "" : "cursor: pointer" %>;" onclick="<%= allow_shixun_exec(shixun) ? "" : "shixun_link('#{shixun.identifier}')" %>">
<li class="fl li-width63">
<i class="fa fa-sort-up color-grey-c fl mt5 mr10 transform90 font-18"></i>
<span class="color-grey3 paragraph_name"><%= s_index + 1 %>-<%= index + 1 %>&nbsp;&nbsp;<%= shixun.name %></span>