16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/quby/answers/services/updates_answers.rb', line 16
def update(new_attributes = {})
save_raw_params_on_error(new_attributes) do
attribute_filter = FiltersAnswerValue.new(answer.questionnaire)
attribute_filter.filter(new_attributes).each { |name, value| answer.send("#{name}=", value) }
answer.extend AnswerValidations
answer.cleanup_input
answer.validate_answers
if answer.errors.empty?
if new_attributes["rendered_at"].present?
started_at = Time.at(new_attributes["rendered_at"].to_i)
else
started_at = nil
end
answer.mark_completed(started_at)
answer.outcome = OutcomeCalculation.new(answer).calculate
Quby.answers.update!(answer)
succeed!
else
if defined?(::Roqua::Support)
unless answer.aborted
::Roqua::Support::Errors.report(Quby::ValidationError.new(answer.errors.full_messages))
end
end
fail!
end
end
end
|