class SurveyGizmo::API::Question
Public Instance Methods
options()
click to toggle source
# File lib/survey_gizmo/api/question.rb, line 33 def options return parent_question.options.dup.each { |o| o.question_id = id } if parent_question @options ||= Option.all(children_params.merge(all_pages: true)).to_a @options.each { |o| o.attributes = children_params } end
parent_question()
click to toggle source
# File lib/survey_gizmo/api/question.rb, line 40 def parent_question return nil unless parent_question_id @parent_question ||= Question.first(survey_id: survey_id, id: parent_question_id) end
sub_question_skus()
click to toggle source
# File lib/survey_gizmo/api/question.rb, line 45 def sub_question_skus # As of 2015-12-23, the sub_question_skus attribute can either contain an array of integers if no shortname (alias) # was set for any question, or an array of [String, Integer] with the String corresponding to the subquestion # shortname and the integer corresponding to the subquestion id if at least one shortname was set. @sub_question_skus.map { |sku| sku.is_a?(Array) ? sku[1] : sku } end
sub_questions()
click to toggle source
# File lib/survey_gizmo/api/question.rb, line 52 def sub_questions @sub_questions ||= sub_question_skus.map do |sku| SurveyGizmo.configuration.logger.debug("Have to do individual load of sub question #{sku}...") subquestion = Question.first(survey_id: survey_id, id: sku) subquestion.parent_question_id = id subquestion end end
survey()
click to toggle source
# File lib/survey_gizmo/api/question.rb, line 29 def survey @survey ||= Survey.first(id: survey_id) end