diff --git a/app/models/research_output.rb b/app/models/research_output.rb
index 86484e7..1c0ec77 100644
--- a/app/models/research_output.rb
+++ b/app/models/research_output.rb
@@ -77,6 +77,10 @@
return false
end
+ def get_answers_for_section(section_id)
+ self.answers.select { |answer| answer.question_id.in?(Section.find(section_id).questions.pluck(:id)) }
+ end
+
##
# deep copy the given research output
#
diff --git a/app/views/branded/shared/export/_export_by_question.erb b/app/views/branded/shared/export/_export_by_question.erb
index 1ae2bbc..eadaade 100644
--- a/app/views/branded/shared/export/_export_by_question.erb
+++ b/app/views/branded/shared/export/_export_by_question.erb
@@ -11,26 +11,27 @@
<% options = answer.present? ? answer.question_options : [] %>
<% unless @show_unanswered == false && blank %>
-
+
<% if !@public_plan && @show_sections_questions && idx == 0 %>
<%# Hack: for DOCX export - otherwise, bold highlighting of question inconsistent. %>
<% if local_assigns[:export_format] && export_format == 'docx' %>
- <%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>
+ <%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>
<% else %>
-
<%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>
+ <%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>
<% end %>
<% end %>
+ <% if !section_has_common_answers %>
+ <%= research_output.fullname %>
+ <% end %>
+
<%# case where question has not been answered sufficiently to display%>
<% if @show_unanswered && (answer.blank? || (options.blank? && blank))%>
- <% if !section_has_common_answers %>
- <%= research_output.fullname %> :
- <% end %>
<%= _('Question not answered.') -%>
@@ -40,22 +41,16 @@
<%# case where Question has options %>
<% if options.any? %>
- <% if !section_has_common_answers %>
- <%= research_output.fullname %> :
- <% end %>
-
+
<% options.each do |opt| %>
- <%= opt.text %>
<% end %>
-
+
<% end %>
<%# case for RDA answer display %>
<% if question[:format].rda_metadata? && !blank %>
<% ah = answer.answer_hash %>
<% if ah['standards'].present? %>
- <% if !section_has_common_answers %>
- <%= research_output.fullname %> :
- <% end %>
<% ah['standards'].each do |id, title| %>
- <%= title %>
@@ -67,9 +62,6 @@
<%# case for displaying comments OR text %>
<% elsif !blank %>
- <% if !section_has_common_answers %>
- <%= research_output.fullname %> :
- <% end %>
<%= sanitize answer.text %>
diff --git a/app/views/branded/shared/export/_export_by_research_output.erb b/app/views/branded/shared/export/_export_by_research_output.erb
index 4d5910d..3a8ba85 100644
--- a/app/views/branded/shared/export/_export_by_research_output.erb
+++ b/app/views/branded/shared/export/_export_by_research_output.erb
@@ -1,9 +1,12 @@
<%# locals: { research_outputs, questions, section } %>
<% research_outputs.each do |research_output| %>
<% section_has_common_answers = research_output.get_main().has_common_answers?(section[:id]) %>
+ <% show_research_output_content = @show_unanswered || (!@show_unanswered && !research_output.get_answers_for_section(section[:id]).empty?) %>
<% research_output_default_and_alone = research_output.is_default && research_outputs.length == 1 %>
- <% if !section_has_common_answers %>
+ <% if !research_output_default_and_alone &&
+ !section_has_common_answers &&
+ show_research_output_content %>
<%= research_output[:fullname] %>
<% end %>
@@ -38,11 +41,11 @@
<%# case where Question has options %>
<% if options.any? %>
-
+
<% options.each do |opt| %>
- <%= opt.text %>
<% end %>
-
+
<% end %>
<%# case for RDA answer display %>
<% if question[:format].rda_metadata? && !blank %>
@@ -67,7 +70,7 @@
<% end %>
<% end %>
- <% if !section_has_common_answers %>
+ <% if !section_has_common_answers && show_research_output_content %>
<% end %>
<% if section_has_common_answers %>
diff --git a/app/views/branded/shared/export/_plan_coversheet.erb b/app/views/branded/shared/export/_plan_coversheet.erb
index be179a4..4bca0d6 100644
--- a/app/views/branded/shared/export/_plan_coversheet.erb
+++ b/app/views/branded/shared/export/_plan_coversheet.erb
@@ -10,9 +10,9 @@
<%= _("Affiliation: ") %><%= @hash[:affiliation] %>
<% if @hash[:funder].present? %>
- <%= _("Template: ") + @hash[:funder] %>
+ <%= _("Template: ") %><%= @hash[:funder] %>
<% else %>
- <%= _("Template: ") + @hash[:template] + @hash[:customizer] %>
+ <%= _("Template: ") %><%= @hash[:template] + @hash[:customizer] %>
<% end %>
<% if @plan.principal_investigator_identifier.present? %>
@@ -29,19 +29,17 @@
<% end %>
<% if @hash[:research_outputs].length > 1 || !@hash[:research_outputs][0].main?%>
- <%= d_('dmpopidor', "Research outputs: ") %>
-
+ <%= d_('dmpopidor', "Research outputs") %> :
+
<% @hash[:research_outputs].each do |research_output| %>
-
- <%= research_output.fullname %> (
- <%=
+ <%= research_output.fullname %> ( <%=
research_output.research_output_type && research_output.research_output_type.is_other ?
research_output.research_output_type.label + ' : ' + research_output.other_type_label :
research_output.research_output_type.label
- %>
- )
+ %> )
<% end %>
-
+
<% end %>