From 8a1585476a4c1b73aa97528afb37429f7381d511 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 28 Aug 2017 09:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=BC=80=E5=90=AF=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 8 ++++++-- app/views/subjects/show.html.erb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e96d9eaaf..eae04490a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 # 判断当前用户是否可以开始实战 diff --git a/app/views/subjects/show.html.erb b/app/views/subjects/show.html.erb index 468809166..619724db4 100644 --- a/app/views/subjects/show.html.erb +++ b/app/views/subjects/show.html.erb @@ -33,7 +33,7 @@ <% stage.stage_shixuns.each_with_index do |stage_shixun, index| %> <% shixun = stage_shixun.shixun %>
;" onclick="<%= shixun.status > 1 ? "" : "shixun_link('#{shixun.identifier}')" %>"> + style="<%= allow_shixun_exec(shixun) ? "" : "cursor: pointer" %>;" onclick="<%= allow_shixun_exec(shixun) ? "" : "shixun_link('#{shixun.identifier}')" %>">
  • <%= s_index + 1 %>-<%= index + 1 %>  <%= shixun.name %>