Skip to content

Instantly share code, notes, and snippets.

@mrcwinn
Created June 4, 2013 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrcwinn/5708081 to your computer and use it in GitHub Desktop.
Save mrcwinn/5708081 to your computer and use it in GitHub Desktop.
def to_csv(options={})
header_row = [
'Response ID',
'Timestamp (MM/dd/yyyy)',
'Time Taken to Complete (Seconds)',
]
self.questions.each_with_index do |q, i|
header_row << "Q#{i+1}"
end
CSV.generate(options) do |csv|
csv << ["Data Export Generated on #{DateTime.now}"]
csv << ["Survey ID #{self.uid}"]
csv << ["Survey Name #{self.title}"]
csv << []
csv << header_row
self.questions.each do |question|
question.answers.each do |answer|
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment