Module: MobileWorkflow::Displayable::Steps::Question

Included in:
MobileWorkflow::Displayable
Defined in:
app/models/concerns/mobile_workflow/displayable/steps/question.rb

Constant Summary collapse

QUESTION_STYLES =
%i[single_choice multiple_choice].freeze

Instance Method Summary collapse

Instance Method Details

#mw_text_choice_question(question:, style:, text_choices:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/mobile_workflow/displayable/steps/question.rb', line 9

def mw_text_choice_question(question:, style:, text_choices:)
  raise 'Missing question' if question.empty?
  raise 'Text Choices should be a hash' unless text_choices.is_a?(Hash)

  validate_question_style!(style)

  text_choices_a = text_choices.map do |k, v|
    { _class: 'ORKTextChoice', exclusive: false, text: k, value: v }
  end.to_a
  { question: question,
    answerFormat: { _class: 'ORKTextChoiceAnswerFormat', style: camelcase_converter(style.to_s, first_letter: :lower),
                    textChoices: text_choices_a } }
end