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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c684b9b4714d3b27caf69a72e5a699383ef8ea1b
4
- data.tar.gz: 33e35080bc3b276d3cd9b6cd5d201781ddc2dbd5
3
+ metadata.gz: ba82037e1b058c4ecf7430289db392d0a7f5b465
4
+ data.tar.gz: 5de73a69ee23d588e0ea26e4f51e4884d15525c7
5
5
  SHA512:
6
- metadata.gz: 72c18d4c679891ba54a8f0ac7e0f337f0f72bb9a6d22c9b89bb58d37d6b36b31e8e0bf259c84f91d2a28d0704231a22e7ddb9b894ac24f940f67ccc5c3765b94
7
- data.tar.gz: b1d37f736e6dfaf893fd64faaaca62c1284c3c3ce568d33ef56465742b6c7e5446309a91e52a4bcb1fe75f581cd2d2087abddfc670230fcfa95332c0d200e8d1
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
- ## Usage
18
+ ## Development
19
19
 
20
20
  Application Controller Code needed for workspace and status callback
21
21
 
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
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
- 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
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
- connect_to_api = Faraday.new(url: API_URL) do |faraday|
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: @workspace['qualtrics_id'],
22
- qualtrics_library: @workspace['qualtrics_library'],
23
- study_workspace_name: @workspace['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
- puts ">>>>>>>>>>>>>>>>>>> #{api_params.inspect}"
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
@@ -1,3 +1,3 @@
1
1
  module BhtSurvey
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04-26 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler