Method: Qe::ChoiceField#has_answer?

Defined in:
app/models/qe/choice_field.rb

#has_answer?(choice, app) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/qe/choice_field.rb', line 39

def has_answer?(choice, app)
  responses(app).each do |r|   # loop through Answers
     # legacy field type choices may be int or tinyint 
     # raise r.inspect + ' - ' + choice.inspect if id == 1137 && r != 1
     # r = r.to_s
     return true if  case true
                     when is_true(r) then is_true(choice)
                     when is_false(r) then is_false(choice)
                     else
                       r.to_s == choice.to_s
                     end
   end
   false
end