You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.2 KiB
29 lines
1.2 KiB
json.question do
|
|
json.id question.id
|
|
json.question_number question.question_number
|
|
json.question_title question.question_title
|
|
json.question_type question.question_type
|
|
json.is_necessary question.is_necessary
|
|
if question.question_type == 2
|
|
json.max_choices question.max_choices
|
|
json.min_choices question.min_choices
|
|
end
|
|
if question.question_type == 2 || question.question_type == 1 # 选择题
|
|
# vote_text_id = votes.find_vote_text.pluck(:poll_answer_id) # 其他选项的输入
|
|
# vote_choose_answer = votes.pluck(:poll_answer_id).reject(&:blank?) - vote_text_id
|
|
vote_choose_answer = votes.pluck(:poll_answer_id).reject(&:blank?)
|
|
json.answers do
|
|
json.array! answers do | a|
|
|
vote_choose_boolean = vote_choose_answer.include?(a.id) ? true : false
|
|
json.answer_id a.id
|
|
json.answer_position a.answer_position
|
|
json.answer_text a.answer_text.nil? ? "other_choices" : a.answer_text
|
|
json.answer_boolean vote_choose_boolean #判断用户的回答是否为该答案
|
|
end
|
|
end
|
|
json.poll_answer_ids vote_choose_answer
|
|
end
|
|
if votes.find_vote_text.present?
|
|
json.poll_vote_texts votes.pluck(:vote_text).reject(&:blank?).first
|
|
end
|
|
end |