Class: Quby::Compiler::Entities::Questions::CheckboxQuestion
- Inherits:
-
Quby::Compiler::Entities::Question
- Object
- Item
- Quby::Compiler::Entities::Question
- Quby::Compiler::Entities::Questions::CheckboxQuestion
- Defined in:
- lib/quby/compiler/entities/questions/checkbox_question.rb
Constant Summary
Constants inherited from Quby::Compiler::Entities::Question
Quby::Compiler::Entities::Question::MARKDOWN_ATTRIBUTES
Instance Attribute Summary collapse
-
#check_all_option ⇒ Object
checkbox option that checks all other options on check.
-
#maximum_checked_allowed ⇒ Object
checkbox option that allows to select a maximum amount of checkboxes.
-
#minimum_checked_required ⇒ Object
checkbox option that forces to select a minimum amount of checkboxes.
-
#uncheck_all_option ⇒ Object
checkbox option that unchecks all other options on check.
Attributes inherited from Quby::Compiler::Entities::Question
#allow_blank_titles, #allow_duplicate_option_values, #as, #autocomplete, #col_span, #cols, #context_description, #context_free_title, #css_vars, #default_invisible, #default_position, #dependencies, #depends_on, #description, #deselectable, #disallow_bulk, #display_modes, #extra_data, #group_maximum_answered, #group_minimum_answered, #hidden, #indent, #input_data, #key, #labels, #labels_i18n_key, #lines, #opt_groups, #options, #parent, #parent_option_key, #question_group, #questionnaire, #row_span, #sbg_key, #score_header, #sets_textvar, #show_values, #size, #table, #title, #title_question, #type, #unit, #validations, #visibility_rules
Attributes inherited from Item
#presentation, #raw_content, #switch_cycle
Instance Method Summary collapse
- #answer_keys ⇒ Object
- #claimed_keys ⇒ Object
-
#initialize(key, options = {}) ⇒ CheckboxQuestion
constructor
A new instance of CheckboxQuestion.
Methods inherited from Quby::Compiler::Entities::Question
#after_build, #all_options, #context_free_title_or_title, #hidden?, #html_id, #input_keys, #key_in_use?, #maximum, #minimum, #path_str, #set_depends_on, #show_values_in_mode?, #subquestion?, #subquestions, #title_question?, #view_selector
Methods inherited from Item
Constructor Details
#initialize(key, options = {}) ⇒ CheckboxQuestion
Returns a new instance of CheckboxQuestion.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 20 def initialize(key, = {}) super @check_all_option = [:check_all_option] @uncheck_all_option = [:uncheck_all_option] @maximum_checked_allowed = [:maximum_checked_allowed] @minimum_checked_required = [:minimum_checked_required] if @check_all_option @validations << {type: :not_all_checked, check_all_key: @check_all_option, explanation: [:error_explanation]} end if @uncheck_all_option @validations << {type: :too_many_checked, uncheck_all_key: @uncheck_all_option, explanation: [:error_explanation]} end if @maximum_checked_allowed @validations << {type: :maximum_checked_allowed, maximum_checked_value: @maximum_checked_allowed, explanation: [:error_explanation]} end if @minimum_checked_required @validations << {type: :minimum_checked_required, minimum_checked_value: @minimum_checked_required, explanation: [:error_explanation]} end end |
Instance Attribute Details
#check_all_option ⇒ Object
checkbox option that checks all other options on check
9 10 11 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 9 def check_all_option @check_all_option end |
#maximum_checked_allowed ⇒ Object
checkbox option that allows to select a maximum amount of checkboxes
15 16 17 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 15 def maximum_checked_allowed @maximum_checked_allowed end |
#minimum_checked_required ⇒ Object
checkbox option that forces to select a minimum amount of checkboxes
18 19 20 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 18 def minimum_checked_required @minimum_checked_required end |
#uncheck_all_option ⇒ Object
checkbox option that unchecks all other options on check
12 13 14 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 12 def uncheck_all_option @uncheck_all_option end |
Instance Method Details
#answer_keys ⇒ Object
57 58 59 60 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 57 def answer_keys # Some options don't have a key (inner_title), they are stripped. .reject(&:inner_title?).map { |opt| opt.input_key } end |
#claimed_keys ⇒ Object
53 54 55 |
# File 'lib/quby/compiler/entities/questions/checkbox_question.rb', line 53 def claimed_keys [key] end |