think_feel_do_engine 3.19.9 → 3.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +11 -3
  3. data/app/assets/config/manifest.js +3 -0
  4. data/app/assets/javascripts/think_feel_do_engine/activities/activity_tracker.js +3 -2
  5. data/app/controllers/think_feel_do_engine/application_controller.rb +4 -3
  6. data/app/controllers/think_feel_do_engine/bit_maker/content_modules_controller.rb +4 -3
  7. data/app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb +2 -1
  8. data/app/controllers/think_feel_do_engine/bit_maker/slides_controller.rb +7 -5
  9. data/app/controllers/think_feel_do_engine/bit_maker/slideshow_anchors_controller.rb +3 -2
  10. data/app/controllers/think_feel_do_engine/bit_maker/slideshows_controller.rb +1 -0
  11. data/app/controllers/think_feel_do_engine/coach/group_dashboard_controller.rb +1 -0
  12. data/app/controllers/think_feel_do_engine/coach/memberships_controller.rb +7 -4
  13. data/app/controllers/think_feel_do_engine/coach/messages_controller.rb +2 -1
  14. data/app/controllers/think_feel_do_engine/coach/participant_activities_visualizations_controller.rb +1 -0
  15. data/app/controllers/think_feel_do_engine/coach/participant_thoughts_visualizations_controller.rb +1 -0
  16. data/app/controllers/think_feel_do_engine/coach/patient_dashboards_controller.rb +1 -0
  17. data/app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb +1 -0
  18. data/app/controllers/think_feel_do_engine/coach/received_messages_controller.rb +2 -1
  19. data/app/controllers/think_feel_do_engine/coach/sent_messages_controller.rb +1 -0
  20. data/app/controllers/think_feel_do_engine/coach/site_messages_controller.rb +1 -0
  21. data/app/controllers/think_feel_do_engine/coach_dashboard_controller.rb +1 -0
  22. data/app/controllers/think_feel_do_engine/concerns/browser_detective.rb +13 -12
  23. data/app/controllers/think_feel_do_engine/concerns/invalid_auth_token.rb +1 -0
  24. data/app/controllers/think_feel_do_engine/concerns/navigator_enabled.rb +1 -0
  25. data/app/controllers/think_feel_do_engine/keep_alive_controller.rb +1 -0
  26. data/app/controllers/think_feel_do_engine/lesson_slides_controller.rb +3 -2
  27. data/app/controllers/think_feel_do_engine/lessons_controller.rb +4 -3
  28. data/app/controllers/think_feel_do_engine/manage/groups_controller.rb +3 -2
  29. data/app/controllers/think_feel_do_engine/manage/tasks_controller.rb +1 -0
  30. data/app/controllers/think_feel_do_engine/memberships_controller.rb +1 -0
  31. data/app/controllers/think_feel_do_engine/navigator_controller.rb +7 -4
  32. data/app/controllers/think_feel_do_engine/participant_data_controller.rb +3 -2
  33. data/app/controllers/think_feel_do_engine/participants/activities_controller.rb +8 -11
  34. data/app/controllers/think_feel_do_engine/participants/assessments_controller.rb +4 -3
  35. data/app/controllers/think_feel_do_engine/participants/lessons_controller.rb +1 -0
  36. data/app/controllers/think_feel_do_engine/participants/media_access_events_controller.rb +3 -3
  37. data/app/controllers/think_feel_do_engine/participants/passwords_controller.rb +1 -0
  38. data/app/controllers/think_feel_do_engine/participants/public_slides_controller.rb +3 -2
  39. data/app/controllers/think_feel_do_engine/participants/sessions_controller.rb +1 -0
  40. data/app/controllers/think_feel_do_engine/participants/thoughts_controller.rb +4 -5
  41. data/app/controllers/think_feel_do_engine/password_entropy_bits_controller.rb +3 -1
  42. data/app/controllers/think_feel_do_engine/privacy_policies_controller.rb +1 -0
  43. data/app/controllers/think_feel_do_engine/quick_sign_ins_controller.rb +1 -0
  44. data/app/controllers/think_feel_do_engine/users/passwords_controller.rb +1 -0
  45. data/app/controllers/think_feel_do_engine/users/registrations_controller.rb +1 -0
  46. data/app/controllers/think_feel_do_engine/users/sessions_controller.rb +1 -0
  47. data/app/helpers/think_feel_do_engine/activities_helper.rb +2 -1
  48. data/app/helpers/think_feel_do_engine/application_helper.rb +2 -1
  49. data/app/helpers/think_feel_do_engine/brand_helper.rb +1 -0
  50. data/app/helpers/think_feel_do_engine/coach/activity_color_code_helper.rb +1 -0
  51. data/app/helpers/think_feel_do_engine/coach/dashboard_and_phq_table_helper.rb +6 -5
  52. data/app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb +5 -3
  53. data/app/helpers/think_feel_do_engine/coach/messages_helper.rb +3 -1
  54. data/app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb +1 -0
  55. data/app/helpers/think_feel_do_engine/coach/patient_dashboard_helper.rb +9 -8
  56. data/app/helpers/think_feel_do_engine/emotions_helper.rb +1 -0
  57. data/app/helpers/think_feel_do_engine/phq_assessment_helper.rb +1 -0
  58. data/app/helpers/think_feel_do_engine/presenters_helper.rb +1 -0
  59. data/app/helpers/think_feel_do_engine/slides_helper.rb +5 -2
  60. data/app/helpers/think_feel_do_engine/tasks_helper.rb +11 -9
  61. data/app/mailers/think_feel_do_engine/lesson_notification_mailer.rb +5 -2
  62. data/app/mailers/think_feel_do_engine/message_notifications.rb +1 -0
  63. data/app/mailers/think_feel_do_engine/site_message_mailer.rb +3 -1
  64. data/app/models/ability.rb +1 -0
  65. data/app/models/activity.rb +21 -10
  66. data/app/models/activity_type.rb +1 -0
  67. data/app/models/arm.rb +2 -2
  68. data/app/models/arm_validator.rb +3 -1
  69. data/app/models/available_content_module.rb +6 -2
  70. data/app/models/awake_period.rb +1 -0
  71. data/app/models/bit_core/slide_observer.rb +1 -0
  72. data/app/models/coach_assignment.rb +1 -0
  73. data/app/models/concerns/accessibility.rb +1 -0
  74. data/app/models/concerns/copier.rb +25 -17
  75. data/app/models/content_modules/lesson_module.rb +6 -5
  76. data/app/models/content_modules.rb +3 -2
  77. data/app/models/content_provider_decorator.rb +1 -0
  78. data/app/models/content_provider_policy.rb +1 -0
  79. data/app/models/content_providers/accomplished_activity_index_provider.rb +1 -0
  80. data/app/models/content_providers/activity_index_provider.rb +1 -0
  81. data/app/models/content_providers/augmented_thoughts_table_provider.rb +1 -0
  82. data/app/models/content_providers/awake_period_form.rb +1 -0
  83. data/app/models/content_providers/create_activity.rb +4 -3
  84. data/app/models/content_providers/edit_past_feel_provider.rb +1 -0
  85. data/app/models/content_providers/evaluate_thoughts_provider.rb +1 -0
  86. data/app/models/content_providers/fun_activity_checklist.rb +5 -4
  87. data/app/models/content_providers/harmful_thoughts_edit_form_provider.rb +1 -0
  88. data/app/models/content_providers/helpful_thoughts_index_provider.rb +1 -0
  89. data/app/models/content_providers/important_activity_checklist.rb +5 -4
  90. data/app/models/content_providers/index_past_feel_provider.rb +1 -0
  91. data/app/models/content_providers/input_new_activity_form.rb +1 -0
  92. data/app/models/content_providers/learn_lessons_index_provider.rb +5 -4
  93. data/app/models/content_providers/messages_index_provider.rb +2 -1
  94. data/app/models/content_providers/module_index_provider.rb +1 -0
  95. data/app/models/content_providers/new_complete_thought_form_provider.rb +1 -0
  96. data/app/models/content_providers/new_current_emotion_provider.rb +1 -0
  97. data/app/models/content_providers/new_current_feel_provider.rb +1 -0
  98. data/app/models/content_providers/new_harmful_thought_form_provider.rb +1 -0
  99. data/app/models/content_providers/new_message_form_provider.rb +1 -0
  100. data/app/models/content_providers/new_past_feel_provider.rb +1 -0
  101. data/app/models/content_providers/new_thought_form_provider.rb +1 -0
  102. data/app/models/content_providers/new_thoughts_form_provider.rb +1 -0
  103. data/app/models/content_providers/past_activity_form.rb +1 -0
  104. data/app/models/content_providers/past_activity_review_form.rb +1 -0
  105. data/app/models/content_providers/past_due_activities_viz.rb +1 -0
  106. data/app/models/content_providers/pleasurable_activity_index_provider.rb +1 -0
  107. data/app/models/content_providers/previous_planned_activities_provider.rb +1 -0
  108. data/app/models/content_providers/random_slide_provider.rb +1 -0
  109. data/app/models/content_providers/show_message_provider.rb +5 -3
  110. data/app/models/content_providers/thought_patterns_index_provider.rb +1 -0
  111. data/app/models/content_providers/thoughts_distortion_viz_provider.rb +1 -0
  112. data/app/models/content_providers/thoughts_table_provider.rb +1 -0
  113. data/app/models/content_providers/unhelpful_thoughts_list_provider.rb +5 -2
  114. data/app/models/content_providers/unhelpful_thoughts_reflection_provider.rb +1 -0
  115. data/app/models/content_providers/unplanned_activity_form.rb +1 -0
  116. data/app/models/content_providers/your_activities_provider.rb +4 -2
  117. data/app/models/delivered_message.rb +3 -1
  118. data/app/models/emotion.rb +3 -2
  119. data/app/models/emotional_rating.rb +1 -0
  120. data/app/models/engagement.rb +1 -0
  121. data/app/models/group.rb +2 -1
  122. data/app/models/group_metrics/weekly_activities_count.rb +1 -0
  123. data/app/models/group_metrics/weekly_comments_count.rb +1 -0
  124. data/app/models/group_metrics/weekly_count.rb +1 -0
  125. data/app/models/group_metrics/weekly_goals_count.rb +1 -0
  126. data/app/models/group_metrics/weekly_likes_count.rb +1 -0
  127. data/app/models/group_metrics/weekly_logins_count.rb +1 -0
  128. data/app/models/group_metrics/weekly_on_the_mind_statements_count.rb +1 -0
  129. data/app/models/group_metrics/weekly_thoughts_count.rb +1 -0
  130. data/app/models/media_access_event.rb +1 -0
  131. data/app/models/membership.rb +5 -3
  132. data/app/models/message.rb +1 -0
  133. data/app/models/message_sms_notification.rb +3 -1
  134. data/app/models/mood.rb +3 -1
  135. data/app/models/participant.rb +2 -1
  136. data/app/models/participant_login_event.rb +1 -0
  137. data/app/models/participant_metrics/weekly_count.rb +1 -0
  138. data/app/models/participant_metrics/weekly_logins_count.rb +1 -0
  139. data/app/models/participant_token.rb +3 -2
  140. data/app/models/phq_assessment.rb +3 -0
  141. data/app/models/phq_stepping.rb +5 -4
  142. data/app/models/phq_stepping_assessment.rb +12 -13
  143. data/app/models/planned_activity.rb +1 -0
  144. data/app/models/roles/clinician.rb +1 -0
  145. data/app/models/roles/content_author.rb +1 -0
  146. data/app/models/roles/researcher.rb +1 -0
  147. data/app/models/site_message.rb +1 -0
  148. data/app/models/slideshow_anchor.rb +2 -1
  149. data/app/models/task.rb +3 -1
  150. data/app/models/task_status.rb +4 -2
  151. data/app/models/think_feel_do_engine/addressable.rb +1 -0
  152. data/app/models/think_feel_do_engine/concerns/validate_password.rb +1 -0
  153. data/app/models/think_feel_do_engine/password_validator.rb +3 -1
  154. data/app/models/think_feel_do_engine/reports/emotional_rating.rb +1 -0
  155. data/app/models/think_feel_do_engine/reports/event.rb +3 -2
  156. data/app/models/think_feel_do_engine/reports/lesson_module.rb +4 -3
  157. data/app/models/think_feel_do_engine/reports/lesson_slide_view.rb +1 -0
  158. data/app/models/think_feel_do_engine/reports/lesson_viewing.rb +9 -8
  159. data/app/models/think_feel_do_engine/reports/login.rb +1 -0
  160. data/app/models/think_feel_do_engine/reports/messaging.rb +2 -1
  161. data/app/models/think_feel_do_engine/reports/module_page_view.rb +1 -0
  162. data/app/models/think_feel_do_engine/reports/module_session.rb +6 -5
  163. data/app/models/think_feel_do_engine/reports/patient_activity.rb +1 -0
  164. data/app/models/think_feel_do_engine/reports/patient_thought.rb +2 -1
  165. data/app/models/think_feel_do_engine/reports/phq_assessment.rb +1 -0
  166. data/app/models/think_feel_do_engine/reports/reporter.rb +2 -1
  167. data/app/models/think_feel_do_engine/reports/site_session.rb +1 -0
  168. data/app/models/think_feel_do_engine/reports/task_completion.rb +3 -2
  169. data/app/models/think_feel_do_engine/reports/tool_access.rb +1 -0
  170. data/app/models/think_feel_do_engine/reports/tool_module.rb +1 -0
  171. data/app/models/think_feel_do_engine/reports/user_agent.rb +1 -0
  172. data/app/models/think_feel_do_engine/reports/video_session.rb +1 -0
  173. data/app/models/think_feel_do_engine/reports/wai_assessment.rb +1 -0
  174. data/app/models/thought.rb +4 -2
  175. data/app/models/thought_pattern.rb +1 -0
  176. data/app/models/tool_nav_item.rb +2 -1
  177. data/app/models/tools/home.rb +1 -0
  178. data/app/models/tools/learn.rb +1 -0
  179. data/app/models/tools/messages.rb +1 -0
  180. data/app/models/tools/think.rb +1 -0
  181. data/app/models/unplanned_activities.rb +2 -2
  182. data/app/models/user.rb +1 -0
  183. data/app/models/user_role.rb +2 -1
  184. data/app/models/values/accomplishment.rb +1 -0
  185. data/app/models/values/emotional_rating.rb +1 -0
  186. data/app/models/values/mood.rb +1 -0
  187. data/app/models/values/pleasure.rb +1 -0
  188. data/app/models/wai_assessment.rb +4 -1
  189. data/app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb +1 -0
  190. data/app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb +1 -0
  191. data/app/presenters/think_feel_do_engine/media_access_event_presenter.rb +1 -0
  192. data/app/support/mood_and_emotion_visualization_service.rb +22 -25
  193. data/lib/think_feel_do_engine/engine.rb +1 -0
  194. data/lib/think_feel_do_engine/version.rb +2 -1
  195. data/lib/think_feel_do_engine.rb +1 -0
  196. metadata +20 -6
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # PHQ-9 Stepping Assessment in a well-formatted testable object
2
3
  class PhqSteppingAssessment
3
4
  attr_accessor :date, :score, :week_of_assessment,
@@ -10,18 +11,18 @@ class PhqSteppingAssessment
10
11
  # [5]the entire assessment object (first call from table)
11
12
  @date = args[0]
12
13
  @score = args[1]
13
- if args[3].nil?
14
- @week_of_assessment = find_week_of_assessment(args[2])
15
- else
16
- @week_of_assessment = args[3]
17
- end
18
- @missing_but_copied = (!args[3].nil?) ? args[4].nil? : false
19
- @missing_with_no_fallback = (!args[4].nil?) ? args[4] : false
14
+ @week_of_assessment = if args[3].nil?
15
+ find_week_of_assessment(args[2])
16
+ else
17
+ args[3]
18
+ end
19
+ @missing_but_copied = !args[3].nil? ? args[4].nil? : false
20
+ @missing_with_no_fallback = !args[4].nil? ? args[4] : false
20
21
  missing_answers_count = false
21
22
  unless args[5].nil?
22
23
  missing_answers_count = fill_in_unanswered_questions(args[5])
23
24
  end
24
- @missing_answers_count = (!args[5].nil?) ? missing_answers_count : 0
25
+ @missing_answers_count = !args[5].nil? ? missing_answers_count : 0
25
26
  end
26
27
 
27
28
  def self.convert_from_score(hash, study_start_date)
@@ -31,8 +32,7 @@ class PhqSteppingAssessment
31
32
  date,
32
33
  score,
33
34
  study_start_date
34
- )
35
- )
35
+ ))
36
36
  end
37
37
  converted_array
38
38
  end
@@ -47,8 +47,7 @@ class PhqSteppingAssessment
47
47
  nil,
48
48
  false,
49
49
  assessment
50
- )
51
- )
50
+ ))
52
51
  end
53
52
  converted_array
54
53
  end
@@ -69,7 +68,7 @@ class PhqSteppingAssessment
69
68
  private
70
69
 
71
70
  def fill_in_missing_value(question)
72
- (question.nil?) ? 1.5 : question
71
+ question.nil? ? 1.5 : question
73
72
  end
74
73
 
75
74
  def fill_in_unanswered_questions(assessment)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A planned activity is expected to take place in the future.
2
3
  class PlannedActivity < Activity
3
4
  validates :predicted_accomplishment_intensity, :predicted_pleasure_intensity,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Roles
2
3
  class Clinician
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Roles
2
3
  class ContentAuthor
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Roles
2
3
  class Researcher
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A message sent from the site to a Participant.
2
3
  class SiteMessage < ActiveRecord::Base
3
4
  belongs_to :participant
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  # Defines a relationship between a BitCore::Slideshow and a "target", which for
2
3
  # now is limited to the home screen of a Participant.
3
4
  class SlideshowAnchor < ActiveRecord::Base
4
- TARGET_NAMES = %w(home_intro)
5
+ TARGET_NAMES = %w(home_intro).freeze
5
6
 
6
7
  belongs_to :slideshow,
7
8
  class_name: "BitCore::Slideshow",
data/app/models/task.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Gives participants notifications on what needs to be completed
2
3
  class Task < ActiveRecord::Base
3
4
  belongs_to :group
@@ -97,6 +98,7 @@ class Task < ActiveRecord::Base
97
98
  TaskStatus.create!(
98
99
  membership_id: membership_id,
99
100
  start_day: day,
100
- task_id: id)
101
+ task_id: id
102
+ )
101
103
  end
102
104
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  # Holds the completion status of a task for each participant
2
3
  class TaskStatus < ActiveRecord::Base
3
4
  include Concerns::Accessibility
4
- LESSON_MODULE_TYPE = "ContentModules::LessonModule"
5
+ LESSON_MODULE_TYPE = ContentModules::LessonModule.to_s
5
6
 
6
7
  belongs_to :membership
7
8
  belongs_to :task
@@ -38,7 +39,8 @@ class TaskStatus < ActiveRecord::Base
38
39
  joins(:task, task: :bit_core_content_module)
39
40
  .where(
40
41
  BitCore::ContentModule.arel_table[:type]
41
- .eq(LESSON_MODULE_TYPE))
42
+ .eq(LESSON_MODULE_TYPE)
43
+ )
42
44
  }
43
45
 
44
46
  scope :available_by_day, lambda { |day_in_study|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  # Labels the sender and recipient of a message.
3
4
  module Addressable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "strong_password"
2
3
 
3
4
  module ThinkFeelDoEngine
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  # Users Participant and User password validations
3
4
  class PasswordValidator
@@ -41,7 +42,8 @@ module ThinkFeelDoEngine
41
42
  def token
42
43
  @token ||= Devise.token_generator.digest(
43
44
  Devise, :reset_password_token,
44
- password_token)
45
+ password_token
46
+ )
45
47
  end
46
48
 
47
49
  def valid_entropy?
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Collect metadata for all Participant Emotional Ratings.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant clicks, causes a page to render,
@@ -9,9 +10,9 @@ module ThinkFeelDoEngine
9
10
 
10
11
  def self.all
11
12
  Participant.not_moderator
12
- .select(:id, :study_id, :is_admin).map do |participant|
13
+ .select(:id, :study_id, :is_admin).map do |participant|
13
14
  EventCapture::Event.where(participant_id: participant.id)
14
- .map do |event|
15
+ .map do |event|
15
16
  {
16
17
  participant_id: participant.study_id,
17
18
  is_admin: participant.is_admin,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Shared Lesson Module behavior.
@@ -17,7 +18,7 @@ module ThinkFeelDoEngine
17
18
  path = navigator_location_path(module_id: m.id,
18
19
  provider_id: first_provider_id,
19
20
  content_position: 1)
20
- ["#{path}", m.id]
21
+ [path, m.id]
21
22
  end.compact
22
23
 
23
24
  Hash[lessons]
@@ -28,7 +29,7 @@ module ThinkFeelDoEngine
28
29
  lessons = ContentModules::LessonModule.all.map do |m|
29
30
  path = navigator_location_path(module_id: m.id)
30
31
 
31
- ["#{path}", m.id]
32
+ [path, m.id]
32
33
  end
33
34
 
34
35
  Hash[lessons]
@@ -38,7 +39,7 @@ module ThinkFeelDoEngine
38
39
 
39
40
  def navigator_location_path(options)
40
41
  ThinkFeelDoEngine::Engine.routes.url_helpers
41
- .navigator_location_path(options)
42
+ .navigator_location_path(options)
42
43
  end
43
44
  end
44
45
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant starts viewing a Slide.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant starts viewing a Lesson.
@@ -20,25 +21,25 @@ module ThinkFeelDoEngine
20
21
  lessons_default = lessons_with_default_urls
21
22
 
22
23
  Participant.not_moderator.select(:id, :study_id)
23
- .where(id: participant_ids(ids)).map do |participant|
24
+ .where(id: participant_ids(ids)).map do |participant|
24
25
  lesson_select_events =
25
26
  EventCapture::Event
26
27
  .where(participant_id: participant.id, kind: "render")
27
28
  .select(:participant_id, :emitted_at, :payload)
28
29
  .to_a.select do |e|
29
30
  lessons.keys.include?(e.current_url.gsub(URL_ROOT_RE, "")) ||
30
- lessons_default
31
- .keys.include?(e.current_url.gsub(URL_ROOT_RE, "")) ||
32
- lessons_default
33
- .keys.include?(e.current_url.gsub(URL_ROOT_RE, "")[0...-1])
31
+ lessons_default
32
+ .keys.include?(e.current_url.gsub(URL_ROOT_RE, "")) ||
33
+ lessons_default
34
+ .keys.include?(e.current_url.gsub(URL_ROOT_RE, "")[0...-1])
34
35
  end
35
36
 
36
37
  lesson_select_events.map do |e|
37
38
  lesson_id = lessons[e.current_url.gsub(URL_ROOT_RE, "")] ||
38
39
  lessons_default[e.current_url
39
- .gsub(URL_ROOT_RE, "")] ||
40
+ .gsub(URL_ROOT_RE, "")] ||
40
41
  lessons_default[e.current_url
41
- .gsub(URL_ROOT_RE, "")[0...-1]]
42
+ .gsub(URL_ROOT_RE, "")[0...-1]]
42
43
  last_page_opened = last_page_opened(e, lesson_id)
43
44
  event_hash(participant, lesson_id, e, last_page_opened)
44
45
  end
@@ -75,7 +76,7 @@ module ThinkFeelDoEngine
75
76
  lessons_with_default_path = lesson_entries_map.each.map do |lesson|
76
77
  default_lesson_url =
77
78
  lesson[0].gsub(URL_ROOT_RE, "")
78
- .gsub(DEFAULT_LESSON_MODULE_POSTFIX, "")
79
+ .gsub(DEFAULT_LESSON_MODULE_POSTFIX, "")
79
80
  [default_lesson_url, lesson[1]]
80
81
  end
81
82
  Hash[lessons_with_default_path]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant logs into the site.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Metadata for Coach-Participant messaging.
@@ -102,7 +103,7 @@ module ThinkFeelDoEngine
102
103
 
103
104
  def received_message
104
105
  @received_message ||= @recipient.received_messages
105
- .find_by_message_id(@message.id)
106
+ .find_by_message_id(@message.id)
106
107
  end
107
108
  end
108
109
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: A Participant starts using a Module page.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: A Participant starts using a Tool Module.
@@ -87,8 +88,8 @@ module ThinkFeelDoEngine
87
88
  .drop_while { |e| e.id != first_session_event.id }
88
89
  .take_while do |e|
89
90
  e.emitted_at - latest_event_time < THRESHOLD &&
90
- e.current_url.match(/modules\/#{ module_id }(\/.*)?$/) &&
91
- (latest_event_time = e.emitted_at)
91
+ e.current_url.match(/modules\/#{ module_id }(\/.*)?$/) &&
92
+ (latest_event_time = e.emitted_at)
92
93
  end
93
94
  last_event = (module_events.last || first_session_event)
94
95
 
@@ -111,9 +112,9 @@ module ThinkFeelDoEngine
111
112
  def self.is_last_module_page(url, module_id)
112
113
  # last provider within module
113
114
  last_provider = BitCore::ContentModule.find(module_id)
114
- .content_providers
115
- .order(:position)
116
- .last
115
+ .content_providers
116
+ .order(:position)
117
+ .last
117
118
 
118
119
  if last_provider.nil?
119
120
  false
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Collect metadata for each Participant Activity.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Collect metadata for all Participant Thoughts.
@@ -8,7 +9,7 @@ module ThinkFeelDoEngine
8
9
 
9
10
  def self.all
10
11
  Participant.not_moderator
11
- .select(:id, :study_id).map.map do |participant|
12
+ .select(:id, :study_id).map.map do |participant|
12
13
  participant.thoughts.map do |thought|
13
14
  {
14
15
  participant_id: participant.study_id,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: Participants complete a Phq Assessment by email.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "csv"
2
3
 
3
4
  module ThinkFeelDoEngine
@@ -14,7 +15,7 @@ module ThinkFeelDoEngine
14
15
 
15
16
  def self.file_path(name)
16
17
  Rails.application.config.reports_root_path
17
- .join("reports/#{name.to_s.scan(/[a-z]+/).join.downcase}.csv")
18
+ .join("reports/#{name.to_s.scan(/[a-z]+/).join.downcase}.csv")
18
19
  end
19
20
 
20
21
  def initialize(collector)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant is active on the site for a period of time.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant completes a Task on the assigned day.
@@ -8,11 +9,11 @@ module ThinkFeelDoEngine
8
9
 
9
10
  def self.all
10
11
  Participant.not_moderator.select(:id, :study_id)
11
- .includes(:memberships).map do |participant|
12
+ .includes(:memberships).map do |participant|
12
13
  next unless participant.active_membership
13
14
 
14
15
  TaskStatus.where(membership_id: participant.active_membership.id)
15
- .map do |task_status|
16
+ .map do |task_status|
16
17
  next unless task_status.completed_at.try(:to_date) ==
17
18
  participant.active_membership.start_date +
18
19
  task_status.start_day - 1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant accesses a Tool Module.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Helper methods for reporting on modules.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "user_agent_parser"
2
3
 
3
4
  module ThinkFeelDoEngine
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: a Participant plays a video.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module Reports
3
4
  # Scenario: Participants complete a Wai Assessment by email.
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  # A thought recorded by a Participant.
2
3
  class Thought < ActiveRecord::Base
3
4
  EFFECTS = {
4
5
  helpful: "helpful",
5
6
  harmful: "harmful",
6
7
  neither: "neither"
7
- }
8
+ }.freeze
8
9
  IDENTIFIED = "Identified"
9
10
  ASSIGNED_A_PATTERN = "Assigned a pattern to"
10
11
  RESHAPED = "Reshaped"
@@ -39,7 +40,8 @@ class Thought < ActiveRecord::Base
39
40
  scope :last_seven_days, lambda {
40
41
  where(
41
42
  arel_table[:created_at]
42
- .gteq(Time.current.advance(days: -7).beginning_of_day))
43
+ .gteq(Time.current.advance(days: -7).beginning_of_day)
44
+ )
43
45
  }
44
46
 
45
47
  scope :for_day, lambda { |time|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A classification of a Thought.
2
3
  class ThoughtPattern < ActiveRecord::Base
3
4
  has_many :thoughts, foreign_key: :pattern_id, dependent: :nullify
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  # A nav item related to a Bit Core Tool.
2
3
  class ToolNavItem
3
4
  def self.for_participant(participant)
4
5
  participant.active_group.arm.non_home_tools.order(:position)
5
- .map { |t| new(participant, t) }
6
+ .map { |t| new(participant, t) }
6
7
  end
7
8
 
8
9
  def initialize(participant, tool)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tools
2
3
  # The homepage of the application.
3
4
  class Home < BitCore::Tool
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tools
2
3
  # Tool for reading didactic content.
3
4
  class Learn < BitCore::Tool
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tools
2
3
  # A Tool for communicating with a coach or moderator.
3
4
  class Messages < BitCore::Tool
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Tools
2
3
  # Tool for showing thoughts.
3
4
  class Think < BitCore::Tool
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # A collection of Activities that have not been scheduled by a Participant.
2
3
  class UnplannedActivities
3
4
  Errors = Struct.new(:full_messages)
@@ -14,8 +15,7 @@ class UnplannedActivities
14
15
  end
15
16
 
16
17
  def build(attributes)
17
- many_attributes = case
18
- when attributes[:activity_type_ids]
18
+ many_attributes = if attributes[:activity_type_ids]
19
19
  (attributes[:activity_type_ids] || []).map do |type_id|
20
20
  { activity_type_id: type_id }
21
21
  end
data/app/models/user.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "devise"
2
3
 
3
4
  # A person with some authoritative role (a non-Participant).
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  # The assignment of a Role to a User.
2
3
  class UserRole < ActiveRecord::Base
3
4
  ROLES = [
4
5
  "Roles::Clinician",
5
6
  "Roles::Researcher",
6
7
  "Roles::ContentAuthor"
7
- ]
8
+ ].freeze
8
9
 
9
10
  belongs_to :user
10
11
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Values
2
3
  # A value that might be assigned to an Activity.
3
4
  class Accomplishment
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Values
2
3
  # Participants rate their emotion with an intensity
3
4
  class EmotionalRating
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Values
2
3
  # Users rate their mood
3
4
  class Mood
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Values
2
3
  # A value that might be assigned to an Activity.
3
4
  class Pleasure
@@ -1,10 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  # Collected responses from one Participant WAI assessment session.
2
3
  class WaiAssessment < ActiveRecord::Base
3
4
  MIN_QUESTION_SCORE = 1
4
5
  MAX_QUESTION_SCORE = 5
5
6
  QUESTION_COUNT = 12
7
+ # rubocop:disable Style/MutableConstant
6
8
  QUESTION_ATTRIBUTES = :q1, :q2, :q3, :q4, :q5, :q6, :q7, :q8, :q9, :q10, :q11,
7
9
  :q12
10
+ # rubocop:enable Style/MutableConstant
8
11
 
9
12
  belongs_to :participant
10
13
 
@@ -15,7 +18,7 @@ class WaiAssessment < ActiveRecord::Base
15
18
  private
16
19
 
17
20
  def scores_valid
18
- return unless remove_nils.length > 0
21
+ return if remove_nils.empty?
19
22
 
20
23
  if remove_nils.min < MIN_QUESTION_SCORE ||
21
24
  remove_nils.max > MAX_QUESTION_SCORE
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  # Simplifies the logic of the conditions to display a thought viz
3
4
  class HarmfulThoughtVizPresenter
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  module LessonEvent
3
4
  # Creates a presenter for the logic of the completion data partial
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ThinkFeelDoEngine
2
3
  # Simplifies the logic of the media/audio access event views.
3
4
  class MediaAccessEventPresenter