Skip to content

Guide: The JSON API and Exports

yoon edited this page Mar 13, 2013 · 2 revisions

TABLE OF CONTENTS

JSON

/surveys/[survey.access_code].json exports the survey definition in JSON format. See the draft survey schema

/surveys/[survey.access_code]/[response_set.access_code].json exports a response set in JSON format. See the draft response set schema

CSV

view_my_survey_path => /surveys/[survey.access_code]/[response_set.access_code].csv exports a response set in CSV format.

Or dump all response sets for a given survey via

rake surveyor:dump SURVEY_ACCESS_CODE=<access_code> [OUTPUT_DIR=<dir>] [SURVEY_VERSION=<survey_version>]

CSV is a common format for exporting statistical data. Data in CSV format can be directly imported into Excel and analyzed, as well as other "Statistical Analysis Software (SAS)":http://en.wikipedia.org/wiki/SAS_(software).

PDF support

  • Add the following lines to your Gemfile:
  gem 'pdfkit'
  gem 'wkhtmltopdf'

or on OSX:

  gem 'pdfkit'
  gem 'wkhtmltopdf-binary'
  • Add the following to your application.rb:
  config.middleware.use PDFKit::Middleware
  • Create links with :format => 'pdf' in them, for example:
  %li= link_to "PDF", view_my_survey_path(:survey_code => response_set.survey.access_code, :response_set_code => response_set.access_code, :format => 'pdf')

NEXT: Special topics