|
|
@ -225,18 +225,8 @@ class GamesController < ApplicationController
|
|
|
|
# GET: /tasks/:identifier/get_answer_info
|
|
|
|
# GET: /tasks/:identifier/get_answer_info
|
|
|
|
# 0 直接查看答案, 1 查看答案弹框, 2 答案详情弹框
|
|
|
|
# 0 直接查看答案, 1 查看答案弹框, 2 答案详情弹框
|
|
|
|
def get_answer_info
|
|
|
|
def get_answer_info
|
|
|
|
@challenge = @game.challenge
|
|
|
|
challenge = @game.challenge
|
|
|
|
if @challenge.st == 0
|
|
|
|
@challenge_answers = challenge.challenge_answers
|
|
|
|
@challenge_answers = @challenge.challenge_answers
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
@challenge.challenge_chooses.each do |choose|
|
|
|
|
|
|
|
|
result << {:position => choose.position, :answer => (choose.answer.blank? ? choose.standard_answer : choose.answer)}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
@challenge_answers = result
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 平台已认证的老师需要控制
|
|
|
|
# 平台已认证的老师需要控制
|
|
|
|
@power = (@identity < User::EDU_GAME_MANAGER)
|
|
|
|
@power = (@identity < User::EDU_GAME_MANAGER)
|
|
|
|
if !@power
|
|
|
|
if !@power
|
|
|
@ -259,6 +249,8 @@ class GamesController < ApplicationController
|
|
|
|
# 解锁答案
|
|
|
|
# 解锁答案
|
|
|
|
# GET: /tasks/:identifier/get_answer_info?answer_id=?
|
|
|
|
# GET: /tasks/:identifier/get_answer_info?answer_id=?
|
|
|
|
def unlock_answer
|
|
|
|
def unlock_answer
|
|
|
|
|
|
|
|
@challenge = @game.challenge
|
|
|
|
|
|
|
|
if @challenge.st == 0
|
|
|
|
@answer = ChallengeAnswer.find(params[:answer_id])
|
|
|
|
@answer = ChallengeAnswer.find(params[:answer_id])
|
|
|
|
challenge = @answer.challenge
|
|
|
|
challenge = @answer.challenge
|
|
|
|
# 解锁需要本层级的答案是否需要扣分
|
|
|
|
# 解锁需要本层级的答案是否需要扣分
|
|
|
@ -268,6 +260,12 @@ class GamesController < ApplicationController
|
|
|
|
unless current_user.grade.to_i - deduct_score > 0
|
|
|
|
unless current_user.grade.to_i - deduct_score > 0
|
|
|
|
tip_exception("您没有足够的金币")
|
|
|
|
tip_exception("您没有足够的金币")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@answer = []
|
|
|
|
|
|
|
|
@challenge.challenge_chooses.each do |choose|
|
|
|
|
|
|
|
|
@answer << {:position => choose.position, :answer => (choose.answer.blank? ? choose.standard_answer : choose.answer)}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|