Sha256: 9b85dbbf0eebfe85f67be6081edac2e75823ce410d47bd27d037e44284028b9d

Contents?: true

Size: 906 Bytes

Versions: 8

Compression:

Stored size: 906 Bytes

Contents

module MobileWorkflow
  module Displayable
    module Steps
      module Question
        QUESTION_STYLES = [:single_choice, :multiple_choice]
        
        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{|k, v| {_class: "ORKTextChoice", exclusive: false, text: k, value: v} }.to_a
          { question: question, answerFormat: { _class: "ORKTextChoiceAnswerFormat", style: camelcase_converter(style.to_s, first_letter: :lower), textChoices: text_choices_a}}
        end

        private
        
        def validate_question_style!(style)
          raise 'Unknown style' unless QUESTION_STYLES.include?(style)      
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mobile_workflow-0.10.2 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.10.1 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.10.0 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.9.0 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.8.9 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.7.9 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.7.8 app/models/concerns/mobile_workflow/displayable/steps/question.rb
mobile_workflow-0.7.7 app/models/concerns/mobile_workflow/displayable/steps/question.rb