diff --git a/app/models/answer.rb b/app/models/answer.rb index a2a625f..225a782 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -87,6 +87,18 @@ return notes.select{ |n| n.archived.blank? }.sort!{ |x,y| y.updated_at <=> x.updated_at } end + ## + # Returns True if answer text is blank, false otherwise + # specificly we want to remove empty hml tags and check + # + # @return [Boolean] is the answer's text blank + def is_blank? + if self.text.present? + return self.text.gsub(/<\/?p>/, '').gsub(//, '').chomp.blank? + end + # no text so blank + return True + end ## # Returns the parsed JSON hash for the current answer object diff --git a/app/views/shared/export/_plan.erb b/app/views/shared/export/_plan.erb index fb9acb4..cf0346e 100644 --- a/app/views/shared/export/_plan.erb +++ b/app/views/shared/export/_plan.erb @@ -19,7 +19,7 @@ <%= @plan.title %> - <%= render partial: '/shared/export/plan_styling', + <%= render partial: '/shared/export/plan_styling', locals: { font_face: font_face, font_size: "#{font_size}pt", @@ -56,13 +56,14 @@ <% end %>
<% end %> - <% answer = @plan.answer(question[:id], false) %> - <% blank = (answer.present? && answer.is_valid?) ? answer.text.gsub(/<\/?p>/, '').gsub(//, '').chomp.blank? : true %> + <% blank = answer.present? ? answer.is_blank? : true %> <% options = answer.present? ? answer.question_options : [] %> - <% if blank && @show_unanswered && options.blank? %> + <%# case where question has not been answered sufficiently to display%> + <% if @show_unanswered && (answer.blank? || (options.blank? && blank)))%>

<%= _('Question not answered.') -%>

- <% elsif !blank %> + <% else %> + <%# case where Question has options %> <% if options.present?%> <% end %> - <% if question[:format].rda_metadata? %> + <%# case for RDA answer display %> + <% if question[:format].rda_metadata? && !blank %> <% ah = answer.answer_hash %> <% if ah['standards'].present? %> <% end %>

<%= raw ah['text'] %>

- <% else %> + <%# case for displaying comments OR text %> + <% elsif !blank %>

<%= raw answer.text %>

<% end %> <% end %>