Skip to content
Browse files

fixed bug in question histogram code -- histograms counts now reflect…

… number of responses per option, not per word occurance for multiple choice questions
  • Loading branch information...
1 parent 3bdba52 commit 7fd41415491d26b9ae9d200011862a876275991f @yuletide yuletide committed Jun 18, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 app/models/question.rb
View
7 app/models/question.rb
@@ -41,9 +41,10 @@ def response_histogram
puts "response histogramming time: #{responses}"
if r.length > 0
# create an array with all the words from all the responses
- words = r.map{ |rs| rs.response.downcase.split(/[^A-Za-z0-9\-]/)}.flatten
- unless self.options.empty?
- words.map!{ |w| self.get_matching_option(w) }
+ if self.options.empty?
+ words = r.map{ |rs| rs.response.downcase.split(/[^A-Za-z0-9\-]/)}.flatten
+ else
+ words = r.map{ |rs| self.get_matching_option(rs.response) }
end
# reduce the words array to a set of word => frequency pairs

0 comments on commit 7fd4141

Please sign in to comment.
Something went wrong with that request. Please try again.