class SurveyGizmo::API::Response
Constants
- NO_TEST_DATA
Filters
- ONLY_COMPLETED
Public Class Methods
submitted_since_filter(time)
click to toggle source
# File lib/survey_gizmo/api/response.rb, line 9 def self.submitted_since_filter(time) { field: 'datesubmitted', operator: '>=', value: time.in_time_zone(SurveyGizmo.configuration.api_time_zone).strftime('%Y-%m-%d %H:%M:%S') } end
Public Instance Methods
parsed_answers()
click to toggle source
# File lib/survey_gizmo/api/response.rb, line 38 def parsed_answers filtered_answers = answers.select do |k, v| next false unless v.is_a?(FalseClass) || v.present? # Strip out "Other" answers that don't actually have the "other" text (they come back as two responses - one # for the "Other" option_id, and then a whole separate response for the text given as an "Other" response. if /\[question\((?<question_id>\d+)\),\s*option\((?<option_id>\d+)\)\]/ =~ k !answers.keys.any? { |key| key =~ /\[question\((#{question_id})\),\s*option\("(#{option_id})-other"\)\]/ } elsif /\[question\((?<question_id>\d+)\)\]/ =~ k !answers.keys.any? { |key| key =~ /\[question\((#{question_id})\),\s*option\("\d+-other"\)\]/ } else true end end filtered_answers.map do |k, v| Answer.new(children_params.merge(key: k, value: v, answer_text: v, submitted_at: submitted_at)) end end
survey()
click to toggle source
# File lib/survey_gizmo/api/response.rb, line 34 def survey @survey ||= Survey.first(id: survey_id) end