2014-10-06 05:55:25 +00:00
|
|
|
class SurveyQuestionOption
|
|
|
|
include Mongoid::Document
|
|
|
|
|
|
|
|
field :name, :localize => true
|
|
|
|
field :jump_to, :default => 0
|
2016-08-18 13:18:02 +00:00
|
|
|
field :points, :type => Integer, :default => 0
|
2021-07-08 13:31:27 +00:00
|
|
|
field :question_type, :type => Integer, :default => 0
|
|
|
|
|
|
|
|
embeds_many :level2, class_name: "SurveyQuestionOptionLevel2"
|
|
|
|
accepts_nested_attributes_for :level2, class_name: "SurveyQuestionOptionLevel2", :allow_destroy => true
|
|
|
|
|
2014-10-06 05:55:25 +00:00
|
|
|
embedded_in :survey_question
|
2021-07-08 13:31:27 +00:00
|
|
|
|
|
|
|
#def attributes()
|
|
|
|
# tmp = super()
|
|
|
|
# tmp.merge({name_translations: tmp[:name], qid: tmp[:_id].to_s})
|
|
|
|
#end
|
|
|
|
def as_json(**xargs)
|
|
|
|
res = super({:except =>:level2}.merge(xargs))
|
|
|
|
res.merge({name_translations: self.name_translations, qid: self[:_id].to_s, level2: self.level2.as_json})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def level2_radio
|
|
|
|
self.question_type==0
|
|
|
|
end
|
|
|
|
|
|
|
|
def level2_check
|
|
|
|
self.question_type==1
|
|
|
|
end
|
2014-10-06 05:55:25 +00:00
|
|
|
end
|