Commit b62dbe79e39d4d7d5964523ee194478bf33371eb

Authored by Pius Uzamere
1 parent c6569df2

send the question name along with the choice to save a server roundtrip in some cases

app/controllers/choices_controller.rb
@@ -28,7 +28,7 @@ class ChoicesController < InheritedResources::Base @@ -28,7 +28,7 @@ class ChoicesController < InheritedResources::Base
28 @choice.reload 28 @choice.reload
29 @choice.compute_score! 29 @choice.compute_score!
30 @choice.reload 30 @choice.reload
31 - render :xml => @choice.to_xml(:methods => [:item_data, :wins_plus_losses])} 31 + render :xml => @choice.to_xml(:methods => [:item_data, :wins_plus_losses, :question_name])}
32 format.json { render :json => @choice.to_json(:methods => [:data])} 32 format.json { render :json => @choice.to_json(:methods => [:data])}
33 end 33 end
34 end 34 end
app/models/choice.rb
@@ -15,6 +15,10 @@ class Choice < ActiveRecord::Base @@ -15,6 +15,10 @@ class Choice < ActiveRecord::Base
15 15
16 attr_accessor :data 16 attr_accessor :data
17 17
  18 + def question_name
  19 + question.name
  20 + end
  21 +
18 def item_data 22 def item_data
19 item.data 23 item.data
20 end 24 end