|  |  | json.question_id question.id
 | 
						
						
						
							|  |  | q_positon = question.question_number
 | 
						
						
						
							|  |  | if ques_position.present?
 | 
						
						
						
							|  |  |   q_positon = ques_position
 | 
						
						
						
							|  |  | end
 | 
						
						
						
							|  |  | json.q_position q_positon
 | 
						
						
						
							|  |  | json.question_title question.question_title
 | 
						
						
						
							|  |  | json.question_type question.question_type
 | 
						
						
						
							|  |  | json.question_score question.question_score.round(1).to_s
 | 
						
						
						
							|  |  | if question.question_type <= 2  #当为选择题或判断题时,只显示选项的位置
 | 
						
						
						
							|  |  |   standard_answers_array = question.get_standard_answer_ids
 | 
						
						
						
							|  |  |   exercise_choices = choices.order("choice_position ASC")
 | 
						
						
						
							|  |  |   json.question_choices exercise_choices.each do |a|
 | 
						
						
						
							|  |  |     #TODO: 旧版本来一个题只有一个标准答案的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..)
 | 
						
						
						
							|  |  |     standard_answer_b = standard_answers_array.join("").include?(a.choice_position.to_s)
 | 
						
						
						
							|  |  |     choice_text = a.choice_text
 | 
						
						
						
							|  |  |     if question.question_type == 2
 | 
						
						
						
							|  |  |       if choice_text == "对"
 | 
						
						
						
							|  |  |         choice_text = "正确"
 | 
						
						
						
							|  |  |       end
 | 
						
						
						
							|  |  |       if choice_text == "错"
 | 
						
						
						
							|  |  |         choice_text = "错误"
 | 
						
						
						
							|  |  |       end
 | 
						
						
						
							|  |  |     end
 | 
						
						
						
							|  |  |     json.choice_id a.id
 | 
						
						
						
							|  |  |     # json.choice_text (edit_type.present? || question.question_type == 2) ? a.choice_text : "#{(index+65).chr}.#{a.choice_text}"
 | 
						
						
						
							|  |  | 
 | 
						
						
						
							|  |  |     json.choice_text choice_text
 | 
						
						
						
							|  |  |     json.choice_position a.choice_position
 | 
						
						
						
							|  |  |     json.standard_boolean standard_answer_b
 | 
						
						
						
							|  |  |   end
 | 
						
						
						
							|  |  | 
 | 
						
						
						
							|  |  |   json.standard_answer standard_answers_array
 | 
						
						
						
							|  |  |   if question.question_type == 2   #返回答案的文字
 | 
						
						
						
							|  |  |     standard_text = standard_answers_array.first.to_i == 1 ? "正确" : "错误"
 | 
						
						
						
							|  |  |   else
 | 
						
						
						
							|  |  |     if question.question_type == 1 && standard_answers_array.size == 1
 | 
						
						
						
							|  |  |       standard_answers_array = standard_answers_array.first.to_s.split("")
 | 
						
						
						
							|  |  |     end
 | 
						
						
						
							|  |  |     array_text_answer = []
 | 
						
						
						
							|  |  |     standard_answers_array.each{|a| array_text_answer.push((a.to_i+64).chr)}
 | 
						
						
						
							|  |  |     standard_text = array_text_answer.join("")
 | 
						
						
						
							|  |  |   end
 | 
						
						
						
							|  |  |   json.standard_answer_show  standard_text
 | 
						
						
						
							|  |  | 
 | 
						
						
						
							|  |  | elsif question.question_type == 3   #当为填空题时
 | 
						
						
						
							|  |  |   standard_answers_count = question.exercise_bank_standard_answers
 | 
						
						
						
							|  |  |   standard_answer_ex = standard_answers_count.pluck(:exercise_bank_choice_id).uniq
 | 
						
						
						
							|  |  |   json.is_ordered question.is_ordered
 | 
						
						
						
							|  |  |   json.multi_count standard_answer_ex.size #有几个填空
 | 
						
						
						
							|  |  |   json.standard_answer do
 | 
						
						
						
							|  |  |     json.array! standard_answer_ex.each do |a|
 | 
						
						
						
							|  |  |       s_answer_text = standard_answers_count.standard_by_ids(a).pluck(:answer_text)
 | 
						
						
						
							|  |  |       json.choice_id a
 | 
						
						
						
							|  |  |       json.answer_text s_answer_text
 | 
						
						
						
							|  |  |     end
 | 
						
						
						
							|  |  |   end
 | 
						
						
						
							|  |  | elsif question.question_type == 4   #简答题时
 | 
						
						
						
							|  |  |   json.standard_answer question.exercise_bank_standard_answers.pluck(:answer_text)
 | 
						
						
						
							|  |  | elsif question.question_type == 5
 | 
						
						
						
							|  |  |   json.shixun_id question.shixun_id
 | 
						
						
						
							|  |  |   json.shixun_name question.shixun_name.present? ? question.shixun_name : ""
 | 
						
						
						
							|  |  |   json.shixun_identifier question.shixun.identifier
 | 
						
						
						
							|  |  |   json.shixun do
 | 
						
						
						
							|  |  |     json.array! shixun_challenges do |s|
 | 
						
						
						
							|  |  |       json.challenge_id s.challenge_id
 | 
						
						
						
							|  |  |       json.challenge_position s.position
 | 
						
						
						
							|  |  |       json.challenge_name  s.challenge.subject
 | 
						
						
						
							|  |  |       json.challenge_score s.question_score.round(1).to_s
 | 
						
						
						
							|  |  |     end
 | 
						
						
						
							|  |  |   end
 | 
						
						
						
							|  |  | end |