选择题查看实训答案的问题

dev_course
daiao 6 years ago
parent 716b5af39f
commit b6ccd6562c

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

@ -1,8 +1,7 @@
index = 0 index = 0
json.status 3 json.status 3
# st: 0 实践题 1 选择题 # st: 0 实践题 1 选择题
if @challenge.st == 0 json.message do
json.message do
json.array! @challenge_answers do |answer| json.array! @challenge_answers do |answer|
index += 1 index += 1
json.answer_id answer.id json.answer_id answer.id
@ -13,14 +12,7 @@ if @challenge.st == 0
json.answer_contents answer.contents json.answer_contents answer.contents
end end
end end
end
else
json.message do
json.array! @challenge_answers do |answer|
json.position answer[:postion]
json.answer_contents answer[:answer]
end
end
end end

@ -1 +1,5 @@
json.contents @answer.contents if @challenge.st == 0
json.contents @answer.contents
else
json.contents @answer
end

Loading…
Cancel
Save