Commit a5557a551a16c088962f33e9b7c250aff4fb9938

Authored by Luke Baker
1 parent 3dd71e9a

remove unneeded error_message += statements

Showing 1 changed file with 3 additions and 7 deletions   Show diff stats
lib/tasks/test_api.rake
@@ -255,7 +255,6 @@ namespace :test_api do @@ -255,7 +255,6 @@ namespace :test_api do
255 end 255 end
256 256
257 def answered_appearances_equals_votes_and_skips(question) 257 def answered_appearances_equals_votes_and_skips(question)
258 - error_message = ""  
259 success_message = "All vote and skip objects have an associated appearance object" 258 success_message = "All vote and skip objects have an associated appearance object"
260 skip_appearances_count = Appearance.count( 259 skip_appearances_count = Appearance.count(
261 :conditions => ["skips.valid_record = 1 and appearances.question_id = ? AND answerable_id IS NOT NULL AND answerable_type = 'Skip'", question.id], 260 :conditions => ["skips.valid_record = 1 and appearances.question_id = ? AND answerable_id IS NOT NULL AND answerable_type = 'Skip'", question.id],
@@ -267,15 +266,13 @@ namespace :test_api do @@ -267,15 +266,13 @@ namespace :test_api do
267 total_votes = question.votes.count 266 total_votes = question.votes.count
268 total_skips = question.skips.count 267 total_skips = question.skips.count
269 if (total_answered_appearances != total_votes + total_skips) 268 if (total_answered_appearances != total_votes + total_skips)
270 - error_message += "Question #{question.id}: answered_appearances = #{total_answered_appearances}, votes = #{total_votes}, skips = #{total_skips}" 269 + error_message = "Question #{question.id}: answered_appearances = #{total_answered_appearances}, votes = #{total_votes}, skips = #{total_skips}"
271 end 270 end
272 271
273 -  
274 return error_message.blank? ? [success_message, false] : [error_message, true] 272 return error_message.blank? ? [success_message, false] : [error_message, true]
275 end 273 end
276 274
277 def check_each_choice_appears_within_n_stddevs(question) 275 def check_each_choice_appears_within_n_stddevs(question)
278 - error_message =""  
279 success_message = "Each choice has appeared n times, where n falls within 6 stddevs of the mean number of appearances for a question " + 276 success_message = "Each choice has appeared n times, where n falls within 6 stddevs of the mean number of appearances for a question " +
280 "(Note: this applies only to seed choices (not user submitted) and choices currently marked active)" 277 "(Note: this applies only to seed choices (not user submitted) and choices currently marked active)"
281 278
@@ -304,7 +301,7 @@ namespace :test_api do @@ -304,7 +301,7 @@ namespace :test_api do
304 ignore_choices = [133189] 301 ignore_choices = [133189]
305 appearances_by_choice_id.each do |choice_id, n_i| 302 appearances_by_choice_id.each do |choice_id, n_i|
306 if ((n_i < (mean - 6*stddev)) || (n_i > mean + 6 *stddev)) && !ignore_choices.include?(choice_id) && Choice.find(choice_id).active? 303 if ((n_i < (mean - 6*stddev)) || (n_i > mean + 6 *stddev)) && !ignore_choices.include?(choice_id) && Choice.find(choice_id).active?
307 - error_message += "Choice #{choice_id} in Question ##{question.id} has an irregular number of appearances: #{n_i}, as compared to the mean: #{mean} and stddev #{stddev} for this question\n" 304 + error_message = "Choice #{choice_id} in Question ##{question.id} has an irregular number of appearances: #{n_i}, as compared to the mean: #{mean} and stddev #{stddev} for this question\n"
308 end 305 end
309 end 306 end
310 end 307 end
@@ -313,7 +310,6 @@ namespace :test_api do @@ -313,7 +310,6 @@ namespace :test_api do
313 end 310 end
314 311
315 def check_each_choice_equally_likely_to_appear_left_or_right(question) 312 def check_each_choice_equally_likely_to_appear_left_or_right(question)
316 - error_message = ""  
317 success_message = "All choices have equal probability of appearing on left or right (within error params)" 313 success_message = "All choices have equal probability of appearing on left or right (within error params)"
318 question.choices.each do |c| 314 question.choices.each do |c|
319 left_prompts_ids = c.prompts_on_the_left.ids_only 315 left_prompts_ids = c.prompts_on_the_left.ids_only
@@ -331,7 +327,7 @@ namespace :test_api do @@ -331,7 +327,7 @@ namespace :test_api do
331 z = (est_p - 0.5).abs / Math.sqrt((0.5 * 0.5) / n.to_f) 327 z = (est_p - 0.5).abs / Math.sqrt((0.5 * 0.5) / n.to_f)
332 328
333 if z > 6 329 if z > 6
334 - error_message += "Error: Choice ID #{c.id} seems to favor one side: Left Appearances #{left_appearances}, Right Appearances: #{right_appearances}, z = #{z}\n" 330 + error_message = "Error: Choice ID #{c.id} seems to favor one side: Left Appearances #{left_appearances}, Right Appearances: #{right_appearances}, z = #{z}\n"
335 end 331 end
336 end 332 end
337 return error_message.blank? ? [success_message, false] : [error_message, true] 333 return error_message.blank? ? [success_message, false] : [error_message, true]