Sha256: 0397681dee9d2234749e77908192a2c76e58eca452594522139a93b92872a86b
Contents?: true
Size: 1.47 KB
Versions: 44
Compression:
Stored size: 1.47 KB
Contents
module ThinkFeelDoEngine module Reports # Scenario: a Participant accesses a Tool Module. class ToolAccess def self.columns %w( participant_id module_title came_from occurred_at ) end def self.all Participant.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 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 end end end
Version data entries
44 entries across 44 versions & 1 rubygems