Ruby wrapper for Qualtrics REST ControlPanel API version 3.0. API Documents/Play Ground
Add this line to your application's Gemfile:
gem 'qualtrics_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install qualtrics_api
QualtricsAPI.configure do |config|
config.api_token = "YOUR_QUALTRICS_API_KEY"
end
To get all your surveys:
QualtricsAPI.surveys.fetch
# => #<QualtricsAPI::SurveyCollection:0x007fcb72cce350 ....>
You can also add a scopeId:
QualtricsAPI.surveys.fetch(scope_id: "someOwnerIdMaybe")
# => #<QualtricsAPI::SurveyCollection:0x007fcb72adaf21 ....>
After you have received results, you can search for a survey by id:
survey = QualtricsAPI.surveys.find("surveyIdHere")
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
or just:
survey = QualtricsAPI.surveys["surveyIdHere"]
# => #<QualtricsAPI::Survey:0x007fcb724f9468 @id="surveyIdHere" ...>
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"
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!)
export = QualtricsAPI.response_exports["someExportID"]
# => #<QualtricsAPI::ResponseExport:0x007fcb742e4e50 ....>
export.status
=> "99.99999%"
To get all the panels:
QualtricsAPI.panels.fetch
# => #<QualtricsAPI::PanelCollection:0x007f8769aae2c0 ....>
After you have received results, you can search for a panel by id:
panel = QualtricsAPI.panels.find("panelIdHere")
# => #<QualtricsAPI::Panel:0x007f876906f278 @id="panelIdHere" ...>
or just:
panel = QualtricsAPI.panels["panelIdHere"]
# => #<QualtricsAPI::Panel:0x007f876906f278 @id="panelIdHere" ...>
To add panel members to a panel:
panel = QualtricsAPI.panels.fetch["panelIdHere"]
members = [QualtricsAPI::PanelMember.new(first_name: 'John', last_name: 'Doe', email: '[email protected]')]
panel.members.create(members)
=> #<QualtricsAPI::PanelImport:0x007fb7db984668 ...>
and update athe status of panel import:
members = [QualtricsAPI::PanelMember.new(first_name: 'John', last_name: 'Doe', email: '[email protected]')]
panel_import = panel.members.create(members)
=> #<QualtricsAPI::PanelImport:0x007fb7db984668 ...>
panel_import.status
=> "99.99999%"
panel_import.update_status
panel_import.status
=> "100.0%"
- 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