QualtricsAPI
Ruby wrapper for Qualtrics REST ControlPanel API version 3.0. API Documents/Play Ground
Installation
Add this line to your application's Gemfile:
gem 'qualtrics_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install qualtrics_api
Usage
Initialize
client = QualtricsAPI.new "YOUR_QUALTRICS_API_KEY"
# => #<QualtricsAPI::Client:0x007fcb74496528 @api_token="YOUR_QUALTRICS_API_KEY">
Surveys
To get all your surveys:
client.surveys.fetch
# => #<QualtricsAPI::SurveyCollection:0x007fcb72cce350 ....>
You can also add a scopeId:
client.surveys.fetch(scope_id: "someOwnerIdMaybe")
# => #<QualtricsAPI::SurveyCollection:0x007fcb72adaf21 ....>
After you have received results, you can search for a survey by id:
survey = client.surveys.find("surveyIdHere")
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
or just:
survey = client.surveys["surveyIdHere"]
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
Export Responses From a Survey
Once you have a survey object (QualtricsAPI::Survey], you can start
an export like so:
(You can pass any supported options in ruby style!)
export_service = survey.export_responses({ start_date: "2015-03-03 11:11:10" })
# => #<QualtricsAPI::Services::ResponseExportService:0x007fcb742e4e50 ....>
or you can configure it laster...
export_service = survey.export_responses
# => #<QualtricsAPI::Services::ResponseExport:0x007fcb742e4e50 ....>
export_service.start_date = "2015-03-03 11:11:10"
(See Qualtrics API doc for a full list of options)
Then start the export:
export = export_service.start
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
Then to check the progress
export.status
# => "20.333333%"
export.completed?
# => fasle
# call again to refresh
export.status
# => "100%"
export.completed?
# => true
Once it's finished, you can get the response file URL:
export.file_url
# => "https://some.amazon.s3.com/file/path?withTimeStamps=AndOtherStuff"
Checking status on a previous response export
Each response export yeilds an id
export = survey.export_responses({ }).start
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
export.id
# => "someExportID"
You can save it somewhere in your app and check back later (if you know it's gonna take a while!)
client = QualtricsAPI.new "YOUR QUALTRICS API TOKEN"
export = client.response_exports["someExportID"]
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
export.status
=> "99.99999%"
Contributing
- Fork it ( https://github.com/pallymore/qualtrics_api/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request