Class: SurveyGizmo::API::Response
- Inherits:
-
Object
- Object
- SurveyGizmo::API::Response
show all
- Includes:
- Resource
- Defined in:
- lib/survey_gizmo/api/response.rb
Constant Summary
collapse
- NO_TEST_DATA =
{ field: 'istestdata', operator: '<>', value: 1 }
- ONLY_COMPLETED =
{ field: 'status', operator: '=', value: 'Complete' }
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Resource
descendants, #destroy, #inspect, #reload, #save
Class Method Details
.submitted_since_filter(time) ⇒ Object
9
10
11
12
13
14
15
|
# 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
|
Instance Method Details
#parsed_answers ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# 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?
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 ⇒ Object
34
35
36
|
# File 'lib/survey_gizmo/api/response.rb', line 34
def survey
@survey ||= Survey.first(id: survey_id)
end
|