You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
457 B
19 lines
457 B
class Question < ApplicationRecord
|
|
belongs_to :category
|
|
|
|
validates :text, presence: true
|
|
validates :option1, presence: true
|
|
validates :option2, presence: true
|
|
validates :option3, presence: true
|
|
validates :option4, presence: true
|
|
validates :option5, presence: true
|
|
|
|
def options
|
|
[option1, option2, option3, option4, option5].map(&:downcase).map(&:strip)
|
|
end
|
|
|
|
def option_index(answer)
|
|
options.index(answer.downcase.strip)
|
|
end
|
|
end
|