Class: ThinkFeelDoEngine::Reports::ToolAccess
- Inherits:
-
Object
- Object
- ThinkFeelDoEngine::Reports::ToolAccess
- Defined in:
- app/models/think_feel_do_engine/reports/tool_access.rb
Overview
Scenario: a Participant accesses a Tool Module.
Class Method Summary collapse
Class Method Details
.all ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/think_feel_do_engine/reports/tool_access.rb', line 10 def self.all Participant.not_moderator.select(:id, :study_id).map do |participant| tool_access_events(participant).map do |tool_access| { participant_id: participant.study_id, module_title: tool_access[:title], came_from: tool_access[:source], occurred_at: tool_access[:time].iso8601 } end end.flatten end |
.columns ⇒ Object
6 7 8 |
# File 'app/models/think_feel_do_engine/reports/tool_access.rb', line 6 def self.columns %w( participant_id module_title came_from occurred_at ) end |
.tool_access_events(participant) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/think_feel_do_engine/reports/tool_access.rb', line 23 def self.tool_access_events(participant) sources = { "list-group left" => "Tool home", "list-group right" => "Tool home", "<li>" => "Nav menu", '<li class="list-group-item' => "To do list" } module_titles = BitCore::ContentModule.all.map(&:title) EventCapture::Event .where(kind: "click", participant_id: participant.id).map do |e| title = module_titles.find do |t| e.payload["buttonHtml"].include?(t) end source = sources.keys.find do |s| e.payload["parentHtml"].try(:include?, s) end next unless title && source { title: title, source: sources[source], time: e.emitted_at } end.compact end |