aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-14 20:50:33 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-19 17:15:10 +0200
commiteb9cbe1b545e323eab650960559460641b90a953 (patch)
treee13b6c23e158311a937822afce2b36e7821903cf /app/models
parentFeature for viewing answers of recruits (diff)
downloadrecruiting-webapp-eb9cbe1b545e323eab650960559460641b90a953.tar.gz
recruiting-webapp-eb9cbe1b545e323eab650960559460641b90a953.tar.bz2
recruiting-webapp-eb9cbe1b545e323eab650960559460641b90a953.zip
Feature covering reference answers and fixes needed to pass them
Diffstat (limited to 'app/models')
-rw-r--r--app/models/answer.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb
index 2f091cd..43ce232 100644
--- a/app/models/answer.rb
+++ b/app/models/answer.rb
@@ -63,6 +63,26 @@ class Answer < ActiveRecord::Base
User.user_is_mentor_of?(acting_user, owner)
end
+ def self.update_from(params)
+ ans = Answer.find(params['id'])
+
+ if ans.class == Answer
+ update = params["answer"] || []
+ elsif ans.class == MultipleChoiceAnswer
+ params["multiple_choice_answer"] = {} unless params["multiple_choice_answer"]
+ params["multiple_choice_answer"]["options"] = params["options"].inject(Array.new){ |a, cur| a.push cur.to_i }
+ update = params["multiple_choice_answer"]
+ end
+
+ result = ans.attributes
+
+ for u in update
+ result[u[0]] = u[1]
+ end
+
+ result
+ end
+
def self.new_from(params)
if params.include? "answer"