think_feel_do_engine 3.17.0 → 3.17.1

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: a1aeba41ab19d644e3b61f35f1a0b5a12599b44b
4
- data.tar.gz: f5ab432d31659ccc124231abcd98314d4840238e
3
+ metadata.gz: f5570eaecc8f5761108504851cff534b4affc478
4
+ data.tar.gz: f4bf721ad515aa07b14583738741830d40b7b006
5
5
  SHA512:
6
- metadata.gz: d8999ed4d317cb5c7537d140ea008179e170e52b345d56fa3ce3db6431bf5c0f3dd92c9a0865373ede0acbcf5ac678ceb1e6a5be058a04786b5420c3cc8c1558
7
- data.tar.gz: c7f36ad1f51765a3c90befd9b873d4a0840fff5a62c56708ddf655cfb24576aebc246a857f7bcf9c3953ec520d1312fa526886dae2b5e986deb3edb8d52e15ef
6
+ metadata.gz: 49ee0eb5def617f3789c8d5070473c262cee74d83656b3ce73c8eef237d25396567129351fe8bcc41c6f75ab04972c71f16ba5b3de1c0e1be13e31dd72355f62
7
+ data.tar.gz: e1673c9bad39b0c395636811198c33b8a83ea42b693ba52b66a43057839f37f5159dc4d5629f91719092ad4ff8ac195daef5e7b57590017cfd047dcc9c7a74f6
@@ -9,6 +9,7 @@ module ThinkFeelDoEngine
9
9
 
10
10
  URL_GENERATION_ALERT = "We're sorry, the content you were looking "\
11
11
  " for couldn't be found."
12
+ FIRST_CONTENT_POSITION = 1
12
13
 
13
14
  layout "tool"
14
15
 
@@ -26,7 +27,9 @@ module ThinkFeelDoEngine
26
27
  content_position: params[:content_position]
27
28
  )
28
29
 
29
- complete_task_status(params[:module_id])
30
+ complete_task_status(params[:module_id],
31
+ params[:provider_id],
32
+ params[:content_position])
30
33
 
31
34
  render "show_content"
32
35
  rescue ActiveRecord::RecordNotFound, ActionView::Template::Error
@@ -36,6 +39,7 @@ module ThinkFeelDoEngine
36
39
  end
37
40
 
38
41
  def show_next_content
42
+ mark_engagement_completed
39
43
  @navigator.fetch_next_content
40
44
 
41
45
  if @navigator.current_module
@@ -77,19 +81,54 @@ module ThinkFeelDoEngine
77
81
 
78
82
  private
79
83
 
80
- def complete_task_status(module_id)
84
+ def last_engagment
85
+ current_participant
86
+ .active_membership
87
+ .task_statuses
88
+ .for_content_module(navigator_content_module)
89
+ .try(:last)
90
+ .try(:engagements)
91
+ .try(:last)
92
+ end
93
+
94
+ def complete_task_status(module_id, provider_id, content_id)
81
95
  content_module = BitCore::ContentModule.find(module_id)
82
96
  membership = current_participant
83
97
  .active_membership
84
98
  @task_status = membership
85
99
  .task_statuses
86
- .for_content_module(content_module)
87
- .available_by_day(membership.day_in_study)
88
- .try(:order, "start_day DESC")
89
- .try(:first)
100
+ .most_recent_for_content_module(content_module,
101
+ membership.day_in_study)
102
+ .first
103
+ if @task_status &&
104
+ (!content_specified?(provider_id, content_id) ||
105
+ first_content_slide?(content_module, provider_id, content_id))
106
+ @task_status
107
+ .engagements
108
+ .build
109
+ end
90
110
  @task_status.mark_complete unless @task_status.nil?
91
111
  end
92
112
 
113
+ def first_content_slide?(content_module, provider_id, content_id)
114
+ first_content_provider = content_module
115
+ .content_providers
116
+ .order(:position)
117
+ .first
118
+ provider_id == first_content_provider.id.to_s &&
119
+ content_id == FIRST_CONTENT_POSITION
120
+ end
121
+
122
+ def mark_engagement_completed
123
+ if navigator_content_module && last_engagment
124
+ last_engagment.update_attributes(completed_at: DateTime.current)
125
+ end
126
+ end
127
+
128
+ def content_specified?(provider_id, content_id)
129
+ !provider_id.blank? && !content_id.blank?
130
+ end
131
+
93
132
  def module_exist?
94
133
  @navigator
95
134
  .current_module
@@ -0,0 +1,7 @@
1
+ # Used to determine when a patient starts and completes learn task_statuses
2
+ class Engagement < ActiveRecord::Base
3
+ belongs_to :task_status
4
+
5
+ delegate :participant_id, to: :task_status, prefix: false
6
+ delegate :participant, to: :task_status, prefix: false
7
+ end
@@ -6,6 +6,7 @@ class TaskStatus < ActiveRecord::Base
6
6
  belongs_to :membership
7
7
  belongs_to :task
8
8
  has_one :participant, through: :membership
9
+ has_many :engagements, dependent: :destroy
9
10
 
10
11
  delegate :bit_core_content_module,
11
12
  :bit_core_content_module_id,
@@ -65,6 +66,12 @@ class TaskStatus < ActiveRecord::Base
65
66
  )
66
67
  }
67
68
 
69
+ scope :most_recent_for_content_module, lambda {|content_module, day_in_study|
70
+ for_content_module(content_module)
71
+ .available_by_day(day_in_study)
72
+ .order("start_day DESC")
73
+ }
74
+
68
75
  def provider_viz?
69
76
  try(:bit_core_content_module).try(:is_viz)
70
77
  end
@@ -29,3 +29,7 @@
29
29
  </li>
30
30
  <% end %>
31
31
  </ul>
32
+
33
+ <div class="btn-group pull-right">
34
+ <%= link_to t(:next), main_app.root_url, class: "btn btn-default" %>
35
+ </div>
@@ -10,3 +10,7 @@
10
10
  </li>
11
11
  <% end %>
12
12
  </ul>
13
+
14
+ <div class="btn-group pull-right">
15
+ <%= link_to t(:next), main_app.root_url, class: "btn btn-default" %>
16
+ </div>
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.17.0"
3
+ VERSION = "3.17.1"
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.17.0
4
+ version: 3.17.1
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-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -503,6 +503,7 @@ files:
503
503
  - app/models/delivered_message.rb
504
504
  - app/models/emotion.rb
505
505
  - app/models/emotional_rating.rb
506
+ - app/models/engagement.rb
506
507
  - app/models/experience.rb
507
508
  - app/models/gratitude_recording.rb
508
509
  - app/models/group.rb