Skip to content

Commit

Permalink
Fix bug: if advice total length is 0, then 'Show advice' link will no…
Browse files Browse the repository at this point in the history
…t show in the view.
  • Loading branch information
Winbobob committed Oct 16, 2015
1 parent 7fe881a commit b295abe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/criterion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ def complete(count, answer=nil, questionnaire_min, questionnaire_max, dropdown_o
html = '<li><p><label for="responses_' +count.to_s+ '">' +self.txt+ '</label></p>'
#show advice for each criterion question
question_advices = QuestionAdvice.where(question_id: self.id).sort_by { |advice| advice.id }
if question_advices.length > 0
advice_total_length = 0
question_advices.each do |question_advice|
advice_total_length += question_advice.advice.length
end

if question_advices.length > 0 and advice_total_length > 0
html += '<a id="showAdivce_' + self.id.to_s + '" onclick="showAdvice(' + self.id.to_s + ')">Show advice</a>'
html += '<script>'
html += 'function showAdvice(i){'
Expand Down

0 comments on commit b295abe

Please sign in to comment.