bht_survey 0.3.0 → 0.4.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 +19 -26
- data/app/controllers/bht_survey/qualtrics_surveys_controller.rb +1 -1
- data/lib/bht_survey/qualtrics_interface.rb +9 -8
- data/lib/bht_survey/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba82037e1b058c4ecf7430289db392d0a7f5b465
|
|
4
|
+
data.tar.gz: 5de73a69ee23d588e0ea26e4f51e4884d15525c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4a0113603ff21a86fb027b7d9bf6ea548d873dac2f813e18e6647b34e1d8a2af514c25513b0e3ff99723eb0c3ce498b0edb69623e05a628d8886563de9a2035
|
|
7
|
+
data.tar.gz: cd96148fa88c863fc7d2ba6d41a9849686cc4c3006ebeca39ba1fdb17c7d375c799240f22f1f84e30bb61f3ca78260239c65c63c16e3e79efea9e94ec8d92f30
|
data/README.md
CHANGED
|
@@ -15,39 +15,32 @@ And then execute:
|
|
|
15
15
|
$ bundle
|
|
16
16
|
$ rake assets:precompile
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Development
|
|
19
19
|
|
|
20
20
|
Application Controller Code needed for workspace and status callback
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
To post status as 'in progress' override this method
|
|
34
|
-
- def process_link_clicked_event participant_id, survey_name
|
|
35
|
-
|
|
36
|
-
To open the Survey in a new tab be sure to update application.js by adding
|
|
37
|
-
- //= require qualtrics_survey
|
|
22
|
+
include QualtricsInterface (for example in helpers/shut/study_helper.rb)
|
|
23
|
+
|
|
24
|
+
Set environment variables
|
|
25
|
+
|
|
26
|
+
ENV['API_URL'} ||= 'http://api-assessment.bhtcloud.org/'
|
|
27
|
+
ENV['QUALTRICS_ID'] = 'a qualtrics api token'
|
|
28
|
+
ENV['QUALTRICS_LIBRARY'] = 'a qualtrics library id'
|
|
29
|
+
ENV['STUDY_WORKSPACE_NAME'] = 'a study name plus optional suffix like Test'
|
|
38
30
|
|
|
39
31
|
## Usage
|
|
40
32
|
|
|
41
|
-
Controller
|
|
33
|
+
Controller
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
get_participant_state participant_id, survey_name
|
|
36
|
+
- returns 'not started', 'in progress', 'responded'
|
|
37
|
+
get_participant_link(participant_id, survey_name)['unique_link']
|
|
38
|
+
- returns link to qualtrics
|
|
39
|
+
|
|
40
|
+
View Helper
|
|
41
|
+
qualtrics_link participant_id, survey_name
|
|
42
|
+
- opens the link in a new tab,
|
|
43
|
+
- calls process_link_clicked_event participant_id, survey_name
|
|
51
44
|
|
|
52
45
|
## Contributing
|
|
53
46
|
|
|
@@ -9,7 +9,7 @@ module BhtSurvey
|
|
|
9
9
|
def index
|
|
10
10
|
participant_id = params["participant_id"]
|
|
11
11
|
survey_name = params["survey_name"]
|
|
12
|
-
process_link_clicked_event participant_id, survey_name
|
|
12
|
+
#process_link_clicked_event participant_id, survey_name
|
|
13
13
|
result = get_participant_link participant_id, survey_name
|
|
14
14
|
unique_link = result['unique_link']
|
|
15
15
|
render json: {unique_link: unique_link}.to_json, status: 200
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module QualtricsInterface
|
|
2
2
|
def get_api method_url, api_conditions
|
|
3
|
-
|
|
3
|
+
url = ENV['API_URL'] || 'http://api-assessment.bhtcloud.org/'
|
|
4
|
+
connect_to_api = Faraday.new(url: url) do |faraday|
|
|
4
5
|
faraday.response :logger do | logger |
|
|
5
6
|
logger.filter(/(api_key=)(\w+)/,'\1[REMOVED]') #TODO remove the qualtics key
|
|
6
7
|
end
|
|
@@ -16,13 +17,12 @@ module QualtricsInterface
|
|
|
16
17
|
# The Account table is used for saving credentials for multiple survey developers.
|
|
17
18
|
|
|
18
19
|
def get_workspace_key
|
|
19
|
-
puts "----------------- #{@workspace}"
|
|
20
20
|
api_params = {
|
|
21
|
-
qualtrics_id:
|
|
22
|
-
qualtrics_library:
|
|
23
|
-
study_workspace_name:
|
|
21
|
+
qualtrics_id: ENV['qualtrics_id'],
|
|
22
|
+
qualtrics_library: ENV['qualtrics_library'],
|
|
23
|
+
study_workspace_name: ENV['study_workspace_name']
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
Rails.logger.debug ">>>>>>>>>>>>>>>>>>> #{api_params.inspect}"
|
|
26
26
|
result = get_api 'api/v1/study_workspace', api_params
|
|
27
27
|
session[:workspace_key] = result['response']['workspace_key']
|
|
28
28
|
end
|
|
@@ -37,8 +37,9 @@ module QualtricsInterface
|
|
|
37
37
|
states = get_participant_states participant_id
|
|
38
38
|
result = states.detect{|state|state['name'] == survey_name}
|
|
39
39
|
state = result && result['status']
|
|
40
|
-
flags = {nil => 0, 'not_started' => 0, 'in progress' => 1, 'responded' => 2}
|
|
41
|
-
flags[state] || 0
|
|
40
|
+
#flags = {nil => 0, 'not_started' => 0, 'in progress' => 1, 'responded' => 2}
|
|
41
|
+
#flags[state] || 0
|
|
42
|
+
state || 'not_started'
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def get_participant_link participant_id, survey_name
|
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.4.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-
|
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|