mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
21 lines
526 B
Ruby
21 lines
526 B
Ruby
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
|
|
|
|
scope :for_category, -> (category) { where(category: category) }
|
|
|
|
|
|
def options
|
|
[option1, option2, option3, option4, option5].map(&:downcase).map(&:strip)
|
|
end
|
|
|
|
def option_index(answer)
|
|
options.index(answer.downcase.strip)
|
|
end
|
|
end
|