Class: StudyEngine::Result

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/study_engine/result.rb

Instance Method Summary collapse

Instance Method Details

#bankObject



12
13
14
# File 'app/models/study_engine/result.rb', line 12

def bank
  CatEngine::Bank.new(bank_id, history, assessment.full_history)
end

#historyObject



20
21
22
# File 'app/models/study_engine/result.rb', line 20

def history
  answers.pluck(:response_id).join(" ")
end

#nameObject



16
17
18
# File 'app/models/study_engine/result.rb', line 16

def name
  bank_id.sub(".flat","")
end

#save_answer(answer) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'app/models/study_engine/result.rb', line 24

def save_answer answer
  wrapper do # race condition could bypass validity check
    if bank.valid_answer?(answer.response_id)
      answers << answer
      update_attributes bank.to_h
      save!
    end
  end
end