Class: Decidim::Forms::Question
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Forms::Question
- Defined in:
- app/models/decidim/forms/question.rb
Overview
The data store for a Question in the Decidim::Forms component.
Constant Summary collapse
- QUESTION_TYPES =
%w(short_answer long_answer single_option multiple_option sorting matrix_single matrix_multiple).freeze
- SEPARATOR_TYPE =
"separator"- TYPES =
(QUESTION_TYPES + [SEPARATOR_TYPE]).freeze
Instance Method Summary collapse
- #mandatory_body? ⇒ Boolean
- #mandatory_choices? ⇒ Boolean
- #matrix? ⇒ Boolean
- #multiple_choice? ⇒ Boolean
- #number_of_options ⇒ Object
- #separator? ⇒ Boolean
Instance Method Details
#mandatory_body? ⇒ Boolean
35 36 37 |
# File 'app/models/decidim/forms/question.rb', line 35 def mandatory_body? mandatory? && !multiple_choice? end |
#mandatory_choices? ⇒ Boolean
39 40 41 |
# File 'app/models/decidim/forms/question.rb', line 39 def mandatory_choices? mandatory? && multiple_choice? end |
#matrix? ⇒ Boolean
27 28 29 |
# File 'app/models/decidim/forms/question.rb', line 27 def matrix? %w(matrix_single matrix_multiple).include?(question_type) end |
#multiple_choice? ⇒ Boolean
31 32 33 |
# File 'app/models/decidim/forms/question.rb', line 31 def multiple_choice? %w(single_option multiple_option sorting matrix_single matrix_multiple).include?(question_type) end |
#number_of_options ⇒ Object
43 44 45 |
# File 'app/models/decidim/forms/question.rb', line 43 def .size end |
#separator? ⇒ Boolean
47 48 49 |
# File 'app/models/decidim/forms/question.rb', line 47 def separator? question_type.to_s == SEPARATOR_TYPE end |