newyslclassrooms
daiao 5 years ago
parent b9ad459a9d
commit a6e05b9451

@ -70,6 +70,8 @@ module ApplicationHelper
# shixun开启挑战对应的行为名及url
def task_operation_url current_myshixun, shixun
return ["开启挑战", "/shixuns/#{shixun.identifier}/shixun_exec"] unless current_user.logged?
if current_myshixun.blank?
name = shixun.status == 0 ? "模拟实战" : "开启挑战"
url = "/shixuns/#{shixun.identifier}/shixun_exec"

@ -210,8 +210,9 @@ class Shixun < ApplicationRecord
end
# 当前用户开启的实训
def current_myshixun(user_id)
myshixuns.find_by(user_id: user_id)
def current_myshixun(user)
return nil unless user.logged?
myshixuns.find_by(user_id: user.id)
end
# 实训技术平台
@ -264,7 +265,7 @@ class Shixun < ApplicationRecord
# 实训关卡的总分(由于大部分是实践题,因此没关联查choose表)
# 提前加载问题由于选择题比较少所以几乎不会触发选择题的查询所以没必要提前载入choose_score
def all_score
self.challenges.pluck(:score).sum
self.challenges.sum(:score)
end
### fork 数量

Loading…
Cancel
Save