|
|
|
@ -513,7 +513,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
# 中间需要一个过渡动画
|
|
|
|
|
# TODO: 第一次开启实训都会去判断是否是纯选择题类型,感觉做成在创建关卡的时候就判断该实训是否是纯选择题更加合适
|
|
|
|
|
def shixun_exec
|
|
|
|
|
if @shixun.opening_time.present? && @shixun.opening_time > Time.now && current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER
|
|
|
|
|
if is_shixun_opening?
|
|
|
|
|
tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
|
|
|
end
|
|
|
|
|
current_myshixun = @shixun.current_myshixun(current_user.id)
|
|
|
|
@ -522,8 +522,8 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
if current_myshixun
|
|
|
|
|
games = current_myshixun.games
|
|
|
|
|
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置
|
|
|
|
|
if games.size != min_challenges.size || games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first}
|
|
|
|
|
# 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置,实训发布前打过的实训都需要重置
|
|
|
|
|
if is_shixun_reset?(games, min_challenges, current_myshixun)
|
|
|
|
|
# 这里页面弹框要收到 当前用户myshixun的identifier.
|
|
|
|
|
tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game")
|
|
|
|
|
end
|
|
|
|
@ -803,4 +803,20 @@ private
|
|
|
|
|
tip_exception(403, "..")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 实训是否需要开启
|
|
|
|
|
def is_shixun_opening?
|
|
|
|
|
@shixun.opening_time.present? &&
|
|
|
|
|
@shixun.opening_time > Time.now &&
|
|
|
|
|
current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 实训是否需要重置
|
|
|
|
|
def is_shixun_reset?(games, min_challenges, current_myshixun)
|
|
|
|
|
# 用户在申请发布之前,是否玩过实训
|
|
|
|
|
modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1)
|
|
|
|
|
games.size != min_challenges.size ||
|
|
|
|
|
games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first} ||
|
|
|
|
|
modify_shixun
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|