Commit e3d3ff1cc470e6573ed467a619e6915ced937788

Authored by Pius Uzamere
1 parent 77fdd1a7

changes to vote recording

app/controllers/prompts_controller.rb
@@ -60,7 +60,7 @@ class PromptsController < InheritedResources::Base @@ -60,7 +60,7 @@ class PromptsController < InheritedResources::Base
60 raise "need to specify either ':left' or ':right' as a direction" 60 raise "need to specify either ':left' or ':right' as a direction"
61 end 61 end
62 62
63 - @prompt.choices.each {|c| c.score = c.compute_score; c.save!} 63 + @prompt.choices.each(&:compute_score!)
64 respond_to do |format| 64 respond_to do |format|
65 if successful 65 if successful
66 format.xml { render :xml => @question.picked_prompt.to_xml(:methods => [:left_choice_text, :right_choice_text, :left_choice_id, :right_choice_id]), :status => :ok } 66 format.xml { render :xml => @question.picked_prompt.to_xml(:methods => [:left_choice_text, :right_choice_text, :left_choice_id, :right_choice_id]), :status => :ok }
app/models/user.rb
@@ -32,7 +32,7 @@ class User < ActiveRecord::Base @@ -32,7 +32,7 @@ class User < ActiveRecord::Base
32 def record_vote(visitor_identifier, prompt, ordinality) 32 def record_vote(visitor_identifier, prompt, ordinality)
33 visitor = visitors.find_or_create_by_identifier(visitor_identifier) 33 visitor = visitors.find_or_create_by_identifier(visitor_identifier)
34 visitor.vote_for!(prompt, ordinality) 34 visitor.vote_for!(prompt, ordinality)
35 - prompt.choices.each {|c| c.score = c.compute_score; c.save!} 35 + #prompt.choices.each {|c| c.compute_score; c.save!}
36 end 36 end
37 37
38 def record_skip(visitor_identifier, prompt) 38 def record_skip(visitor_identifier, prompt)