|
|
|
@ -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 数量
|
|
|
|
|