Module: ThinkFeelDoEngine::TasksHelper

Defined in:
app/helpers/think_feel_do_engine/tasks_helper.rb

Overview

Used to display asterisks if tasks and tools have been assigned to a group and to hide unassigned links

Instance Method Summary collapse

Instance Method Details

#create_task_path(task_status) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 52

def create_task_path(task_status)
  think_feel_do_engine.navigator_location_path(
    module_id: task_status
               .bit_core_content_module_id,
    provider_id: task_status
                 .bit_core_content_module
                 .content_providers
                 .find_by_position(1)
                 .id,
    content_position: 1
  )
end

#current_provider_skippable?(navigator) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 40

def current_provider_skippable?(navigator)
  provider = navigator.current_content_provider
  mod = navigator.current_module
  membership = current_participant.active_membership

  # If the TaskStatus was *just* marked complete, this is the first time
  # viewing the ContentProvider, so we should consider it incomplete.
  ContentProviderDecorator.fetch(provider)
                          .is_skippable_after_first_viewing &&
    task_status(membership, mod).completed_at < Time.current - 5.minutes
end

#task_status(membership, content_module) ⇒ Object



6
7
8
9
10
11
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 6

def task_status(membership, content_module)
  membership.available_task_statuses
            .for_content_module(content_module)
            .order(start_day: :asc)
            .last
end


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 17

def task_status_link(available_module:, icon:, membership:)
  available_module = TaskStatusLink.new(
    available_module: available_module,
    icon: icon,
    membership: membership
  )
  link_to available_module.name,
          think_feel_do_engine.navigator_location_path(
            module_id: available_module.id
          ), class: available_module.css_class,
             data: available_module.data_attributes,
             id: available_module.css_id
end

#task_status_viz(task_status) ⇒ Object



13
14
15
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 13

def task_status_viz(task_status)
  task_status.title
end

#todays_lesson(task_status, response) ⇒ Object



35
36
37
38
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 35

def todays_lesson(task_status, response)
  membership = current_participant.membership
  response.html_safe if task_status.release_day == membership.day_in_study
end

#unread_task?(task_status) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/helpers/think_feel_do_engine/tasks_helper.rb', line 31

def unread_task?(task_status)
  !task_status.completed_at?
end