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.
educoder/app/views/polls/_commit_answers_result.json...

27 lines
1.2 KiB

question_vote_user = poll_votes_count(question_votes,@poll_commit_ids) #提交者中该问题的回答者人数
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
json.commit_users_count question_vote_user
json.answers do
json.array! answers do |a|
answer_users_count = poll_votes_count(a.poll_votes,@poll_commit_ids)
json.answer_text a.answer_text.nil? ? "other_choices" : a.answer_text ##
json.answer_position a.answer_position
json.answer_users_count answer_users_count #该答案的填写人数(已提交)
json.answer_percent question_vote_user.present? ? (answer_users_count.to_f / question_vote_user.to_f).round(3) : 0.0
end
end
if question_votes.find_vote_text.present?
json.vote_text question_votes.pluck(:vote_text).reject(&:blank?) #问题的回答是否有用户手动输入的内容
end
end