bht_survey 0.2.0 → 0.3.0
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/README.md +29 -10
- data/app/assets/javascripts/qualtrics_survey.js +21 -0
- data/app/helpers/qualtrics_link_helper.rb +11 -0
- data/bht_survey.gemspec +0 -1
- data/lib/bht_survey/qualtrics_interface.rb +9 -1
- data/lib/bht_survey/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c684b9b4714d3b27caf69a72e5a699383ef8ea1b
|
|
4
|
+
data.tar.gz: 33e35080bc3b276d3cd9b6cd5d201781ddc2dbd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72c18d4c679891ba54a8f0ac7e0f337f0f72bb9a6d22c9b89bb58d37d6b36b31e8e0bf259c84f91d2a28d0704231a22e7ddb9b894ac24f940f67ccc5c3765b94
|
|
7
|
+
data.tar.gz: b1d37f736e6dfaf893fd64faaaca62c1284c3c3ce568d33ef56465742b6c7e5446309a91e52a4bcb1fe75f581cd2d2087abddfc670230fcfa95332c0d200e8d1
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# BhtSurvey
|
|
2
2
|
|
|
3
|
-
This is a
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
This is a wrapper for Faraday access to the Qualtric Interface Service. It generates the workspace key separately from individual API calls.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -15,20 +13,41 @@ gem 'bht_survey'
|
|
|
15
13
|
And then execute:
|
|
16
14
|
|
|
17
15
|
$ bundle
|
|
16
|
+
$ rake assets:precompile
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
## Usage
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
Application Controller Code needed for workspace and status callback
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
include QualtricsInterface
|
|
23
|
+
# Use API_URL to override the default API Server
|
|
24
|
+
def set_workspace
|
|
25
|
+
@user = Account.where(user: session[:user]).first
|
|
26
|
+
@workspace = {
|
|
27
|
+
'qualtrics_id' => @user.qualtrics_id,
|
|
28
|
+
'qualtrics_library' => @user.library_id,
|
|
29
|
+
'study_workspace_name' => 'Shuti-Gold-Test'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
To post status as 'in progress' override this method
|
|
34
|
+
- def process_link_clicked_event participant_id, survey_name
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
To open the Survey in a new tab be sure to update application.js by adding
|
|
37
|
+
- //= require qualtrics_survey
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
## Usage
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
Controller
|
|
42
|
+
|
|
43
|
+
get_participant_state participant_id, survey_name
|
|
44
|
+
- returns 0,1,2
|
|
45
|
+
get_participant_link(participant_id, survey_name)['unique_link']
|
|
46
|
+
- returns link to qualtrics
|
|
47
|
+
View
|
|
48
|
+
qualtrics_link participant_id, survey_name
|
|
49
|
+
- opens the link in a new tab,
|
|
50
|
+
- calls process_link_clicked_event participant_id, survey_name
|
|
32
51
|
|
|
33
52
|
## Contributing
|
|
34
53
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Open the qualtrics survey link in another tab
|
|
2
|
+
$(document).ready(function(){
|
|
3
|
+
$('.survey_link a').on('click', function(){
|
|
4
|
+
$.get({
|
|
5
|
+
url: this.href,
|
|
6
|
+
success: function(response){
|
|
7
|
+
link = response['unique_link']
|
|
8
|
+
window.open(link, '_blank')
|
|
9
|
+
},
|
|
10
|
+
dataType: 'json'
|
|
11
|
+
})
|
|
12
|
+
return false;
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
// Refresh the RICE page when focus returns to the RICE tab
|
|
16
|
+
document.addEventListener('visibilitychange', function(){
|
|
17
|
+
if (!document['hidden']) {
|
|
18
|
+
location.reload()
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module QualtricsLinkHelper
|
|
2
|
+
def qualtrics_link participant_id, survey_name, button_name=survey_name
|
|
3
|
+
html = "<div class='survey_link'><a href='"
|
|
4
|
+
html << "/qualtrics_surveys?participant_id=" +
|
|
5
|
+
participant_id.to_s + "&survey_name=" +survey_name.to_s
|
|
6
|
+
html << "'>"
|
|
7
|
+
html << button_name
|
|
8
|
+
html << " </div>"
|
|
9
|
+
html = html.html_safe
|
|
10
|
+
end
|
|
11
|
+
end
|
data/bht_survey.gemspec
CHANGED
|
@@ -32,7 +32,15 @@ module QualtricsInterface
|
|
|
32
32
|
result = get_api 'api/v1/participant_states', api_params
|
|
33
33
|
result['response']
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
def get_participant_state participant_id, survey_name
|
|
37
|
+
states = get_participant_states participant_id
|
|
38
|
+
result = states.detect{|state|state['name'] == survey_name}
|
|
39
|
+
state = result && result['status']
|
|
40
|
+
flags = {nil => 0, 'not_started' => 0, 'in progress' => 1, 'responded' => 2}
|
|
41
|
+
flags[state] || 0
|
|
42
|
+
end
|
|
43
|
+
|
|
36
44
|
def get_participant_link participant_id, survey_name
|
|
37
45
|
api_params = {workspace_key: get_workspace_key, participant_id: participant_id, assessment_name: survey_name}
|
|
38
46
|
result = get_api 'api/v1/participant_link', api_params
|
data/lib/bht_survey/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bht_survey
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jfinucane
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-04-
|
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -83,7 +83,9 @@ files:
|
|
|
83
83
|
- LICENSE.txt
|
|
84
84
|
- README.md
|
|
85
85
|
- Rakefile
|
|
86
|
+
- app/assets/javascripts/qualtrics_survey.js
|
|
86
87
|
- app/controllers/bht_survey/qualtrics_surveys_controller.rb
|
|
88
|
+
- app/helpers/qualtrics_link_helper.rb
|
|
87
89
|
- bht_survey.gemspec
|
|
88
90
|
- bin/console
|
|
89
91
|
- bin/setup
|