Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positive for Question#triggered? #469

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/surveyor/models/question_methods.rb
Expand Up @@ -63,7 +63,13 @@ def dependent?
self.dependency != nil
end
def triggered?(response_set)
dependent? ? self.dependency.is_met?(response_set) : true
if dependent?
dependency.is_met?(response_set)
elsif question_group.try(:dependent?)
question_group.dependency.is_met?(response_set)
else
true
end
end
def css_class(response_set)
[(dependent? ? "q_dependent" : nil), (triggered?(response_set) ? nil : "q_hidden"), custom_class].compact.join(" ")
Expand Down
6 changes: 5 additions & 1 deletion lib/surveyor/models/response_set_methods.rb
Expand Up @@ -108,7 +108,11 @@ def is_answered?(question)
%w(label image).include?(question.display_type) or !is_unanswered?(question)
end
def is_unanswered?(question)
self.responses.detect{|r| r.question_id == question.id}.nil?
if question.display_type == 'label'
false
else
self.responses.detect{|r| r.question_id == question.id}.nil?
end
end
def is_group_unanswered?(group)
group.questions.any?{|question| is_unanswered?(question)}
Expand Down