newyslclassrooms
daiao 5 years ago
parent 518ee3aa32
commit 3cf27da3dc

@ -164,7 +164,7 @@ class ChallengesController < ApplicationController
#@challenges = @shixun.challenges.joins(join_sql).select(base_columns) #@challenges = @shixun.challenges.joins(join_sql).select(base_columns)
@challenges = @shixun.challenges.fields_for_list @challenges = @shixun.challenges.includes(:games).fields_for_list
@editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员 @editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员
@user = current_user @user = current_user
@shixun.increment!(:visits) @shixun.increment!(:visits)

@ -142,12 +142,12 @@ class Challenge < ApplicationRecord
# 关卡用户通关数 # 关卡用户通关数
def user_passed_count def user_passed_count
games.where(status: 2).count games.map{|g| g.status == 2}.count
end end
# 关卡用户正在挑战的人数 # 关卡用户正在挑战的人数
def playing_count def playing_count
games.where(status: [0, 1]).count games.map{|g| g.status == 0 || g.status == 1}.count
end end
def last_challenge def last_challenge

Loading…
Cancel
Save