Add more options for surveys

* Survey period constraints
* Add abilities
* Enforce required questions
* Update survey_submssion updated_at
* Do a full match of possible answer and user reply
This commit is contained in:
Stella Rouzi 2018-02-09 19:07:10 +02:00
parent c278e547ce
commit 683f62a27c
36 changed files with 219 additions and 74 deletions

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
class SurveyQuestion < ActiveRecord::Base
belongs_to :survey
has_many :survey_replies
has_many :survey_replies, dependent: :destroy
# Order of this list should not be changed without proper action!
enum kind: [:boolean, :choice, :string, :text, :datetime, :numeric]
@ -23,15 +25,15 @@ class SurveyQuestion < ActiveRecord::Base
end
def possible_answers=(value)
self[:possible_answers] = choice? ? value : nil
self[:possible_answers] = value if choice?
end
def min_choices=(value)
self[:min_choices] = choice? ? value : nil
self[:min_choices] = value if choice?
end
def max_choices=(value)
self[:max_choices] = choice? ? value : nil
self[:max_choices] = value if choice?
end
private