Class: ThinkFeelDoEngine::NavigatorController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ThinkFeelDoEngine::NavigatorController
- Includes:
- Concerns::NavigatorEnabled
- Defined in:
- app/controllers/think_feel_do_engine/navigator_controller.rb
Overview
Uses the Navigator to direct a participant“s flow through the site.
Constant Summary collapse
- URL_GENERATION_ALERT =
"We're sorry, the content you were looking "\ " for couldn't be found."
- FIRST_CONTENT_POSITION =
1
Constants inherited from ApplicationController
ApplicationController::CSRF_COOKIE_NAME, ApplicationController::CSRF_HEADER_NAME, ApplicationController::INACTIVE_MESSAGE, ApplicationController::ROOT_URI
Instance Method Summary collapse
- #show_context ⇒ Object
- #show_location ⇒ Object
- #show_next_content ⇒ Object
-
#show_next_provider ⇒ Object
Seek and redirect to the next content provider in order.
- #show_previous_content ⇒ Object
Methods inherited from ApplicationController
#access_denied_resource_path, #after_sign_in_path_for, #after_sign_out_path_for, #raise_not_found!, #render_not_found
Instance Method Details
#show_context ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 17 def show_context context_name = params[:context_name] || home_tool.try(:title) @navigator.initialize_context(context_name) render "show_content" end |
#show_location ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 24 def show_location @navigator.initialize_location( module_id: params[:module_id], provider_id: params[:provider_id], content_position: params[:content_position] ) complete_task_status(params[:module_id], params[:provider_id], params[:content_position]) render "show_content" rescue ActiveRecord::RecordNotFound, ActionView::Template::Error @navigator.initialize_context(home_tool.title) flash[:alert] = "Unable to find that module." render "show_content" end |
#show_next_content ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 42 def show_next_content mark_engagement_completed @navigator.fetch_next_content if @navigator.current_module redirect_to navigator_location_path( module_id: @navigator.current_module.try(:id), provider_id: @navigator.current_content_provider .try(:id), content_position: @navigator.content_position ) else next_content_not_found end end |
#show_next_provider ⇒ Object
Seek and redirect to the next content provider in order.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 67 def show_next_provider current_provider = @navigator.current_content_provider next_provider = current_provider while next_provider == current_provider @navigator.fetch_next_content next_provider = @navigator.current_content_provider end redirect_to navigator_location_path( module_id: @navigator.current_module.try(:id), provider_id: @navigator.current_content_provider.try(:id), content_position: @navigator.content_position ) end |
#show_previous_content ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 57 def show_previous_content @navigator.fetch_previous_content redirect_to navigator_location_path( module_id: @navigator.current_module.try(:id), provider_id: @navigator.current_content_provider.try(:id), content_position: @navigator.content_position ) end |