qualtrics 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +68 -20
- data/lib/qualtrics/entity.rb +6 -0
- data/lib/qualtrics/mailer.rb +2 -7
- data/lib/qualtrics/panel.rb +8 -0
- data/lib/qualtrics/panel_import.rb +1 -0
- data/lib/qualtrics/survey.rb +16 -0
- data/lib/qualtrics/version.rb +1 -1
- data/qualtrics.gemspec +1 -0
- data/spec/fixtures/vcr_cassettes/Qualtrics_Panel/updating_in_qualtrics/adds_recipients_to_an_existing_panel.yml +110 -0
- data/spec/qualtrics/mailer_spec.rb +1 -1
- data/spec/qualtrics/panel_spec.rb +12 -0
- data/spec/spec_helper.rb +2 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be834a55988ab40b72e6965929937c2dd41a07fb
|
4
|
+
data.tar.gz: bf6d9f735800c64921ffcfe051c73c92eba99f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118bc5617532aa6fea1f706d705588cd895e1922520ac9ba3162e0e898f299e9b91d0330e5d0fb7767432749272c78152acbd67c036d57cd8447d24b9bee0e70
|
7
|
+
data.tar.gz: 7fc42f68e519f6c0e8bc494d3a45e608b850323bf9c150bdea1ee210288f0fc92b7b8002a7e19f0c4782780423528389ebf70f9ae6f2738c5f765f3082846e4e
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,35 +1,83 @@
|
|
1
|
-
|
1
|
+
[](https://codeclimate.com/github/sunkev/qualtrics) [](https://travis-ci.org/sunkev/qualtrics) [](https://coveralls.io/r/sunkev/qualtrics) [](http://badge.fury.io/rb/qualtrics)
|
2
2
|
|
3
|
-
|
3
|
+
# Qualtrics
|
4
4
|
|
5
|
-
|
5
|
+
A nice wrapper for the Qualtrics REST API. Currently under fast iterations.
|
6
|
+
Full functional, but may see many changes before 1.0 release.
|
7
|
+
Not recommended for production use before then.
|
6
8
|
|
7
|
-
|
9
|
+
Just add the gem.
|
8
10
|
|
9
11
|
gem 'qualtrics'
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
Set the user, token and default library id
|
10
16
|
|
11
|
-
|
17
|
+
Qualtrics.configure do |config|
|
18
|
+
config.user = ENV['QUALTRICS_USER']
|
19
|
+
config.token = ENV['QUALTRICS_TOKEN']
|
20
|
+
config.default_library_id = ENV['QUALTRICS_LIBRARY_ID']
|
21
|
+
end
|
12
22
|
|
13
|
-
|
23
|
+
## Example usage
|
14
24
|
|
15
|
-
|
25
|
+
Add/remove a panel to Qualtrics
|
16
26
|
|
17
|
-
|
27
|
+
panel = Qualtrics::Panel.new({
|
28
|
+
name: 'My first panel'
|
29
|
+
})
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
31
|
+
panel.save
|
32
|
+
panel.destroy
|
33
|
+
|
34
|
+
Add/remove recipients to panel
|
35
|
+
|
36
|
+
recipient = Qualtrics::Recipient.new({
|
37
|
+
panel_id: panel.id
|
38
|
+
})
|
39
|
+
|
40
|
+
recipient.save
|
41
|
+
recipient.delete
|
42
|
+
|
43
|
+
Retrieve all survey and messages in Qualtrics
|
44
|
+
|
45
|
+
Qualtrics::Survey.all -> returns array of Qualtrics::Survey objects
|
46
|
+
Qualtrics::Message.all
|
47
|
+
|
48
|
+
Send a survey to a panel or individual with the Mailer object
|
24
49
|
|
25
|
-
|
50
|
+
mailer = Qualtrics::Mailer.new({
|
51
|
+
from_email: 'from_email',
|
52
|
+
from_name: 'from_name',
|
53
|
+
subject: 'subject'
|
54
|
+
})
|
55
|
+
|
56
|
+
mailer.send_survey_to_individual(recipient, message, survey)
|
57
|
+
mailer.send_survey_to_panel(panel, message, survey)
|
58
|
+
|
59
|
+
Retrieve submission results if you know the Qualtrics response_qid
|
60
|
+
|
61
|
+
submission = Qualtrics::Submission.new({
|
62
|
+
id: 'response_qid',
|
63
|
+
survey_id: 'survey_id'
|
64
|
+
})
|
65
|
+
|
66
|
+
submission.raw_csv
|
67
|
+
|
68
|
+
## Interesting features
|
26
69
|
|
27
|
-
|
70
|
+
Can batch update all the recipients in a panel for efficency.
|
28
71
|
|
72
|
+
## TODO
|
73
|
+
|
74
|
+
1. Allow retrieving responses in different formats.
|
75
|
+
2. Qualtrics does not all deleting library messages, find a way to test around this.
|
76
|
+
|
29
77
|
## Contributing
|
30
78
|
|
31
|
-
1. Fork it ( https://github.com/[my-github-username]/qualtrics/fork
|
32
|
-
2.
|
33
|
-
3.
|
34
|
-
4.
|
35
|
-
|
79
|
+
1. Fork it ( https://github.com/[my-github-username]/qualtrics/fork
|
80
|
+
2. Add tests.
|
81
|
+
3. Make your feature addition or bug fix.
|
82
|
+
4. Send me a pull request.
|
83
|
+
|
data/lib/qualtrics/entity.rb
CHANGED
@@ -4,6 +4,8 @@ module Qualtrics
|
|
4
4
|
include ActiveModel::Model
|
5
5
|
include ActiveModel::Validations
|
6
6
|
|
7
|
+
QUALTRICS_POST_TIMEZONE = 'Mountain Time (US & Canada)'
|
8
|
+
|
7
9
|
def library_id=(lib_id)
|
8
10
|
@library_id = lib_id
|
9
11
|
end
|
@@ -51,5 +53,9 @@ module Qualtrics
|
|
51
53
|
def self.configuration
|
52
54
|
Qualtrics.configuration
|
53
55
|
end
|
56
|
+
|
57
|
+
def formatted_time(time)
|
58
|
+
time.utc.in_time_zone(QUALTRICS_POST_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
59
|
+
end
|
54
60
|
end
|
55
61
|
end
|
data/lib/qualtrics/mailer.rb
CHANGED
@@ -12,8 +12,6 @@ module Qualtrics
|
|
12
12
|
validates :from_name, presence: true
|
13
13
|
validates :subject, presence: true
|
14
14
|
|
15
|
-
QUALTRICS_POST_TIMEZONE = 'Mountain Time (US & Canada)'
|
16
|
-
|
17
15
|
def initialize(options={})
|
18
16
|
@send_date = options[:send_date] || post_time
|
19
17
|
@from_email = options[:from_email]
|
@@ -92,12 +90,9 @@ module Qualtrics
|
|
92
90
|
end
|
93
91
|
|
94
92
|
private
|
95
|
-
def post_time
|
96
|
-
formatted_time Time.now.utc.in_time_zone(QUALTRICS_POST_TIMEZONE)
|
97
|
-
end
|
98
93
|
|
99
|
-
def
|
100
|
-
|
94
|
+
def post_time
|
95
|
+
formatted_time Time.now
|
101
96
|
end
|
102
97
|
|
103
98
|
def create_distribution(response, survey_id, message_id)
|
data/lib/qualtrics/panel.rb
CHANGED
@@ -50,6 +50,14 @@ module Qualtrics
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
def add_recipients(recipients)
|
54
|
+
panel_import = Qualtrics::PanelImport.new({
|
55
|
+
panel: self,
|
56
|
+
recipients: recipients
|
57
|
+
})
|
58
|
+
panel_import.save
|
59
|
+
end
|
60
|
+
|
53
61
|
def destroy
|
54
62
|
response = post('deletePanel', {
|
55
63
|
'LibraryID' => library_id,
|
@@ -13,6 +13,7 @@ module Qualtrics
|
|
13
13
|
payload = headers
|
14
14
|
payload['LibraryID'] = library_id
|
15
15
|
payload['ColumnHeaders'] = 1
|
16
|
+
payload['PanelID'] = @panel.id if @panel.persisted?
|
16
17
|
file = Qualtrics::PanelImportFile.new(@recipients)
|
17
18
|
post 'importPanel', payload, File.read(file.temp_file)
|
18
19
|
true
|
data/lib/qualtrics/survey.rb
CHANGED
@@ -38,6 +38,22 @@ module Qualtrics
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def retrieve_all_raw_responses(start_date, end_date)
|
42
|
+
response = get('getLegacyResponseData', {
|
43
|
+
'SurveyID' => id,
|
44
|
+
'StartDate' => formatted_time(start_date),
|
45
|
+
'EndDate' => formatted_time(end_date),
|
46
|
+
'Format' => 'CSV',
|
47
|
+
'ExportTags' => 1
|
48
|
+
})
|
49
|
+
|
50
|
+
if response.status == 200
|
51
|
+
response.result
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
41
57
|
def self.attribute_map
|
42
58
|
{
|
43
59
|
'responses' => :responses,
|
data/lib/qualtrics/version.rb
CHANGED
data/qualtrics.gemspec
CHANGED
@@ -0,0 +1,110 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://survey.qualtrics.com/WRAPI/ControlPanel/api.php
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: Category=Great+Category&Format=JSON&LibraryID=<QUALTRICS_LIBRARY_ID>&Name=Newest+Panel&Request=createPanel&Token=<QUALTRICS_TOKEN>&User=brookesidedev%40brookeside.com&Version=2.3
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Content-Type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- Apache
|
25
|
+
Cache-Control:
|
26
|
+
- max-age=315360000
|
27
|
+
Expires:
|
28
|
+
- Sun, 09 Mar 2025 20:52:52 GMT
|
29
|
+
P3p:
|
30
|
+
- CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE", CP="CAO
|
31
|
+
DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
|
32
|
+
Servershortname:
|
33
|
+
- w634
|
34
|
+
X-Cnection:
|
35
|
+
- close
|
36
|
+
X-Edgeconnect-Midmile-Rtt:
|
37
|
+
- '10'
|
38
|
+
- '14'
|
39
|
+
X-Edgeconnect-Origin-Mex-Latency:
|
40
|
+
- '224'
|
41
|
+
- '733'
|
42
|
+
Content-Length:
|
43
|
+
- '82'
|
44
|
+
Content-Type:
|
45
|
+
- application/json
|
46
|
+
Date:
|
47
|
+
- Thu, 12 Mar 2015 20:52:52 GMT
|
48
|
+
Connection:
|
49
|
+
- keep-alive
|
50
|
+
body:
|
51
|
+
encoding: UTF-8
|
52
|
+
string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_5gMUHo4Xfog8K6F"}}'
|
53
|
+
http_version:
|
54
|
+
recorded_at: Thu, 12 Mar 2015 20:52:52 GMT
|
55
|
+
- request:
|
56
|
+
method: post
|
57
|
+
uri: https://survey.qualtrics.com/WRAPI/ControlPanel/api.php?ColumnHeaders=1&Email=3&EmbeddedData=4&ExternalData=5&FirstName=1&Format=JSON&Language=7&LastName=2&LibraryID=<QUALTRICS_LIBRARY_ID>&PanelID=ML_5gMUHo4Xfog8K6F&Request=importPanel&Token=<QUALTRICS_TOKEN>&Unsubscribed=6&User=<QUALTRICS_USER>&Version=2.3
|
58
|
+
body:
|
59
|
+
encoding: UTF-8
|
60
|
+
string: |
|
61
|
+
"FirstName","LastName","Email","EmbeddedData","ExternalData","Unsubscribed","Language"
|
62
|
+
"New","Person","example@example.com","","","",""
|
63
|
+
"Another","NewPerson","example@example.com","","","",""
|
64
|
+
headers:
|
65
|
+
User-Agent:
|
66
|
+
- Faraday v0.9.1
|
67
|
+
Content-Type:
|
68
|
+
- application/x-www-form-urlencoded
|
69
|
+
Accept-Encoding:
|
70
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
71
|
+
Accept:
|
72
|
+
- "*/*"
|
73
|
+
response:
|
74
|
+
status:
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
Server:
|
79
|
+
- Apache
|
80
|
+
Cache-Control:
|
81
|
+
- max-age=315360000
|
82
|
+
Expires:
|
83
|
+
- Sun, 09 Mar 2025 20:52:53 GMT
|
84
|
+
P3p:
|
85
|
+
- CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE", CP="CAO
|
86
|
+
DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
|
87
|
+
Servershortname:
|
88
|
+
- w202
|
89
|
+
X-Cnection:
|
90
|
+
- close
|
91
|
+
X-Edgeconnect-Midmile-Rtt:
|
92
|
+
- '10'
|
93
|
+
- '11'
|
94
|
+
X-Edgeconnect-Origin-Mex-Latency:
|
95
|
+
- '323'
|
96
|
+
- '792'
|
97
|
+
Content-Length:
|
98
|
+
- '214'
|
99
|
+
Content-Type:
|
100
|
+
- application/json
|
101
|
+
Date:
|
102
|
+
- Thu, 12 Mar 2015 20:52:53 GMT
|
103
|
+
Connection:
|
104
|
+
- keep-alive
|
105
|
+
body:
|
106
|
+
encoding: UTF-8
|
107
|
+
string: '{"Meta":{"Status":"Success","Debug":""},"Result":{"PanelID":"ML_5gMUHo4Xfog8K6F","Count":2,"IgnoredCount":0,"Recipients":{"MLRP_9BmlZ9vmPgQ9hGJ":"example@example.com","MLRP_7WlcwPHwkUYPWKx":"example@example.com"}}}'
|
108
|
+
http_version:
|
109
|
+
recorded_at: Thu, 12 Mar 2015 20:52:53 GMT
|
110
|
+
recorded_with: VCR 2.9.2
|
@@ -11,7 +11,7 @@ describe Qualtrics::Mailer, :vcr do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'has a default send date' do
|
14
|
-
send_date = Time.now.utc.in_time_zone(Qualtrics::
|
14
|
+
send_date = Time.now.utc.in_time_zone(Qualtrics::Entity::QUALTRICS_POST_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
15
15
|
mailer = Qualtrics::Mailer.new({})
|
16
16
|
expect(mailer.send_date).to eq(send_date)
|
17
17
|
end
|
@@ -77,4 +77,16 @@ describe Qualtrics::Panel, :vcr => true do
|
|
77
77
|
panel.save
|
78
78
|
expect(Qualtrics::Panel.all.map{|p| p.id}).to include(panel.id)
|
79
79
|
end
|
80
|
+
|
81
|
+
context 'updating in qualtrics' do
|
82
|
+
it 'adds recipients to an existing panel' do
|
83
|
+
panel.save
|
84
|
+
expect(panel.persisted?).to be true
|
85
|
+
recipients = [
|
86
|
+
Qualtrics::Recipient.new(email: 'example@example.com', first_name: 'New', last_name: 'Person'),
|
87
|
+
Qualtrics::Recipient.new(email: 'example@example.com', first_name: 'Another', last_name: 'NewPerson')
|
88
|
+
]
|
89
|
+
expect(panel.add_recipients(recipients)).to be true
|
90
|
+
end
|
91
|
+
end
|
80
92
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qualtrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: configatron
|
@@ -165,6 +165,20 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: coveralls
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
168
182
|
description: Client for Qualtrics API with Faraday
|
169
183
|
email:
|
170
184
|
- sunkev@brandeis.edu
|
@@ -176,6 +190,7 @@ files:
|
|
176
190
|
- ".env.example"
|
177
191
|
- ".gitignore"
|
178
192
|
- ".rspec"
|
193
|
+
- ".travis.yml"
|
179
194
|
- Gemfile
|
180
195
|
- LICENSE.txt
|
181
196
|
- README.md
|
@@ -215,6 +230,7 @@ files:
|
|
215
230
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/destroys_a_panel_that_returns_true_when_successful.yml
|
216
231
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/raises_an_error_when_you_attempt_to_save_an_already_presisted_panel.yml
|
217
232
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/retrieves_an_array_of_all_panels_in_a_library.yml
|
233
|
+
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/updating_in_qualtrics/adds_recipients_to_an_existing_panel.yml
|
218
234
|
- spec/fixtures/vcr_cassettes/Qualtrics_PanelImport/transmits_to_qualtrics.yml
|
219
235
|
- spec/fixtures/vcr_cassettes/Qualtrics_Recipient/creating_to_qualtrics/persists_to_qualtrics.yml
|
220
236
|
- spec/fixtures/vcr_cassettes/Qualtrics_Recipient/creating_to_qualtrics/populates_the_recipient_id_when_successful.yml
|
@@ -286,6 +302,7 @@ test_files:
|
|
286
302
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/destroys_a_panel_that_returns_true_when_successful.yml
|
287
303
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/raises_an_error_when_you_attempt_to_save_an_already_presisted_panel.yml
|
288
304
|
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/retrieves_an_array_of_all_panels_in_a_library.yml
|
305
|
+
- spec/fixtures/vcr_cassettes/Qualtrics_Panel/updating_in_qualtrics/adds_recipients_to_an_existing_panel.yml
|
289
306
|
- spec/fixtures/vcr_cassettes/Qualtrics_PanelImport/transmits_to_qualtrics.yml
|
290
307
|
- spec/fixtures/vcr_cassettes/Qualtrics_Recipient/creating_to_qualtrics/persists_to_qualtrics.yml
|
291
308
|
- spec/fixtures/vcr_cassettes/Qualtrics_Recipient/creating_to_qualtrics/populates_the_recipient_id_when_successful.yml
|