think_feel_do_engine 3.13.1 → 3.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58c305de820aec793aadb69da7198a9a55ae7ba8
4
- data.tar.gz: 14e0d3e93f6285dacff773c99f1312ccb2b363fa
3
+ metadata.gz: 2e52d93a1e3df886b9a314e18e7199cea8e4487d
4
+ data.tar.gz: 194f71dad591970c846e5f9a62393ed0c88eb488
5
5
  SHA512:
6
- metadata.gz: 61bfe1a0cf4290f0335de714a133be2e131eeebd8c9f4eb5bcd3f5b800330de6c592546a3d04e267fea247188a980197fee9cde56a3c64f359b88cd60a078197
7
- data.tar.gz: a55df5197e857ff4b3cb2c813d146adc93e47ab09d65dd5bb3128313f4ecfcac3df550d1590a034d3c4f3605b63820c02a69b1eceb5bfb550b8ea2ceee0d9e0c
6
+ metadata.gz: f9caa87eb111f241458a6acf0a19ee2e83dfe763a6f091abd1a62f17dbd3ff3d1aea2b2cc089c638b96cfb2ab54db3eb0ed4a896f0e146bdec311092f972c214
7
+ data.tar.gz: 75139bbc0c7ce729689fada0addf65d294520c134209e3935c96465c696c6fe9a05135ff64a957d2a7745dc58101cd275e1022a9cee75ff4139ff63fd010e7c0
data/Rakefile CHANGED
@@ -25,7 +25,11 @@ end
25
25
 
26
26
  require "jshintrb/jshinttask"
27
27
  Jshintrb::JshintTask.new :jshint do |t|
28
- t.pattern = %w( spec/dummy/spec/javascripts/**/*.js app/assets/javascripts/think_feel_do_engine/**/draw_graphs.js )
28
+ t.pattern = %w(
29
+ spec/dummy/spec/javascripts/**/*.js
30
+ app/assets/javascripts/think_feel_do_engine/**/draw_graphs.js
31
+ app/assets/javascripts/think_feel_do_engine/feel/create_emotional_ratings.js
32
+ )
29
33
  t.options = :defaults
30
34
  t.globals = ["$".to_sym, :spyOn, :afterEach, :beforeEach, :describe, :expect, :it, :jasmine, :sc, :Graph, :appendDateRange, :columnChart, :d3, :moment]
31
35
  end
@@ -0,0 +1,44 @@
1
+ (function() {
2
+ 'use strict';
3
+
4
+ sc.createEmotionalRating = function(options) {
5
+ var $tr = $(options.rows_of_emotions[options.index]);
6
+ var rating = $tr.find('input:checked').val();
7
+
8
+ function successCallback() {
9
+ rateEmotion(options);
10
+ }
11
+
12
+ options.index = options.index + 1;
13
+ if (rating) {
14
+ $.ajax({
15
+ type: 'post',
16
+ url: options.post_path,
17
+ data: {
18
+ emotional_rating: {
19
+ emotion_id: $tr.data('emotionId'),
20
+ is_positive: $tr.data('isPositive'),
21
+ participant_id: options.participant_id,
22
+ rating: rating
23
+ }
24
+ },
25
+ async: true,
26
+ dataType: 'script',
27
+ success: successCallback,
28
+ error: errorCallback
29
+ });
30
+ } else {
31
+ rateEmotion(options);
32
+ }
33
+ };
34
+
35
+ function errorCallback() {}
36
+
37
+ function rateEmotion(options) {
38
+ if (options.count === 0 || options.count === options.index) {
39
+ options._window.location = options.redirect_path;
40
+ } else {
41
+ sc.createEmotionalRating(options);
42
+ }
43
+ }
44
+ })();
@@ -9,6 +9,8 @@ module ThinkFeelDoEngine
9
9
  before_action :authenticate_user!, :set_arm,
10
10
  :set_content_modules, :set_slideshows
11
11
 
12
+ PROVIDER_NOT_FOUND = "The slide you are looking for no longer exists."
13
+
12
14
  def index
13
15
  authorize! :index, BitCore::ContentProvider
14
16
  @content_providers = BitCore::ContentProvider.all
@@ -16,10 +18,14 @@ module ThinkFeelDoEngine
16
18
 
17
19
  def show
18
20
  authorize! :show, BitCore::ContentProvider
19
- @content_provider = find_content_provider
20
-
21
- if @content_provider.source_content_id
22
- @slideshow = @content_provider.source_content
21
+ begin
22
+ @content_provider = find_content_provider
23
+
24
+ if @content_provider.source_content_id
25
+ @slideshow = @content_provider.source_content
26
+ end
27
+ rescue ActiveRecord::RecordNotFound
28
+ redirect_to main_app.root_path, alert: PROVIDER_NOT_FOUND
23
29
  end
24
30
  end
25
31
 
@@ -71,12 +71,7 @@ module ThinkFeelDoEngine
71
71
  end
72
72
 
73
73
  def show
74
- if @slideshow.has_table_of_contents? &&
75
- FIRST_SLIDE_POSITION == @slide.position
76
- render "think_feel_do_engine/slides/"
77
- else
78
- render "think_feel_do_engine/slides/show"
79
- end
74
+ render "think_feel_do_engine/slides/show"
80
75
  end
81
76
 
82
77
  def edit
@@ -0,0 +1,95 @@
1
+ module ContentProviders
2
+ module Emotions
3
+ # Allows participants to record all of yesterday's emotions
4
+ class NewYesterdayProvider < BitCore::ContentProvider
5
+ Description = Struct.new(:name, :is_positive)
6
+ Rating = Struct.new(:description, :value)
7
+
8
+ def render_current(options)
9
+ context = options.view_context
10
+ participant = options.participant
11
+
12
+ context.render(
13
+ template: "think_feel_do_engine/emotions/new_yesterday",
14
+ locals: {
15
+ create_path: context.participant_data_path,
16
+ emotional_ratings: emotional_ratings(participant),
17
+ participant: participant,
18
+ ratings: ratings
19
+ })
20
+ end
21
+
22
+ def data_attributes
23
+ [
24
+ :emotion_id,
25
+ :is_positive,
26
+ :participant_id,
27
+ :rating
28
+ ]
29
+ end
30
+
31
+ def data_class_name
32
+ "EmotionalRating"
33
+ end
34
+
35
+ def emotional_ratings(participant)
36
+ descriptions.map do |description|
37
+ participant
38
+ .emotional_ratings
39
+ .build(
40
+ emotion: emotions(participant)
41
+ .find_or_create_by!(name: description.name),
42
+ is_positive: description.is_positive)
43
+ end
44
+ end
45
+
46
+ def show_nav_link?
47
+ false
48
+ end
49
+
50
+ private
51
+
52
+ def descriptions
53
+ [
54
+ Description.new("amused, fun-loving", true),
55
+ Description.new("angry, irritated, frustrated", false),
56
+ Description.new("anxious, scared", false),
57
+ Description.new("awe, wonder, inspiration", true),
58
+ Description.new("bored", false),
59
+ Description.new("contempt, score, disdain", false),
60
+ Description.new("content", false),
61
+ Description.new("disgusted", false),
62
+ Description.new("embarrassed", false),
63
+ Description.new("excited, eager, enthusiastic", true),
64
+ Description.new("grateful", true),
65
+ Description.new("guilty", false),
66
+ Description.new("happy", true),
67
+ Description.new("hatred, disgust, suspicion", false),
68
+ Description.new("hopeful, optimistic", true),
69
+ Description.new("interested", true),
70
+ Description.new("lonely, rejected", false),
71
+ Description.new("love, closeness, trust", true),
72
+ Description.new("proud, confident", true),
73
+ Description.new("sad", false),
74
+ Description.new("stressed, overwhelmed", false),
75
+ Description.new("sympathy, compassion", true),
76
+ Description.new("relieved", true)
77
+ ]
78
+ end
79
+
80
+ def emotions(participant)
81
+ @emotions ||= participant.emotions
82
+ end
83
+
84
+ def ratings
85
+ [
86
+ Rating.new("Not at all", 0),
87
+ Rating.new("A little bit", 1),
88
+ Rating.new("Sometimes", 2),
89
+ Rating.new("Frequently", 3),
90
+ Rating.new("All the time", 4)
91
+ ]
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,60 @@
1
+ <h1>Over the PAST DAY, how much have you felt each of these emotions?</h1>
2
+
3
+ <table class="table" style="background-color: #FFF;">
4
+ <thead>
5
+ <tr>
6
+ <th></th>
7
+ <% ratings.each do |rating| %>
8
+ <th>
9
+ <%= rating.description %>
10
+ </th>
11
+ <% end %>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% emotional_ratings.each do |emotional_rating| %>
16
+ <tr
17
+ data-emotion-id="<%= emotional_rating.emotion_id %>"
18
+ data-is-positive="<%= emotional_rating.is_positive %>">
19
+ <th>
20
+ <label for="emotional_rating_<%= emotional_rating.emotion_id %>_<%= ratings.first.value %>">
21
+ <%= emotional_rating.name %>
22
+ </label>
23
+ </th>
24
+ <% ratings.each do |rating| %>
25
+ <td>
26
+ <input
27
+ id="emotional_rating_<%= emotional_rating.emotion_id %>_<%= rating.value %>"
28
+ name="emotional_rating_<%= emotional_rating.emotion_id %>"
29
+ type="radio"
30
+ value="<%= rating.value %>">
31
+ </td>
32
+ <% end %>
33
+ </tr>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
37
+
38
+ <div class="btn-toolbar">
39
+ <%= submit_tag t(:next), class: "btn btn-primary", id: "submit_emotions" %>
40
+ </div>
41
+
42
+ <script type="text/javascript">
43
+ $(document).on("page:change", function() {
44
+ $('#submit_emotions').on('click', function() {
45
+ var $rows_of_emotions = $('table.table tbody tr');
46
+ var count = $rows_of_emotions.length;
47
+ var options = {
48
+ rows_of_emotions: $rows_of_emotions,
49
+ index: 0,
50
+ count: count,
51
+ participant_id: '<%= current_participant.id %>',
52
+ post_path: '<%= create_path %>',
53
+ redirect_path: '<%= main_app.root_path %>',
54
+ _window: window
55
+ };
56
+
57
+ sc.createEmotionalRating(options);
58
+ });
59
+ });
60
+ </script>
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.13.1"
3
+ VERSION = "3.14.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: think_feel_do_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.1
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Carty-Fickes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -349,6 +349,7 @@ files:
349
349
  - app/assets/javascripts/think_feel_do_engine/dateWrapper.js
350
350
  - app/assets/javascripts/think_feel_do_engine/devise/passwords/edit.js.erb
351
351
  - app/assets/javascripts/think_feel_do_engine/event_capture/init.js
352
+ - app/assets/javascripts/think_feel_do_engine/feel/create_emotional_ratings.js
352
353
  - app/assets/javascripts/think_feel_do_engine/feel/draw_graphs.js
353
354
  - app/assets/javascripts/think_feel_do_engine/feel/emotion_mood_viz.js
354
355
  - app/assets/javascripts/think_feel_do_engine/feel/emotions.js
@@ -459,6 +460,7 @@ files:
459
460
  - app/models/content_providers/create_activity.rb
460
461
  - app/models/content_providers/current_modules/index_provider.rb
461
462
  - app/models/content_providers/edit_past_feel_provider.rb
463
+ - app/models/content_providers/emotions/new_yesterday_provider.rb
462
464
  - app/models/content_providers/evaluate_thoughts_provider.rb
463
465
  - app/models/content_providers/experiences/index_provider.rb
464
466
  - app/models/content_providers/experiences/new_provider.rb
@@ -680,6 +682,7 @@ files:
680
682
  - app/views/think_feel_do_engine/emotions/_form.html.erb
681
683
  - app/views/think_feel_do_engine/emotions/index.html.erb
682
684
  - app/views/think_feel_do_engine/emotions/new_current.html.erb
685
+ - app/views/think_feel_do_engine/emotions/new_yesterday.html.erb
683
686
  - app/views/think_feel_do_engine/experiences/index_provider.html.erb
684
687
  - app/views/think_feel_do_engine/experiences/new_provider.html.erb
685
688
  - app/views/think_feel_do_engine/gratitude_recordings/index_provider.html.erb