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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5489830167b8c53332b96ddbe1ce28177463ae9
4
- data.tar.gz: 96cb2ea70396e561435cd35368d922a085244be1
3
+ metadata.gz: c684b9b4714d3b27caf69a72e5a699383ef8ea1b
4
+ data.tar.gz: 33e35080bc3b276d3cd9b6cd5d201781ddc2dbd5
5
5
  SHA512:
6
- metadata.gz: '0419eb42a98681acfb110f552bd08ee6785b0c22f60d7f7937aaafd6886ac5c912804954f261a909de9c488392451484e396856632bd783d84e4c87946cf80ee'
7
- data.tar.gz: 83d9094d6b53c19e6e1b01823d01c46fb8c14c9bbdbfdfbf3db9c58d4ed143387b7000d4ab3ddff7ca06aff9e2268f51e79fa5cd77d055ea132969657f71114b
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 simple wrapper for Faraday access to the Qualtric Interface Service. It generates the workspace key separately from individual API calls.
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
- Or install it yourself as:
18
+ ## Usage
20
19
 
21
- $ gem install bht_survey
20
+ Application Controller Code needed for workspace and status callback
22
21
 
23
- ## Usage
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
- TODO: Write usage instructions here
33
+ To post status as 'in progress' override this method
34
+ - def process_link_clicked_event participant_id, survey_name
26
35
 
27
- ## Development
36
+ To open the Survey in a new tab be sure to update application.js by adding
37
+ - //= require qualtrics_survey
28
38
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+ ## Usage
30
40
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
@@ -33,5 +33,4 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.2"
35
35
  spec.add_dependency "rails", "~> 5.0"
36
-
37
36
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module BhtSurvey
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.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.2.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-24 00:00:00.000000000 Z
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