问卷导出的统计结果:“其他”选项要标出来,多行主观题要对各小题标识出来

This commit is contained in:
cxt 2016-10-18 11:14:29 +08:00
parent 750a9c9d38
commit 8648ea605f
2 changed files with 40 additions and 8 deletions

View File

@ -705,7 +705,7 @@ class PollController < ApplicationController
sheet1[count_row + 1,0] = l(:label_poll_subtotal)
sheet1[count_row + 2,0] = l(:label_poll_proportion)
poll_question.poll_answers.each_with_index do |poll_answer,i|
sheet1[count_row, i + 1] = poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")
sheet1[count_row, i + 1] = poll_answer.answer_text == "" ? l(:label_poll_other) : poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")
sheet1[count_row + 1, i + 1] = poll_answer.poll_votes.count
sheet1[count_row + 2, i + 1] = statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)).to_s + "%"
end
@ -717,27 +717,58 @@ class PollController < ApplicationController
sheet1[count_row,0] = l(:label_poll_question_num,:num => poll_question.question_number)
sheet1[count_row,1] = poll_question.question_title
count_row += 1
if poll_question.question_type == 3
poll_question.poll_votes.each do |poll_vote|
sheet1[count_row,0] = poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")
count_row += 1
end
count_row += 1
else
count = 0
poll_question.poll_answers.reorder("answer_position asc").each_with_index do |poll_answer,i|
sheet1.row(count_row).default_format = blue
sheet1[count_row, i] = poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")
count = poll_question.poll_votes.where("poll_answer_id = #{poll_answer.id}").count > count ? poll_question.poll_votes.where("poll_answer_id = #{poll_answer.id}").count : count
poll_question.poll_votes.where("poll_answer_id = #{poll_answer.id}").each_with_index do |poll_vote, j|
sheet1[count_row + j + 1,i] = poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")
end
end
count_row = count_row + count + 2
end
end
end
sheet1.row(count_row).default_format = blue
sheet1[count_row ,0] = l(:label_bidding_user_studentname)
poll_questions.each_with_index do |poll_question, i|
sheet1[count_row ,i + 1] = poll_question.question_title
current_index = 1
poll_questions.each do |poll_question|
if poll_question.question_type == 4
poll_question.poll_answers.reorder("answer_position asc").each do |ans|
sheet1[count_row ,current_index] = poll_question.question_title + "(#{ans.answer_text})"
current_index += 1
end
else
sheet1[count_row ,current_index] = poll_question.question_title
current_index += 1
end
end
count_row += 1
@poll.users.each do |user|
sheet1[count_row ,0] = user.show_name
current_index = 1
poll_questions.each_with_index do |poll_question, i|
if poll_question.question_type == 1 || poll_question.question_type == 2
sheet1[count_row ,i + 1] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ") if poll_vote.poll_answer}.join(";")
sheet1[count_row ,current_index] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ") if poll_vote.poll_answer}.join(";")
current_index += 1
elsif poll_question.question_type == 3
sheet1[count_row ,current_index] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")}.join(";")
current_index += 1
else
sheet1[count_row ,i + 1] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/&nbsp;/," ")}.join(";")
poll_question.poll_answers.reorder("answer_position asc").each do |ans|
poll_vote = user.poll_votes.where(:poll_question_id => poll_question.id, :poll_answer_id => ans.id).first
sheet1[count_row ,current_index] = poll_vote.nil? ? "" : poll_vote.vote_text
current_index += 1
end
end
end
count_row += 1

View File

@ -2019,6 +2019,7 @@ zh:
label_poll_title: 问卷标题
label_poll_description: 问卷描述
label_poll_options: 选项
label_poll_other: 其他
label_poll_subtotal: 小计
label_poll_question_num: "第%{num}题"
label_poll_proportion: 比例