think_feel_do_engine 3.12.9 → 3.13.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/app/controllers/think_feel_do_engine/navigator_controller.rb +22 -5
- data/app/helpers/think_feel_do_engine/tasks_helper.rb +1 -1
- data/app/models/available_content_module.rb +21 -0
- data/app/models/content_providers/current_modules/index_provider.rb +56 -0
- data/app/models/membership.rb +7 -0
- data/app/models/task_status.rb +32 -11
- data/app/views/think_feel_do_engine/current_modules/index.html.erb +19 -0
- data/app/views/think_feel_do_engine/learn/lessons_index.html.erb +1 -1
- data/lib/think_feel_do_engine/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9447779076494b47bf120de758af87edc143f4
|
4
|
+
data.tar.gz: c27cbe732bbcfd29d29663bfadec457eadcacf0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1acc06e132534b5f98fc39eb90697aaa358e109b9c8405701bbac641f1061302fcdf16e67a9e2f199f9d20b33d122f1822f2af1fee312a2f2ebbfb25f01b68b0
|
7
|
+
data.tar.gz: c7bd1e6be19e7f61cbd0f5da8936ab6b91a1a38c732d2a2c0a70c2705f6c20462bec9cd3f2ef505b6dcb1df9642e4542a716fa5540dada710c844e520d76b28e
|
@@ -7,6 +7,9 @@ module ThinkFeelDoEngine
|
|
7
7
|
include Concerns::NavigatorEnabled
|
8
8
|
before_action :authenticate_participant!, :instantiate_navigator
|
9
9
|
|
10
|
+
URL_GENERATION_ALERT = "We're sorry, the content you were looking "\
|
11
|
+
" for couldn't be found."
|
12
|
+
|
10
13
|
layout "tool"
|
11
14
|
|
12
15
|
def show_context
|
@@ -32,11 +35,16 @@ module ThinkFeelDoEngine
|
|
32
35
|
def show_next_content
|
33
36
|
mark_engagement_completed
|
34
37
|
@navigator.fetch_next_content
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
if @navigator.current_module
|
40
|
+
redirect_to navigator_location_path(
|
41
|
+
module_id: @navigator.current_module.try(:id),
|
42
|
+
provider_id: @navigator.current_content_provider
|
43
|
+
.try(:id),
|
44
|
+
content_position: @navigator.content_position)
|
45
|
+
else
|
46
|
+
next_content_not_found
|
47
|
+
end
|
40
48
|
end
|
41
49
|
|
42
50
|
def show_previous_content
|
@@ -106,5 +114,14 @@ module ThinkFeelDoEngine
|
|
106
114
|
.arm
|
107
115
|
.bit_core_tools.find_by_type("Tools::Home")
|
108
116
|
end
|
117
|
+
|
118
|
+
def next_content_not_found
|
119
|
+
Raven.capture_message "URL Generation error in NavigatorController",
|
120
|
+
extra: {
|
121
|
+
participant_id: current_participant.try(:id),
|
122
|
+
params: params
|
123
|
+
} if defined?(Raven)
|
124
|
+
redirect_to main_app.root_path, alert: URL_GENERATION_ALERT
|
125
|
+
end
|
109
126
|
end
|
110
127
|
end
|
@@ -41,10 +41,31 @@ class AvailableContentModule < ActiveRecord::Base
|
|
41
41
|
where has_didactic_content: false
|
42
42
|
end
|
43
43
|
|
44
|
+
def self.for_current_week(membership)
|
45
|
+
study_week_number = membership.week_in_study
|
46
|
+
membership_start_date = membership.start_date
|
47
|
+
available_on = arel_table[:available_on]
|
48
|
+
|
49
|
+
for_participant(membership.participant)
|
50
|
+
.where(
|
51
|
+
available_on
|
52
|
+
.lt(membership_start_date + study_week_number.weeks)
|
53
|
+
.and(
|
54
|
+
available_on
|
55
|
+
.gteq(membership_start_date + (study_week_number - 1).weeks)))
|
56
|
+
end
|
57
|
+
|
44
58
|
def self.is_terminated_on(date)
|
45
59
|
where(arel_table[:terminates_on].lt(date))
|
46
60
|
end
|
47
61
|
|
62
|
+
def self.for_past_weeks(membership)
|
63
|
+
for_participant(membership.participant)
|
64
|
+
.where(
|
65
|
+
arel_table[:available_on]
|
66
|
+
.lt(membership.start_date + (membership.week_in_study - 1).weeks))
|
67
|
+
end
|
68
|
+
|
48
69
|
def self.is_not_terminated_on(date)
|
49
70
|
where(arel_table[:terminates_on].eq(nil)
|
50
71
|
.or(arel_table[:terminates_on].gteq(date)))
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module ContentProviders
|
2
|
+
module CurrentModules
|
3
|
+
# Provides a set of links to other ContentProviders.
|
4
|
+
class IndexProvider < BitCore::ContentProvider
|
5
|
+
def render_current(options)
|
6
|
+
participant = options.participant
|
7
|
+
context = options.view_context
|
8
|
+
|
9
|
+
context.render(
|
10
|
+
template: "think_feel_do_engine/current_modules/index",
|
11
|
+
locals: {
|
12
|
+
content_modules: content_modules(options),
|
13
|
+
current_practice_modules: current_practice_modules(options),
|
14
|
+
past_practice_modules: past_practice_modules(options),
|
15
|
+
membership: context
|
16
|
+
.view_membership(participant, participant.active_group)
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_nav_link?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def content_modules(options)
|
27
|
+
participant = options.participant
|
28
|
+
arm_id = participant.active_group.arm_id
|
29
|
+
tool = BitCore::Tool
|
30
|
+
.find_by_arm_id_and_title(arm_id, options.app_context)
|
31
|
+
|
32
|
+
@content_modules ||=
|
33
|
+
AvailableContentModule
|
34
|
+
.for_participant(participant)
|
35
|
+
.for_tool(tool)
|
36
|
+
.available_by(Date.current)
|
37
|
+
.excludes_module(bit_core_content_module_id)
|
38
|
+
.latest_duplicate
|
39
|
+
end
|
40
|
+
|
41
|
+
def current_practice_modules(options)
|
42
|
+
participant = options.participant
|
43
|
+
|
44
|
+
content_modules(options)
|
45
|
+
.for_current_week(participant.active_membership)
|
46
|
+
end
|
47
|
+
|
48
|
+
def past_practice_modules(options)
|
49
|
+
participant = options.participant
|
50
|
+
|
51
|
+
content_modules(options)
|
52
|
+
.for_past_weeks(participant.active_membership)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/app/models/membership.rb
CHANGED
@@ -59,6 +59,13 @@ class Membership < ActiveRecord::Base
|
|
59
59
|
.by_position
|
60
60
|
end
|
61
61
|
|
62
|
+
def ordered_task_status_ids
|
63
|
+
task_statuses
|
64
|
+
.joins(:task)
|
65
|
+
.order("tasks.release_day ASC")
|
66
|
+
.ids
|
67
|
+
end
|
68
|
+
|
62
69
|
def incomplete_tasks
|
63
70
|
available_task_statuses
|
64
71
|
.incomplete_by_day(day_in_study)
|
data/app/models/task_status.rb
CHANGED
@@ -22,17 +22,6 @@ class TaskStatus < ActiveRecord::Base
|
|
22
22
|
.where(tasks: { bit_core_content_module_id: ids })
|
23
23
|
}
|
24
24
|
|
25
|
-
# To Do: should this be renamed or removed?
|
26
|
-
# Is this being used anymore?
|
27
|
-
scope :available_for_learning, lambda { |membership|
|
28
|
-
joins(:task, task: :bit_core_content_module)
|
29
|
-
.by_position
|
30
|
-
.where(
|
31
|
-
arel_table[:start_day]
|
32
|
-
.lteq(membership.day_in_study)
|
33
|
-
)
|
34
|
-
}
|
35
|
-
|
36
25
|
scope :completed, -> { where(arel_table[:completed_at].not_eq(nil)) }
|
37
26
|
|
38
27
|
scope :incomplete, -> { where(arel_table[:completed_at].eq(nil)) }
|
@@ -67,6 +56,22 @@ class TaskStatus < ActiveRecord::Base
|
|
67
56
|
)
|
68
57
|
}
|
69
58
|
|
59
|
+
def accessible?
|
60
|
+
available_for_learning_on <= Date.today
|
61
|
+
end
|
62
|
+
|
63
|
+
def completed?
|
64
|
+
completed_at.present?
|
65
|
+
end
|
66
|
+
|
67
|
+
def previous_completed?
|
68
|
+
return true if is_first?
|
69
|
+
self
|
70
|
+
.class
|
71
|
+
.find_by_id(membership_task_status_ids[index_for_membership - 1])
|
72
|
+
.completed?
|
73
|
+
end
|
74
|
+
|
70
75
|
def provider_viz?
|
71
76
|
try(:bit_core_content_module).try(:is_viz)
|
72
77
|
end
|
@@ -91,4 +96,20 @@ class TaskStatus < ActiveRecord::Base
|
|
91
96
|
def available_for_learning_on
|
92
97
|
membership.start_date + release_day - 1
|
93
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def index_for_membership
|
103
|
+
membership_task_status_ids
|
104
|
+
.find_index(id)
|
105
|
+
end
|
106
|
+
|
107
|
+
def is_first?
|
108
|
+
index_for_membership.zero?
|
109
|
+
end
|
110
|
+
|
111
|
+
def membership_task_status_ids
|
112
|
+
membership
|
113
|
+
.ordered_task_status_ids
|
114
|
+
end
|
94
115
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% if (description = content_modules.first.try(:bit_core_tool).try(:description)) %>
|
2
|
+
<% content_for(:tool_description) { sanitize(description).gsub(/\n/, "<br><br>").html_safe } %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :left do %>
|
6
|
+
<div class="list-group left">
|
7
|
+
<% current_practice_modules.each do |m| %>
|
8
|
+
<%= task_status_link(available_module: m, icon: "", membership: membership) %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% content_for :right do %>
|
14
|
+
<div class="list-group right">
|
15
|
+
<% past_practice_modules.each do |m| %>
|
16
|
+
<%= task_status_link(available_module: m, icon: "", membership: membership) %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -31,7 +31,7 @@
|
|
31
31
|
<% else %>
|
32
32
|
<% tasks[:tasks].each do |ts| %>
|
33
33
|
<% release_date = ts.available_for_learning_on %>
|
34
|
-
<% if
|
34
|
+
<% if ts.accessible? %>
|
35
35
|
<span class="list-group-item task-status enabled">
|
36
36
|
<%= link_to create_task_path(ts), class: "task-status", id: "task-status-#{ ts.id }", data: { :"task-status-id" => ts.id } do %>
|
37
37
|
<h4 class="list-group-item-heading">
|
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.
|
4
|
+
version: 3.13.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-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -455,6 +455,7 @@ files:
|
|
455
455
|
- app/models/content_providers/augmented_thoughts_table_provider.rb
|
456
456
|
- app/models/content_providers/awake_period_form.rb
|
457
457
|
- app/models/content_providers/create_activity.rb
|
458
|
+
- app/models/content_providers/current_modules/index_provider.rb
|
458
459
|
- app/models/content_providers/edit_past_feel_provider.rb
|
459
460
|
- app/models/content_providers/evaluate_thoughts_provider.rb
|
460
461
|
- app/models/content_providers/experiences/index_provider.rb
|
@@ -672,6 +673,7 @@ files:
|
|
672
673
|
- app/views/think_feel_do_engine/coach/site_messages/index.html.erb
|
673
674
|
- app/views/think_feel_do_engine/coach/site_messages/new.html.erb
|
674
675
|
- app/views/think_feel_do_engine/coach/site_messages/show.html.erb
|
676
|
+
- app/views/think_feel_do_engine/current_modules/index.html.erb
|
675
677
|
- app/views/think_feel_do_engine/emotions/_emotion_coach_view.html.erb
|
676
678
|
- app/views/think_feel_do_engine/emotions/_form.html.erb
|
677
679
|
- app/views/think_feel_do_engine/emotions/index.html.erb
|