问卷的导出和统计结果调整

dev_daiao
cxt 5 years ago
parent 6d6925f537
commit d8a4b06ca3

@ -1409,23 +1409,29 @@ class PollsController < ApplicationController
poll_questions.each do |q| poll_questions.each do |q|
user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id) user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id)
if user_poll_votes.present? if user_poll_votes.present?
user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) if q.question_type < 3
user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?)
if user_poll_answer_ids.count > 0 if user_poll_answer_ids.count > 0
answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids)
if user_poll_answer_ids.count >1 if user_poll_answer_ids.count >1
u_answer = answer_content.pluck(:answer_text).join(";") u_answer = answer_content.pluck(:answer_text).join(";")
else
u_answer = answer_content.first&.answer_text
end
else else
u_answer = answer_content.first&.answer_text u_answer = "--"
end end
elsif user_poll_vote_texts.count > 0 else
if user_poll_vote_texts.count > 1 user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?)
u_answer = user_poll_vote_texts.join(";") if user_poll_vote_texts.count > 0
if user_poll_vote_texts.count > 1
u_answer = user_poll_vote_texts.join(";")
else
u_answer = user_poll_vote_texts.first
end
else else
u_answer = user_poll_vote_texts.first u_answer = "--"
end end
else
u_answer = "--"
end end
else else
u_answer = "--" u_answer = "--"

@ -21,7 +21,5 @@ json.question do
json.answer_percent question_vote_user.present? ? (answer_users_count.to_f / question_vote_user.to_f).round(3) : 0.0 json.answer_percent question_vote_user.present? ? (answer_users_count.to_f / question_vote_user.to_f).round(3) : 0.0
end end
end end
if question_votes.find_vote_text.present? json.vote_text question_votes.find_vote_text.present? ? question_votes.pluck(:vote_text).reject(&:blank?) : "--" #问题的回答是否有用户手动输入的内容
json.vote_text question_votes.pluck(:vote_text).reject(&:blank?) #问题的回答是否有用户手动输入的内容
end
end end
Loading…
Cancel
Save