Sha256: 11af427fd62864152c224a7bf2cee65f443f17760a45831a7a63376a36b697e8
Contents?: true
Size: 787 Bytes
Versions: 4
Compression:
Stored size: 787 Bytes
Contents
module Helena class QuestionGroup include Helena::Concerns::ApplicationModel include Mongoid::Orderable belongs_to :version has_many :questions, inverse_of: :question_group, class_name: 'Helena::Question', dependent: :destroy, autosave: true orderable scope: :version field :title, type: String field :allow_to_go_back, type: Boolean def question_codes questions.map { |question| [question.code] + question.sub_questions.map(&:code) }.flatten end def question_texts questions.map { |question| [question.code, question.question_text] + subquestion_texts(question) }.flatten end def subquestion_texts(question) question.sub_questions.map { |sub_question| [sub_question.code, sub_question.text] } end end end
Version data entries
4 entries across 4 versions & 1 rubygems