Sha256: ecb2dafd580fb904079636b5cead82b2cab31350919d12f6e2845383070e9c97

Contents?: true

Size: 899 Bytes

Versions: 8

Compression:

Stored size: 899 Bytes

Contents

require "cat_engine/response"
require "cat_engine/question"

module StudyEngine
  class Answer < ActiveRecord::Base
    belongs_to :result

    def question
      CatEngine::Question.new(id: question_id, promis_id: question_promis_id, context: question_context, title: question_title, responses: [])
    end

    def question= value
      self.response = value.selected_response
      value.each_pair do |key, value|
        if key == :response_before
          self.response_before = value
        else
          send :"question_#{key}=", value
        end
      end
    end

    def response
      CatEngine::Response.new(id: response_id, promis_id: response_promis_id, before: response_before, title: response_title)
    end

    def response= value
      value.each_pair do |key, value|
        send :"response_#{key}=", value
      end
    end

    attr_accessor :question_responses
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
study_engine-0.3.1 app/models/study_engine/answer.rb
study_engine-0.3.0 app/models/study_engine/answer.rb
study_engine-0.2.2 app/models/study_engine/answer.rb
study_engine-0.2.1 app/models/study_engine/answer.rb
study_engine-0.2.0 app/models/study_engine/answer.rb
study_engine-0.1.1 app/models/study_engine/answer.rb
study_engine-0.1.0 app/models/study_engine/answer.rb
study_engine-0.0.2 app/models/study_engine/answer.rb