fix ntu ga survey export
This commit is contained in:
parent
82988a2029
commit
89dda76f60
|
@ -232,7 +232,9 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
@survey = ::Survey.find(params[:id])
|
||||
@chart_data, @survey_questions, @survey_answers = @survey.generate_chart_data
|
||||
|
||||
csv = CSV.generate do |csv|
|
||||
head = 'EF BB BF'.split(' ').map{|a|a.hex.chr}.join()
|
||||
|
||||
csv = CSV.generate(csv = head) do |csv|
|
||||
row = []
|
||||
@survey_questions.each do |question|
|
||||
row << question.title
|
||||
|
@ -277,7 +279,7 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
@survey_questions.each do |question|
|
||||
if question.type == ::SurveyQuestion::Radiogroup
|
||||
options = Hash[question.survey_question_options.collect{|o| [ o.id.to_s, o.name ] }]
|
||||
row << Hash[answer[question.id.to_s].map {|o, g| [options[o], g]}]
|
||||
row << Hash[answer[question.id.to_s].map {|o, g| [options[o], g]}] if !answer[question.id.to_s].blank?
|
||||
else
|
||||
row << answer[question.id.to_s]
|
||||
end
|
||||
|
@ -289,11 +291,16 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.csv do
|
||||
response.headers["Content-Type"] = "text/csv; charset=big5"
|
||||
render :text => csv.encode('Big5')
|
||||
end
|
||||
format.html
|
||||
format.csv { send_data csv }
|
||||
end
|
||||
|
||||
# respond_to do |format|
|
||||
# format.csv do
|
||||
# response.headers["Content-Type"] = "text/csv; charset=big5"
|
||||
# render :text => csv.encode('Big5')
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def set_answers
|
||||
|
|
Loading…
Reference in New Issue