Sha256: 268d1c9e63bf0eba996bc3cafbdd65de9f14e5c5900d8a7d3485ca40cdff2ee5
Contents?: true
Size: 983 Bytes
Versions: 4
Compression:
Stored size: 983 Bytes
Contents
# frozen_string_literal: true module MobileWorkflow module Displayable module Steps module Question QUESTION_STYLES = %i[single_choice multiple_choice].freeze 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 private def validate_question_style!(style) raise 'Unknown style' unless QUESTION_STYLES.include?(style) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems